Skip to content

Commit

Permalink
feat(integ-runner): example language integ tests should do something
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Jan 5, 2023
1 parent 2d97189 commit 5ea37fc
Show file tree
Hide file tree
Showing 22 changed files with 2,743 additions and 219 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
import { App, Stack } from '@aws-cdk/core';
import { IntegTest } from '@aws-cdk/integ-tests';
/**
* This test cannot use service modules since it would introduce a circular dependency
* Using CfnResource etc. is a workaround to still test something useful
*/
import * as cdk from "@aws-cdk/core";
import { ExpectedResult, IntegTest } from "@aws-cdk/integ-tests";

const app = new App();
const stack = new Stack(app);
const app = new cdk.App();

new IntegTest(app, 'Integ', { testCases: [stack] });
const stack = new cdk.Stack(app, "TypeScriptStack");
const queue = new cdk.CfnResource(stack, "Queue", {
type: "AWS::SQS::Queue",
properties: {
FifoQueue: true
}
});

const assertionStack = new cdk.Stack(app, "TypeScriptAssertions");
assertionStack.addDependency(stack);

const integ = new IntegTest(app, "TypeScript", {
testCases: [stack],
assertionStack,
});

integ.assertions
.awsApiCall("SQS", "getQueueAttributes", {
QueueUrl: stack.exportValue(queue.getAtt("QueueUrl", cdk.ResolutionTypeHint.STRING)),
AttributeNames: ["QueueArn"],
})
.assertAtPath(
"Attributes.QueueArn",
ExpectedResult.stringLikeRegexp(".*\\.fifo$")
);

app.synth();

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": "22.0.0",
"files": {
"278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4": {
"source": {
"path": "asset.278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"bb131995f97d3bf2ccde6c8fd8d88a6b780ae97a9348985f50b9207d5e341b5c": {
"source": {
"path": "TypeScriptAssertions.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "bb131995f97d3bf2ccde6c8fd8d88a6b780ae97a9348985f50b9207d5e341b5c.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"Resources": {
"AwsApiCallSQSgetQueueAttributes": {
"Type": "Custom::DeployAssert@SdkCallSQSgetQueueAttributes",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F",
"Arn"
]
},
"service": "SQS",
"api": "getQueueAttributes",
"expected": "{\"$StringLike\":\".*\\\\.fifo$\"}",
"actualPath": "Attributes.QueueArn",
"parameters": {
"QueueUrl": {
"Fn::ImportValue": "TypeScriptStack:ExportsOutputFnGetAttQueueQueueUrlA8D516BA"
},
"AttributeNames": [
"QueueArn"
]
},
"flattenResponse": "true",
"outputPaths": [
"Attributes.QueueArn"
],
"salt": "1672941547549"
},
"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": [
"sqs:GetQueueAttributes"
],
"Effect": "Allow",
"Resource": [
"*"
]
}
]
}
}
]
}
},
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Runtime": "nodejs14.x",
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4.zip"
},
"Timeout": 120,
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
"Arn"
]
}
}
}
},
"Outputs": {
"AssertionResultsAwsApiCallSQSgetQueueAttributes": {
"Value": {
"Fn::GetAtt": [
"AwsApiCallSQSgetQueueAttributes",
"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."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "22.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"a28a0c4ed7dfaee5dec40a71393fffa16401094a480e0340d4713a9bb0677c36": {
"source": {
"path": "Default.template.json",
"path": "TypeScriptStack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"objectKey": "a28a0c4ed7dfaee5dec40a71393fffa16401094a480e0340d4713a9bb0677c36.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
{
"Resources": {
"Queue": {
"Type": "AWS::SQS::Queue",
"Properties": {
"FifoQueue": true
}
}
},
"Outputs": {
"ExportsOutputFnGetAttQueueQueueUrlA8D516BA": {
"Value": {
"Fn::GetAtt": [
"Queue",
"QueueUrl"
]
},
"Export": {
"Name": "TypeScriptStack:ExportsOutputFnGetAttQueueQueueUrlA8D516BA"
}
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
Expand Down
Loading

0 comments on commit 5ea37fc

Please sign in to comment.