Skip to content

Commit 366f2ab

Browse files
authored
fix(integ-runner): cleanup tmp snapshot before running test (#23773)
The integ-runner obtains information on how to run a test from the `integ.json` manifest file in the cloud assembly. In order to get this information for a new version of the test it first synthesizes the new cloud assembly _only for the purpose of loading the integ manifest_. It will then run the actual test which synthesizes again into the same cloud assembly directory. We need to cleanup that first temporary cloud assembly _before_ running the actual test to make sure we remove any leftover files. Here is one example of what might happen. 1. Do the temporary synthesis and create the cloud assembly at `cdk-integ.out.my-test.js/`. This assembly has an asset with some hash `asset.abcdefg`. 2. Do the synthesis while executing the test. The cloud assembly at `cdk-integ.out.my-test.js` is updated. This time the asset hash is different `asset.123456`. Now we have two assets in the cloud assembly and one `asset.abcdefg` is not being used! 3. Test completes and copies the temporary snapshot to the final snapshot directory, including the old asset I've also added back the `lambda-nodejs/integ.dependencies-pnpm.ts` integration test that was removed in #23728. With this fix the test will no longer check in the asset file. I also removed the Trigger from the test since that is what introduced the always changing diff. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/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 8a7dffd commit 366f2ab

File tree

12 files changed

+2105
-1
lines changed

12 files changed

+2105
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "29.0.0",
3+
"files": {
4+
"1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28": {
5+
"source": {
6+
"path": "asset.1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.bundle",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb": {
18+
"source": {
19+
"path": "PnpmTestDefaultTestDeployAssert397EDF83.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
{
2+
"Resources": {
3+
"LambdaInvoke55933c6da447c7ea94ebd3a50e8557a8": {
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+
"expected": "{\"$ObjectLike\":{\"StatusCode\":200,\"ExecutedVersion\":\"$LATEST\",\"Payload\":\"null\"}}",
15+
"parameters": {
16+
"FunctionName": {
17+
"Fn::ImportValue": "TestStack:ExportsOutputRefFunction76856677C48862D5"
18+
}
19+
},
20+
"flattenResponse": "false",
21+
"salt": "1674225978419"
22+
},
23+
"UpdateReplacePolicy": "Delete",
24+
"DeletionPolicy": "Delete"
25+
},
26+
"LambdaInvoke55933c6da447c7ea94ebd3a50e8557a8InvokeA3F6E40A": {
27+
"Type": "AWS::Lambda::Permission",
28+
"Properties": {
29+
"Action": "lambda:InvokeFunction",
30+
"FunctionName": {
31+
"Fn::ImportValue": "TestStack:ExportsOutputRefFunction76856677C48862D5"
32+
},
33+
"Principal": {
34+
"Fn::GetAtt": [
35+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
36+
"Arn"
37+
]
38+
}
39+
}
40+
},
41+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": {
42+
"Type": "AWS::IAM::Role",
43+
"Properties": {
44+
"AssumeRolePolicyDocument": {
45+
"Version": "2012-10-17",
46+
"Statement": [
47+
{
48+
"Action": "sts:AssumeRole",
49+
"Effect": "Allow",
50+
"Principal": {
51+
"Service": "lambda.amazonaws.com"
52+
}
53+
}
54+
]
55+
},
56+
"ManagedPolicyArns": [
57+
{
58+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
59+
}
60+
],
61+
"Policies": [
62+
{
63+
"PolicyName": "Inline",
64+
"PolicyDocument": {
65+
"Version": "2012-10-17",
66+
"Statement": [
67+
{
68+
"Action": [
69+
"lambda:Invoke"
70+
],
71+
"Effect": "Allow",
72+
"Resource": [
73+
"*"
74+
]
75+
},
76+
{
77+
"Action": [
78+
"lambda:InvokeFunction"
79+
],
80+
"Effect": "Allow",
81+
"Resource": [
82+
{
83+
"Fn::Join": [
84+
"",
85+
[
86+
"arn:",
87+
{
88+
"Ref": "AWS::Partition"
89+
},
90+
":lambda:",
91+
{
92+
"Ref": "AWS::Region"
93+
},
94+
":",
95+
{
96+
"Ref": "AWS::AccountId"
97+
},
98+
":function:",
99+
{
100+
"Fn::ImportValue": "TestStack:ExportsOutputRefFunction76856677C48862D5"
101+
}
102+
]
103+
]
104+
}
105+
]
106+
}
107+
]
108+
}
109+
}
110+
]
111+
}
112+
},
113+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": {
114+
"Type": "AWS::Lambda::Function",
115+
"Properties": {
116+
"Runtime": "nodejs14.x",
117+
"Code": {
118+
"S3Bucket": {
119+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
120+
},
121+
"S3Key": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip"
122+
},
123+
"Timeout": 120,
124+
"Handler": "index.handler",
125+
"Role": {
126+
"Fn::GetAtt": [
127+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
128+
"Arn"
129+
]
130+
}
131+
}
132+
}
133+
},
134+
"Outputs": {
135+
"AssertionResultsLambdaInvoke55933c6da447c7ea94ebd3a50e8557a8": {
136+
"Value": {
137+
"Fn::GetAtt": [
138+
"LambdaInvoke55933c6da447c7ea94ebd3a50e8557a8",
139+
"assertion"
140+
]
141+
}
142+
}
143+
},
144+
"Parameters": {
145+
"BootstrapVersion": {
146+
"Type": "AWS::SSM::Parameter::Value<String>",
147+
"Default": "/cdk-bootstrap/hnb659fds/version",
148+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
149+
}
150+
},
151+
"Rules": {
152+
"CheckBootstrapVersion": {
153+
"Assertions": [
154+
{
155+
"Assert": {
156+
"Fn::Not": [
157+
{
158+
"Fn::Contains": [
159+
[
160+
"1",
161+
"2",
162+
"3",
163+
"4",
164+
"5"
165+
],
166+
{
167+
"Ref": "BootstrapVersion"
168+
}
169+
]
170+
}
171+
]
172+
},
173+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
174+
}
175+
]
176+
}
177+
}
178+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "29.0.0",
3+
"files": {
4+
"b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9": {
5+
"source": {
6+
"path": "asset.b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327": {
18+
"source": {
19+
"path": "TestStack.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"Resources": {
3+
"FunctionServiceRole675BB04A": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"Function76856677": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Code": {
38+
"S3Bucket": {
39+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
40+
},
41+
"S3Key": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip"
42+
},
43+
"Role": {
44+
"Fn::GetAtt": [
45+
"FunctionServiceRole675BB04A",
46+
"Arn"
47+
]
48+
},
49+
"Environment": {
50+
"Variables": {
51+
"AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1"
52+
}
53+
},
54+
"Handler": "index.handler",
55+
"Runtime": "nodejs18.x"
56+
},
57+
"DependsOn": [
58+
"FunctionServiceRole675BB04A"
59+
]
60+
}
61+
},
62+
"Outputs": {
63+
"ExportsOutputRefFunction76856677C48862D5": {
64+
"Value": {
65+
"Ref": "Function76856677"
66+
},
67+
"Export": {
68+
"Name": "TestStack:ExportsOutputRefFunction76856677C48862D5"
69+
}
70+
}
71+
},
72+
"Parameters": {
73+
"BootstrapVersion": {
74+
"Type": "AWS::SSM::Parameter::Value<String>",
75+
"Default": "/cdk-bootstrap/hnb659fds/version",
76+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
77+
}
78+
},
79+
"Rules": {
80+
"CheckBootstrapVersion": {
81+
"Assertions": [
82+
{
83+
"Assert": {
84+
"Fn::Not": [
85+
{
86+
"Fn::Contains": [
87+
[
88+
"1",
89+
"2",
90+
"3",
91+
"4",
92+
"5"
93+
],
94+
{
95+
"Ref": "BootstrapVersion"
96+
}
97+
]
98+
}
99+
]
100+
},
101+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
102+
}
103+
]
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)