-
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.
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*
- Loading branch information
Showing
64 changed files
with
5,275 additions
and
577 deletions.
There are no files selected for viewing
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,2 @@ | ||
export * from '../match'; | ||
export * from '../matcher'; |
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
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
244 changes: 244 additions & 0 deletions
244
...est/destinations.integ.snapshot/DestinationsDefaultTestDeployAssertCC49E667.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,244 @@ | ||
{ | ||
"Resources": { | ||
"LambdaInvoked12df417a1b74909abb3ea643735a310": { | ||
"Type": "Custom::DeployAssert@SdkCallLambdainvoke", | ||
"Properties": { | ||
"ServiceToken": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", | ||
"Arn" | ||
] | ||
}, | ||
"service": "Lambda", | ||
"api": "invoke", | ||
"parameters": { | ||
"FunctionName": { | ||
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefSnsSqsC4810B27404A5AFF" | ||
}, | ||
"InvocationType": "Event", | ||
"Payload": "{\"status\":\"OK\"}" | ||
}, | ||
"flattenResponse": "false", | ||
"salt": "1651691787842" | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"LambdaInvoked12df417a1b74909abb3ea643735a310InvokeF590C289": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefSnsSqsC4810B27404A5AFF" | ||
}, | ||
"Principal": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"AwsApiCallSQSreceiveMessage": { | ||
"Type": "Custom::DeployAssert@SdkCallSQSreceiveMessage", | ||
"Properties": { | ||
"ServiceToken": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", | ||
"Arn" | ||
] | ||
}, | ||
"service": "SQS", | ||
"api": "receiveMessage", | ||
"parameters": { | ||
"QueueUrl": { | ||
"Fn::ImportValue": "aws-cdk-lambda-destinations:ExportsOutputRefQueue4A7E3555425E8BD3" | ||
}, | ||
"WaitTimeSeconds": 20 | ||
}, | ||
"flattenResponse": "true", | ||
"salt": "1651691787842" | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"AwsApiCallSQSreceiveMessageAssertEqualsSQSreceiveMessage56120636": { | ||
"Type": "Custom::DeployAssert@AssertEquals", | ||
"Properties": { | ||
"ServiceToken": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", | ||
"Arn" | ||
] | ||
}, | ||
"actual": { | ||
"Fn::GetAtt": [ | ||
"AwsApiCallSQSreceiveMessage", | ||
"apiCallResponse.Messages.0.Body" | ||
] | ||
}, | ||
"expected": "{\"$ObjectLike\":{\"requestContext\":{\"condition\":\"Success\"},\"requestPayload\":{\"status\":\"OK\"},\"responseContext\":{\"statusCode\":200},\"responsePayload\":\"success\"}}", | ||
"salt": "1651691787843" | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"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": "aws-cdk-lambda-destinations:ExportsOutputRefSnsSqsC4810B27404A5AFF" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Action": [ | ||
"sqs:ReceiveMessage" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Runtime": "nodejs14.x", | ||
"Code": { | ||
"S3Bucket": { | ||
"Ref": "AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3BucketF7210344" | ||
}, | ||
"S3Key": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::Select": [ | ||
0, | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Ref": "AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3VersionKey1E71961C" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Fn::Select": [ | ||
1, | ||
{ | ||
"Fn::Split": [ | ||
"||", | ||
{ | ||
"Ref": "AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3VersionKey1E71961C" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
"Timeout": 120, | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"AssertionResultsAssertEqualsSQSreceiveMessage": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"AwsApiCallSQSreceiveMessageAssertEqualsSQSreceiveMessage56120636", | ||
"data" | ||
] | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3BucketF7210344": { | ||
"Type": "String", | ||
"Description": "S3 bucket for asset \"1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38b\"" | ||
}, | ||
"AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bS3VersionKey1E71961C": { | ||
"Type": "String", | ||
"Description": "S3 key for asset version \"1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38b\"" | ||
}, | ||
"AssetParameters1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38bArtifactHash4F8362F2": { | ||
"Type": "String", | ||
"Description": "Artifact hash for asset \"1bc7cf3a01a7153f942391263b3bac937812996cc28f9abaf83ffebbbe03e38b\"" | ||
} | ||
} | ||
} |
Oops, something went wrong.