Skip to content

Commit 3ff3fb7

Browse files
authored
feat(integ-tests): enhancements to integ-tests (#20180)
This PR contains various enhancements including - `integ-tests` - removed dependency on other CDK libraries (other than core) - API ergonomics improvements - renamed `queryAws` to `awsApiCall` - added some additional methods - Now using `Match` from @aws-cdk/assertions for the assertions provider - `DeployAssert` now creates its own stack - This stack is written to a new IntegManifest property so that it can be treated differently (i.e. don't diff this stack) - Additional assertion types (OBJECT_LIKE) - Refactored assertion results - removed separate results handler in favor of just writing results to a stack output - utility for invoking lambda functions (separate from `awsApiCall`) - `IntegTest` now creates a test case by default. - Added `IntegTestCaseStack` class - `integ-runner` - Updated to handle the results of assertions - When running with update workflow, the assertion stack is only deployed during the "update" deployment - The stack outputs containing the assertion results are are written to a file that the runner can read. I've also converted/added assertions to a couple of existing integration tests - `aws-lambda/test/integ.bundling.ts` - `aws-lambda-destinations/test/integ.destinations.ts` - `aws-stepfunctions-tasks/test/eventbridge/integ.put-events.ts` ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 861a2bb commit 3ff3fb7

File tree

64 files changed

+5275
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5275
-577
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from '../match';
2+
export * from '../matcher';

packages/@aws-cdk/assertions/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"build+extract": "yarn build && yarn rosetta:extract",
1919
"build+test+extract": "yarn build+test && yarn rosetta:extract"
2020
},
21+
"ubergen": {
22+
"exports": {
23+
"./lib/helpers-internal": "./lib/helpers-internal/index.js"
24+
}
25+
},
2126
"jsii": {
2227
"outdir": "dist",
2328
"diagnostics": {

packages/@aws-cdk/aws-lambda-destinations/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"license": "Apache-2.0",
7373
"devDependencies": {
7474
"@aws-cdk/assertions": "0.0.0",
75+
"@aws-cdk/integ-tests": "0.0.0",
7576
"@aws-cdk/cdk-build-tools": "0.0.0",
7677
"@aws-cdk/integ-runner": "0.0.0",
7778
"@aws-cdk/cfn2ts": "0.0.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
{
2+
"Resources": {
3+
"LambdaInvoked12df417a1b74909abb3ea643735a310": {
4+
"Type": "Custom::DeployAssert@SdkCallLambdainvoke",
5+
"Properties": {
6+
"ServiceToken": {
7+
"Fn::GetAtt": [
8+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F",
9+
"Arn"
10+
]
11+
},
12+
"service": "Lambda",
13+
"api": "invoke",
14+
"parameters": {
15+
"FunctionName": {
16+
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefSnsSqsC4810B27404A5AFF"
17+
},
18+
"InvocationType": "Event",
19+
"Payload": "{\"status\":\"OK\"}"
20+
},
21+
"flattenResponse": "false",
22+
"salt": "1651691787842"
23+
},
24+
"UpdateReplacePolicy": "Delete",
25+
"DeletionPolicy": "Delete"
26+
},
27+
"LambdaInvoked12df417a1b74909abb3ea643735a310InvokeF590C289": {
28+
"Type": "AWS::Lambda::Permission",
29+
"Properties": {
30+
"Action": "lambda:InvokeFunction",
31+
"FunctionName": {
32+
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefSnsSqsC4810B27404A5AFF"
33+
},
34+
"Principal": {
35+
"Fn::GetAtt": [
36+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
37+
"Arn"
38+
]
39+
}
40+
}
41+
},
42+
"AwsApiCallSQSreceiveMessage": {
43+
"Type": "Custom::DeployAssert@SdkCallSQSreceiveMessage",
44+
"Properties": {
45+
"ServiceToken": {
46+
"Fn::GetAtt": [
47+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F",
48+
"Arn"
49+
]
50+
},
51+
"service": "SQS",
52+
"api": "receiveMessage",
53+
"parameters": {
54+
"QueueUrl": {
55+
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefQueue4A7E3555425E8BD3"
56+
},
57+
"WaitTimeSeconds": 20
58+
},
59+
"flattenResponse": "true",
60+
"salt": "1651691787842"
61+
},
62+
"UpdateReplacePolicy": "Delete",
63+
"DeletionPolicy": "Delete"
64+
},
65+
"AwsApiCallSQSreceiveMessageAssertEqualsSQSreceiveMessage56120636": {
66+
"Type": "Custom::DeployAssert@AssertEquals",
67+
"Properties": {
68+
"ServiceToken": {
69+
"Fn::GetAtt": [
70+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F",
71+
"Arn"
72+
]
73+
},
74+
"actual": {
75+
"Fn::GetAtt": [
76+
"AwsApiCallSQSreceiveMessage",
77+
"apiCallResponse.Messages.0.Body"
78+
]
79+
},
80+
"expected": "{\"$ObjectLike\":{\"requestContext\":{\"condition\":\"Success\"},\"requestPayload\":{\"status\":\"OK\"},\"responseContext\":{\"statusCode\":200},\"responsePayload\":\"success\"}}",
81+
"salt": "1651691787843"
82+
},
83+
"UpdateReplacePolicy": "Delete",
84+
"DeletionPolicy": "Delete"
85+
},
86+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": {
87+
"Type": "AWS::IAM::Role",
88+
"Properties": {
89+
"AssumeRolePolicyDocument": {
90+
"Version": "2012-10-17",
91+
"Statement": [
92+
{
93+
"Action": "sts:AssumeRole",
94+
"Effect": "Allow",
95+
"Principal": {
96+
"Service": "lambda.amazonaws.com"
97+
}
98+
}
99+
]
100+
},
101+
"ManagedPolicyArns": [
102+
{
103+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
104+
}
105+
],
106+
"Policies": [
107+
{
108+
"PolicyName": "Inline",
109+
"PolicyDocument": {
110+
"Version": "2012-10-17",
111+
"Statement": [
112+
{
113+
"Action": [
114+
"lambda:Invoke"
115+
],
116+
"Effect": "Allow",
117+
"Resource": [
118+
"*"
119+
]
120+
},
121+
{
122+
"Action": [
123+
"lambda:InvokeFunction"
124+
],
125+
"Effect": "Allow",
126+
"Resource": [
127+
{
128+
"Fn::Join": [
129+
"",
130+
[
131+
"arn:",
132+
{
133+
"Ref": "AWS::Partition"
134+
},
135+
":lambda:",
136+
{
137+
"Ref": "AWS::Region"
138+
},
139+
":",
140+
{
141+
"Ref": "AWS::AccountId"
142+
},
143+
":function:",
144+
{
145+
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefSnsSqsC4810B27404A5AFF"
146+
}
147+
]
148+
]
149+
}
150+
]
151+
},
152+
{
153+
"Action": [
154+
"sqs:ReceiveMessage"
155+
],
156+
"Effect": "Allow",
157+
"Resource": [
158+
"*"
159+
]
160+
}
161+
]
162+
}
163+
}
164+
]
165+
}
166+
},
167+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": {
168+
"Type": "AWS::Lambda::Function",
169+
"Properties": {
170+
"Runtime": "nodejs14.x",
171+
"Code": {
172+
"S3Bucket": {
173+
"Ref": "AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3BucketF7210344"
174+
},
175+
"S3Key": {
176+
"Fn::Join": [
177+
"",
178+
[
179+
{
180+
"Fn::Select": [
181+
0,
182+
{
183+
"Fn::Split": [
184+
"||",
185+
{
186+
"Ref": "AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3VersionKey1E71961C"
187+
}
188+
]
189+
}
190+
]
191+
},
192+
{
193+
"Fn::Select": [
194+
1,
195+
{
196+
"Fn::Split": [
197+
"||",
198+
{
199+
"Ref": "AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3VersionKey1E71961C"
200+
}
201+
]
202+
}
203+
]
204+
}
205+
]
206+
]
207+
}
208+
},
209+
"Timeout": 120,
210+
"Handler": "index.handler",
211+
"Role": {
212+
"Fn::GetAtt": [
213+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
214+
"Arn"
215+
]
216+
}
217+
}
218+
}
219+
},
220+
"Outputs": {
221+
"AssertionResultsAssertEqualsSQSreceiveMessage": {
222+
"Value": {
223+
"Fn::GetAtt": [
224+
"AwsApiCallSQSreceiveMessageAssertEqualsSQSreceiveMessage56120636",
225+
"data"
226+
]
227+
}
228+
}
229+
},
230+
"Parameters": {
231+
"AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3BucketF7210344": {
232+
"Type": "String",
233+
"Description": "S3 bucket for asset \"1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38b\""
234+
},
235+
"AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3VersionKey1E71961C": {
236+
"Type": "String",
237+
"Description": "S3 key for asset version \"1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38b\""
238+
},
239+
"AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bArtifactHash4F8362F2": {
240+
"Type": "String",
241+
"Description": "Artifact hash for asset \"1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38b\""
242+
}
243+
}
244+
}

0 commit comments

Comments
 (0)