Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scheduler-targets-alpha): KinesisStreamPutRecord Target #27845

Merged
merged 23 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP in integ tests
  • Loading branch information
go-to-k committed Nov 5, 2023
commit c8fe724c21ef33d57bbdb16e38390fed957a557b
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as scheduler from '@aws-cdk/aws-scheduler-alpha';
import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';
import { KinesisStreamPutRecord } from '../lib';
import { Stream } from 'aws-cdk-lib/aws-kinesis';

/*
* Stack verification steps:
* A record is put to the kinesis data stream stream by the scheduler
* The assertion checks that the expected record is received by the stream
*/
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-scheduler-targets-kinesis-stream-put-record');

const payload = {
Data: 'record',
};
const streamName = 'my-stream';
const partitionKey = 'key';

const stream = new Stream(stack, 'MyStream', {
streamName,
shardCount: 1,
});

new scheduler.Schedule(stack, 'Schedule', {
schedule: scheduler.ScheduleExpression.rate(cdk.Duration.minutes(1)),
target: new KinesisStreamPutRecord(stream, {
input: scheduler.ScheduleTargetInput.fromObject(payload),
partitionKey: partitionKey,
}),
});

const integrationTest = new IntegTest(app, 'integrationtest-kinesis-stream-put-record', {
testCases: [stack],
stackUpdateWorkflow: false, // this would cause the schedule to trigger with the old code
});

// Verifies that an object was delivered to the S3 bucket by the stream
const getShardIterator = integrationTest.assertions.awsApiCall('kinesis', 'getShardIterator', {
ShardId: 'shardId-000000000',
ShardIteratorType: 'TRIM_HORIZON',
StreamName: streamName,
}).waitForAssertions({
interval: cdk.Duration.seconds(30),
totalTimeout: cdk.Duration.minutes(10),
});

integrationTest.assertions.awsApiCall('kinesis', 'getRecords', {
ShardIterator: getShardIterator.getAttString('ShardIterator'),
}).expect(ExpectedResult.objectLike(
{
Records: ExpectedResult.arrayWith([
{
PartitionKey: partitionKey,
},
]),
},
)).waitForAssertions({
interval: cdk.Duration.seconds(30),
totalTimeout: cdk.Duration.minutes(10),
});

app.synth();
Loading