Skip to content

Commit 5ea37fc

Browse files
committed
feat(integ-runner): example language integ tests should do something
1 parent 2d97189 commit 5ea37fc

22 files changed

+2743
-219
lines changed
Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
1-
import { App, Stack } from '@aws-cdk/core';
2-
import { IntegTest } from '@aws-cdk/integ-tests';
1+
/**
2+
* This test cannot use service modules since it would introduce a circular dependency
3+
* Using CfnResource etc. is a workaround to still test something useful
4+
*/
5+
import * as cdk from "@aws-cdk/core";
6+
import { ExpectedResult, IntegTest } from "@aws-cdk/integ-tests";
37

4-
const app = new App();
5-
const stack = new Stack(app);
8+
const app = new cdk.App();
69

7-
new IntegTest(app, 'Integ', { testCases: [stack] });
10+
const stack = new cdk.Stack(app, "TypeScriptStack");
11+
const queue = new cdk.CfnResource(stack, "Queue", {
12+
type: "AWS::SQS::Queue",
13+
properties: {
14+
FifoQueue: true
15+
}
16+
});
17+
18+
const assertionStack = new cdk.Stack(app, "TypeScriptAssertions");
19+
assertionStack.addDependency(stack);
20+
21+
const integ = new IntegTest(app, "TypeScript", {
22+
testCases: [stack],
23+
assertionStack,
24+
});
25+
26+
integ.assertions
27+
.awsApiCall("SQS", "getQueueAttributes", {
28+
QueueUrl: stack.exportValue(queue.getAtt("QueueUrl", cdk.ResolutionTypeHint.STRING)),
29+
AttributeNames: ["QueueArn"],
30+
})
31+
.assertAtPath(
32+
"Attributes.QueueArn",
33+
ExpectedResult.stringLikeRegexp(".*\\.fifo$")
34+
);
835

936
app.synth();

