-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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*
- Loading branch information
Showing
12 changed files
with
2,105 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...t/integ.dependencies-pnpm.js.snapshot/PnpmTestDefaultTestDeployAssert397EDF83.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"version": "29.0.0", | ||
"files": { | ||
"1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28": { | ||
"source": { | ||
"path": "asset.1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.bundle", | ||
"packaging": "zip" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
}, | ||
"2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb": { | ||
"source": { | ||
"path": "PnpmTestDefaultTestDeployAssert397EDF83.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
178 changes: 178 additions & 0 deletions
178
...integ.dependencies-pnpm.js.snapshot/PnpmTestDefaultTestDeployAssert397EDF83.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
{ | ||
"Resources": { | ||
"LambdaInvoke55933c6da447c7ea94ebd3a50e8557a8": { | ||
"Type": "Custom::DeployAssert@SdkCallLambdainvoke", | ||
"Properties": { | ||
"ServiceToken": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", | ||
"Arn" | ||
] | ||
}, | ||
"service": "Lambda", | ||
"api": "invoke", | ||
"expected": "{\"$ObjectLike\":{\"StatusCode\":200,\"ExecutedVersion\":\"$LATEST\",\"Payload\":\"null\"}}", | ||
"parameters": { | ||
"FunctionName": { | ||
"Fn::ImportValue": "TestStack:ExportsOutputRefFunction76856677C48862D5" | ||
} | ||
}, | ||
"flattenResponse": "false", | ||
"salt": "1674225978419" | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"LambdaInvoke55933c6da447c7ea94ebd3a50e8557a8InvokeA3F6E40A": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Fn::ImportValue": "TestStack:ExportsOutputRefFunction76856677C48862D5" | ||
}, | ||
"Principal": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
} | ||
], | ||
"Policies": [ | ||
{ | ||
"PolicyName": "Inline", | ||
"PolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"lambda:Invoke" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
"*" | ||
] | ||
}, | ||
{ | ||
"Action": [ | ||
"lambda:InvokeFunction" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":lambda:", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
":", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":function:", | ||
{ | ||
"Fn::ImportValue": "TestStack:ExportsOutputRefFunction76856677C48862D5" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Runtime": "nodejs14.x", | ||
"Code": { | ||
"S3Bucket": { | ||
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" | ||
}, | ||
"S3Key": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip" | ||
}, | ||
"Timeout": 120, | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"AssertionResultsLambdaInvoke55933c6da447c7ea94ebd3a50e8557a8": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"LambdaInvoke55933c6da447c7ea94ebd3a50e8557a8", | ||
"assertion" | ||
] | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...@aws-cdk/aws-lambda-nodejs/test/integ.dependencies-pnpm.js.snapshot/TestStack.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"version": "29.0.0", | ||
"files": { | ||
"b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9": { | ||
"source": { | ||
"path": "asset.b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9", | ||
"packaging": "zip" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
}, | ||
"b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327": { | ||
"source": { | ||
"path": "TestStack.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
106 changes: 106 additions & 0 deletions
106
...ws-cdk/aws-lambda-nodejs/test/integ.dependencies-pnpm.js.snapshot/TestStack.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
{ | ||
"Resources": { | ||
"FunctionServiceRole675BB04A": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"Function76856677": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": { | ||
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" | ||
}, | ||
"S3Key": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"FunctionServiceRole675BB04A", | ||
"Arn" | ||
] | ||
}, | ||
"Environment": { | ||
"Variables": { | ||
"AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1" | ||
} | ||
}, | ||
"Handler": "index.handler", | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"FunctionServiceRole675BB04A" | ||
] | ||
} | ||
}, | ||
"Outputs": { | ||
"ExportsOutputRefFunction76856677C48862D5": { | ||
"Value": { | ||
"Ref": "Function76856677" | ||
}, | ||
"Export": { | ||
"Name": "TestStack:ExportsOutputRefFunction76856677C48862D5" | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.