Provision streams before tests, publish UTF-8 record fixtures, and manage development streams. Task types live in io.github.gregwhitaker.awsemulator.aws.kinesis.
Provision Before Tests
import io.github.gregwhitaker.awsemulator.aws.kinesis.CreateKinesisStreamTask
import io.github.gregwhitaker.awsemulator.aws.kinesis.PublishKinesisRecordsTask
plugins {
java
id("io.github.gregwhitaker.aws-emulator") version "0.3.0"
}
val stream = tasks.register<CreateKinesisStreamTask>("createOrdersStream") {
streamName.set("application-orders")
}
val records = tasks.register<PublishKinesisRecordsTask>("publishTestRecords") {
dependsOn(stream)
streamName.set("application-orders")
fixtures.set(layout.projectDirectory.file("fixtures/records.json"))
}
val tests = tasks.named<Test>("test") { dependsOn(records) }
awsEmulator { useWith(tests) }
The stream task waits for ACTIVE before records are published. Tests use their own Kinesis SDK client to consume the records.
Task Properties
-
CreateKinesisStreamTask:streamName,shardCount(default 1),waitTimeoutSeconds(default 60). Creates/reuses a provisioned stream and waits forACTIVE; conflicting shard counts or stream modes fail. -
PublishKinesisRecordsTask:streamName,fixtures. Sends UTF-8 strings with partition keys throughPutRecords. -
ListKinesisStreamsTask: lists all stream names. -
DeleteKinesisStreamTask:streamName,waitTimeoutSeconds(default 60). Waits for disappearance; missing streams are safe to repeat.
Record Fixtures
[
{"partitionKey":"order-1","data":"first-record"},
{"partitionKey":"order-2","data":"second-record"}
]
Both fields must be strings, and partition keys must be nonblank with at most 256 characters. This release conservatively limits each record, including its partition key, to 1 MiB and each batch to 500 records/5 MiB. Partial failures report one-based fixture indexes without replaying successful records. PutRecords does not guarantee ordering. Resharding, retention changes, and enhanced fan-out consumers are outside this scope.
SDK Protocol Settings
The pinned SDK defaults to CBOR, which this emulator workflow does not accept. Kinesis tasks therefore use a process-isolated Gradle worker with aws.cborEnabled=false; no Gradle daemon system property is changed. awsEmulator.useWith(…) sets aws.cborEnabled=false and CBOR_ENABLED=false for participating application JVMs. Configure JSON explicitly for separately launched SDK consumers.
Development Commands
Predefined commands: listKinesisStreams and deleteKinesisStream --streamName=….
./gradlew listKinesisStreams
./gradlew deleteKinesisStream --streamName=application-orders
Runtime Selection
Custom resource tasks inherit awsEmulator.defaultMode, initially MANAGED. Make the consuming test or application task depend on provisioning and opt that consumer in with awsEmulator.useWith(…). Provisioning and consumers must select the same runtime name and mode; see resource task defaults to configure a shared development default.
Every task accepts runtimeName (default default), mode, and apiCallTimeoutSeconds (default 30, positive). Predefined inspection and deletion commands default to DEVELOPMENT; select another mode with --mode=MANAGED or another declared runtime with --runtime <name>. For persistent setup, see development resource tasks.
Resource tasks always execute against live emulator state and do not use the build cache. Configuration-cache reuse is supported. Applying the plugin and listing tasks do not start Docker. Task input values may be stored in Gradle’s configuration cache; fixtures should contain local test values.
Runnable Example
./gradlew -p examples/services verifyServices --configuration-cache
The example creates a stream, publishes record fixtures, and consumes them with AWS SDK for Java v2. Run the command twice to check configuration-cache reuse against a fresh managed emulator. -PfailExample=true deliberately fails the application test to demonstrate cleanup. See the runnable example for its complete setup and persistent development commands.
Verified Scope
The examples exercise these workflows against the pinned AWS Emulator 1.0.385, using AWS SDK for Java v2 2.39.6. They establish the behavior used by these tasks, not complete AWS service equivalence. AWS Emulator fidelity varies by operation and release.