packages/@aws-cdk/integ-runner/test/language-tests/integ.typescript-test.ts.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/@aws-cdk/integ-runner/test/language-tests/integ.typescript-test.ts.snapshot/IntegDefaultTestDeployAssert4E6713E1.template.json

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "22.0.0",
3+
"files": {
4+
"278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4": {
5+
"source": {
6+
"path": "asset.278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4.bundle",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"bb131995f97d3bf2ccde6c8fd8d88a6b780ae97a9348985f50b9207d5e341b5c": {
18+
"source": {
19+
"path": "TypeScriptAssertions.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "bb131995f97d3bf2ccde6c8fd8d88a6b780ae97a9348985f50b9207d5e341b5c.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: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"Resources": {
3+
"AwsApiCallSQSgetQueueAttributes": {
4+
"Type": "Custom::DeployAssert@SdkCallSQSgetQueueAttributes",
5+
"Properties": {
6+
"ServiceToken": {
7+
"Fn::GetAtt": [
8+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F",
9+
"Arn"
10+
]
11+
},
12+
"service": "SQS",
13+
"api": "getQueueAttributes",
14+
"expected": "{\"$StringLike\":\".*\\\\.fifo$\"}",
15+
"actualPath": "Attributes.QueueArn",
16+
"parameters": {
17+
"QueueUrl": {
18+
"Fn::ImportValue": "TypeScriptStack:ExportsOutputFnGetAttQueueQueueUrlA8D516BA"
19+
},
20+
"AttributeNames": [
21+
"QueueArn"
22+
]
23+
},
24+
"flattenResponse": "true",
25+
"outputPaths": [
26+
"Attributes.QueueArn"
27+
],
28+
"salt": "1672941547549"
29+
},
30+
"UpdateReplacePolicy": "Delete",
31+
"DeletionPolicy": "Delete"
32+
},
33+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": {
34+
"Type": "AWS::IAM::Role",
35+
"Properties": {
36+
"AssumeRolePolicyDocument": {
37+
"Version": "2012-10-17",
38+
"Statement": [
39+
{
40+
"Action": "sts:AssumeRole",
41+
"Effect": "Allow",
42+
"Principal": {
43+
"Service": "lambda.amazonaws.com"
44+
}
45+
}
46+
]
47+
},
48+
"ManagedPolicyArns": [
49+
{
50+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
51+
}
52+
],
53+
"Policies": [
54+
{
55+
"PolicyName": "Inline",
56+
"PolicyDocument": {
57+
"Version": "2012-10-17",
58+
"Statement": [
59+
{
60+
"Action": [
61+
"sqs:GetQueueAttributes"
62+
],
63+
"Effect": "Allow",
64+
"Resource": [
65+
"*"
66+
]
67+
}
68+
]
69+
}
70+
}
71+
]
72+
}
73+
},
74+
"SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": {
75+
"Type": "AWS::Lambda::Function",
76+
"Properties": {
77+
"Runtime": "nodejs14.x",
78+
"Code": {
79+
"S3Bucket": {
80+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
81+
},
82+
"S3Key": "278d42fa865f60954d898636503d0ee86a6689d73dc50eb912fac62def0ef6a4.zip"
83+
},
84+
"Timeout": 120,
85+
"Handler": "index.handler",
86+
"Role": {
87+
"Fn::GetAtt": [
88+
"SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73",
89+
"Arn"
90+
]
91+
}
92+
}
93+
}
94+
},
95+
"Outputs": {
96+
"AssertionResultsAwsApiCallSQSgetQueueAttributes": {
97+
"Value": {
98+
"Fn::GetAtt": [
99+
"AwsApiCallSQSgetQueueAttributes",
100+
"assertion"
101+
]
102+
}
103+
}
104+
},
105+
"Parameters": {
106+
"BootstrapVersion": {
107+
"Type": "AWS::SSM::Parameter::Value<String>",
108+
"Default": "/cdk-bootstrap/hnb659fds/version",
109+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
110+
}
111+
},
112+
"Rules": {
113+
"CheckBootstrapVersion": {
114+
"Assertions": [
115+
{
116+
"Assert": {
117+
"Fn::Not": [
118+
{
119+
"Fn::Contains": [
120+
[
121+
"1",
122+
"2",
123+
"3",
124+
"4",
125+
"5"
126+
],
127+
{
128+
"Ref": "BootstrapVersion"
129+
}
130+
]
131+
}
132+
]
133+
},
134+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
135+
}
136+
]
137+
}
138+
}
139+
}

packages/@aws-cdk/integ-runner/test/language-tests/integ_python-test.py.snapshot/Default.assets.json renamed to packages/@aws-cdk/integ-runner/test/language-tests/integ.typescript-test.ts.snapshot/TypeScriptStack.assets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "22.0.0",
33
"files": {
4-
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
4+
"a28a0c4ed7dfaee5dec40a71393fffa16401094a480e0340d4713a9bb0677c36": {
55
"source": {
6-
"path": "Default.template.json",
6+
"path": "TypeScriptStack.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
12+
"objectKey": "a28a0c4ed7dfaee5dec40a71393fffa16401094a480e0340d4713a9bb0677c36.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/integ-runner/test/language-tests/integ_python-test.py.snapshot/Default.template.json renamed to packages/@aws-cdk/integ-runner/test/language-tests/integ.typescript-test.ts.snapshot/TypeScriptStack.template.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
{
2+
"Resources": {
3+
"Queue": {
4+
"Type": "AWS::SQS::Queue",
5+
"Properties": {
6+
"FifoQueue": true
7+
}
8+
}
9+
},
10+
"Outputs": {
11+
"ExportsOutputFnGetAttQueueQueueUrlA8D516BA": {
12+
"Value": {
13+
"Fn::GetAtt": [
14+
"Queue",
15+
"QueueUrl"
16+
]
17+
},
18+
"Export": {
19+
"Name": "TypeScriptStack:ExportsOutputFnGetAttQueueQueueUrlA8D516BA"
20+
}
21+
}
22+
},
223
"Parameters": {
324
"BootstrapVersion": {
425
"Type": "AWS::SSM::Parameter::Value<String>",

0 commit comments

Comments
 (0)