Skip to content

Commit

Permalink
Fixed test kafkaApi e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
armaseg committed Sep 10, 2024
1 parent 68756bb commit 699f11f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions framework/src/streaming/lib/msk/kafka-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class KafkaApi extends TrackedConstruct {
this.mskAclLogGroup = mskAclProvider.onEventHandlerLogGroup;
this.mskAclFunction = mskAclProvider.onEventHandlerFunction;
this.mskAclSecurityGroup = mskAclProvider.securityGroups;
this.serviceToken = mskAclProvider.serviceToken;
}
}

Expand All @@ -147,6 +148,7 @@ export class KafkaApi extends TrackedConstruct {
this.mskIamLogGroup = mskIamProvider.onEventHandlerLogGroup;
this.mskIamFunction = mskIamProvider.onEventHandlerFunction;
this.mskIamSecurityGroup = mskIamProvider.securityGroups;
this.serviceToken = mskIamProvider.serviceToken;
}
}

Expand Down
2 changes: 1 addition & 1 deletion framework/src/streaming/lib/msk/msk-provisioned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ export class MskProvisioned extends TrackedConstruct {
}

new CfnOutput(this, 'ServiceToken', {
value: this.kafkaApi.serviceToken!,
value: this.serviceToken!,
exportName: 'ServiceToken',
});

Expand Down
2 changes: 1 addition & 1 deletion framework/src/streaming/lib/msk/msk-serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class MskServerless extends TrackedConstruct {
this.serviceToken = this.kafkaApi.serviceToken;

new CfnOutput(this, 'ServiceToken', {
value: this.kafkaApi.serviceToken!,
value: this.serviceToken!,
exportName: 'ServiceToken',
});
}
Expand Down
30 changes: 20 additions & 10 deletions framework/test/e2e/kafka-api-byo-service-token.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

import { App, RemovalPolicy, CfnOutput } from 'aws-cdk-lib';

import { CertificateAuthority } from 'aws-cdk-lib/aws-acmpca';
import { SecurityGroup, SubnetType } from 'aws-cdk-lib/aws-ec2';
import { CfnCluster } from 'aws-cdk-lib/aws-msk';
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { TestStack } from './test-stack';
import { AclOperationTypes, AclPermissionTypes, AclResourceTypes, ClientAuthentication, KafkaApi, KafkaClientLogLevel, MskClusterType, MskServerless, ResourcePatternTypes } from '../../src/streaming';
import { ClientAuthentication, KafkaApi, KafkaClientLogLevel, MskClusterType, MskServerless, Authentication} from '../../src/streaming';
import { DataVpc, Utils } from '../../src/utils';


Expand Down Expand Up @@ -43,7 +40,7 @@ const msk = new MskServerless(stack, 'cluster', {
kafkaClientLogLevel: KafkaClientLogLevel.DEBUG,
});

const mskApi = new KafkaApi(stack, 'kafkaApi', {
const kafkaApi = new KafkaApi(stack, 'kafkaApi', {
vpc: vpc.vpc,
clusterArn: msk.cluster.attrArn,
subnets: vpc.vpc.selectSubnets({ subnetType: SubnetType.PRIVATE_WITH_EGRESS }),
Expand All @@ -55,10 +52,16 @@ const mskApi = new KafkaApi(stack, 'kafkaApi', {
serviceToken: msk.serviceToken,
});

msk.addTopic('topicServerelss', {
topic: 'dummy',
numPartitions: 1,
}, RemovalPolicy.DESTROY, false, 1500);

kafkaApi.setTopic('dummyTopic',
Authentication.IAM,
{
topic: 'dummy',
numPartitions: 3,
},
RemovalPolicy.DESTROY,
true, 1000
);

new CfnOutput(stack, 'clusterArn', {
value: msk.cluster.attrArn,
Expand All @@ -71,11 +74,18 @@ beforeAll(async () => {
deployResult = await testStack.deploy();
}, 10000000);

it('Containers runtime created successfully', async () => {
test('MSK cluster created successfully', async () => {
// THEN
expect(deployResult.clusterArn).toContain('arn');
});

/*
test('Kafka API outputs service token successfully', async () => {
// THEN
expect(deployResult.ServiceToken).toContain('arn');
});
*/

afterAll(async () => {
await testStack.destroy();
}, 10000000);
6 changes: 1 addition & 5 deletions framework/test/e2e/kafka-api.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,14 @@ new CfnOutput(stack, 'clusterArn', {
value: cfnCluster.attrArn,
});

new CfnOutput(stack, 'serviceToken', {
value: mskApi.serviceToken!,
});

let deployResult: Record<string, string>;

beforeAll(async() => {
// WHEN
deployResult = await testStack.deploy();
}, 10000000);

it('Containers runtime created successfully', async () => {
test('CMSK cluster created successfully', async () => {
// THEN
expect(deployResult.clusterArn).toContain('arn');
});
Expand Down

0 comments on commit 699f11f

Please sign in to comment.