Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
gkkachi committed Oct 14, 2022
1 parent 1b16891 commit ab29124
Show file tree
Hide file tree
Showing 10 changed files with 595 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-stepfunctions/package.json
Expand Up @@ -83,6 +83,7 @@
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2"
Expand Down
56 changes: 56 additions & 0 deletions packages/@aws-cdk/aws-stepfunctions/test/integ.intrinsics.ts
@@ -0,0 +1,56 @@
import * as cdk from '@aws-cdk/core';
import * as integ from '@aws-cdk/integ-tests';
import { JsonPath, Pass, StateMachine } from '../lib';

/*
* Stack verification steps:
*
* -- aws stepfunctions describe-state-machine --state-machine-arn <stack-output> has a status of `ACTIVE`
*/
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-stepfunctions-intrinsics-integ');

const pass = new Pass(stack, 'pass', {
parameters: {
array1: JsonPath.array('asdf', JsonPath.stringAt('$.Id')),
arrayPartition1: JsonPath.arrayPartition(JsonPath.listAt('$.inputArray'), 4),
arrayPartition2: JsonPath.arrayPartition(JsonPath.listAt('$.inputArray'), JsonPath.numberAt('$.chunkSize')),
arrayContains1: JsonPath.arrayContains(JsonPath.listAt('$.inputArray'), 5),
arrayContains2: JsonPath.arrayContains(JsonPath.listAt('$.inputArray'), 'a'),
arrayContains3: JsonPath.arrayContains(JsonPath.listAt('$.inputArray'), JsonPath.numberAt('$.lookingFor')),
arrayRange1: JsonPath.arrayRange(1, 9, 2),
arrayRange2: JsonPath.arrayRange(JsonPath.numberAt('$.start'), JsonPath.numberAt('$.end'), JsonPath.numberAt('$.step')),
arrayGetItem1: JsonPath.arrayGetItem(JsonPath.listAt('$.inputArray'), 5),
arrayGetItem2: JsonPath.arrayGetItem(JsonPath.numberAt('$.inputArray'), JsonPath.numberAt('$.index')),
arrayLength1: JsonPath.arrayLength(JsonPath.listAt('$.inputArray')),
arrayUnique1: JsonPath.arrayUnique(JsonPath.listAt('$.inputArray')),
base64Encode1: JsonPath.base64Encode('Data to encode'),
base64Encode2: JsonPath.base64Encode(JsonPath.stringAt('$.input')),
base64Decode1: JsonPath.base64Decode('RGF0YSB0byBlbmNvZGU='),
base64Decode2: JsonPath.base64Decode(JsonPath.stringAt('$.base64')),
hash1: JsonPath.hash('Input data', 'SHA-1'),
hash2: JsonPath.hash(JsonPath.objectAt('$.Data'), JsonPath.stringAt('$.Algorithm')),
jsonMerge1: JsonPath.jsonMerge(JsonPath.objectAt('$.Obj1'), JsonPath.objectAt('$.Obj2')),
mathRandom1: JsonPath.mathRandom(1, 999),
mathRandom2: JsonPath.mathRandom(JsonPath.numberAt('$.start'), JsonPath.numberAt('$.end')),
mathAdd1: JsonPath.mathAdd(1, 999),
mathAdd2: JsonPath.mathAdd(JsonPath.numberAt('$.value1'), JsonPath.numberAt('$.step')),
stringSplit1: JsonPath.stringSplit('1,2,3,4,5', ','),
stringSplit2: JsonPath.stringSplit(JsonPath.stringAt('$.inputString'), JsonPath.stringAt('$.splitter')),
uuid: JsonPath.uuid(),
format1: JsonPath.format('Hi my name is {}.', JsonPath.stringAt('$.Name')),
format2: JsonPath.format(JsonPath.stringAt('$.Format'), JsonPath.stringAt('$.Name')),
stringToJson1: JsonPath.stringToJson(JsonPath.stringAt('$.Str')),
jsonToString1: JsonPath.jsonToString(JsonPath.objectAt('$.Obj')),
},
});

new StateMachine(stack, 'StateMachine', {
definition: pass,
});

new integ.IntegTest(app, 'StateMachineIntrinsicsTest', {
testCases: [stack],
});

app.synth();
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "StateMachineIntrinsicsTestDefaultTestDeployAssert1C1E1D7E.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
@@ -0,0 +1,36 @@
{
"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."
}
]
}
}
}
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"0969ff045f30d2fff3d0ee8d260f6d4ba27b98431560c1601d96fa47a574bd1b": {
"source": {
"path": "aws-stepfunctions-intrinsics-integ.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "0969ff045f30d2fff3d0ee8d260f6d4ba27b98431560c1601d96fa47a574bd1b.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
@@ -0,0 +1,172 @@
{
"Resources": {
"StateMachineRoleB840431D": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": {
"Fn::FindInMap": [
"ServiceprincipalMap",
{
"Ref": "AWS::Region"
},
"states"
]
}
}
}
],
"Version": "2012-10-17"
}
}
},
"StateMachine2E01A3A5": {
"Type": "AWS::StepFunctions::StateMachine",
"Properties": {
"RoleArn": {
"Fn::GetAtt": [
"StateMachineRoleB840431D",
"Arn"
]
},
"DefinitionString": "{\"StartAt\":\"pass\",\"States\":{\"pass\":{\"Type\":\"Pass\",\"Parameters\":{\"array1.$\":\"States.Array('asdf', $.Id)\",\"arrayPartition1.$\":\"States.ArrayPartition($.inputArray, 4)\",\"arrayPartition2.$\":\"States.ArrayPartition($.inputArray, $.chunkSize)\",\"arrayContains1.$\":\"States.ArrayContains($.inputArray, 5)\",\"arrayContains2.$\":\"States.ArrayContains($.inputArray, 'a')\",\"arrayContains3.$\":\"States.ArrayContains($.inputArray, $.lookingFor)\",\"arrayRange1.$\":\"States.ArrayRange(1, 9, 2)\",\"arrayRange2.$\":\"States.ArrayRange($.start, $.end, $.step)\",\"arrayGetItem1.$\":\"States.ArrayGetItem($.inputArray, 5)\",\"arrayGetItem2.$\":\"States.ArrayGetItem($.inputArray, $.index)\",\"arrayLength1.$\":\"States.ArrayLength($.inputArray)\",\"arrayUnique1.$\":\"States.ArrayUnique($.inputArray)\",\"base64Encode1.$\":\"States.Base64Encode('Data to encode')\",\"base64Encode2.$\":\"States.Base64Encode($.input)\",\"base64Decode1.$\":\"States.Base64Decode('RGF0YSB0byBlbmNvZGU=')\",\"base64Decode2.$\":\"States.Base64Decode($.base64)\",\"hash1.$\":\"States.Hash('Input data', 'SHA-1')\",\"hash2.$\":\"States.Hash($.Data, $.Algorithm)\",\"jsonMerge1.$\":\"States.JsonMerge($.Obj1, $.Obj2, false)\",\"mathRandom1.$\":\"States.MathRandom(1, 999)\",\"mathRandom2.$\":\"States.MathRandom($.start, $.end)\",\"mathAdd1.$\":\"States.MathAdd(1, 999)\",\"mathAdd2.$\":\"States.MathAdd($.value1, $.step)\",\"stringSplit1.$\":\"States.StringSplit('1,2,3,4,5', ',')\",\"stringSplit2.$\":\"States.StringSplit($.inputString, $.splitter)\",\"uuid.$\":\"States.UUID()\",\"format1.$\":\"States.Format('Hi my name is {}.', $.Name)\",\"format2.$\":\"States.Format($.Format, $.Name)\",\"stringToJson1.$\":\"States.StringToJson($.Str)\",\"jsonToString1.$\":\"States.JsonToString($.Obj)\"},\"End\":true}}}"
},
"DependsOn": [
"StateMachineRoleB840431D"
]
}
},
"Mappings": {
"ServiceprincipalMap": {
"af-south-1": {
"states": "states.af-south-1.amazonaws.com"
},
"ap-east-1": {
"states": "states.ap-east-1.amazonaws.com"
},
"ap-northeast-1": {
"states": "states.ap-northeast-1.amazonaws.com"
},
"ap-northeast-2": {
"states": "states.ap-northeast-2.amazonaws.com"
},
"ap-northeast-3": {
"states": "states.ap-northeast-3.amazonaws.com"
},
"ap-south-1": {
"states": "states.ap-south-1.amazonaws.com"
},
"ap-southeast-1": {
"states": "states.ap-southeast-1.amazonaws.com"
},
"ap-southeast-2": {
"states": "states.ap-southeast-2.amazonaws.com"
},
"ap-southeast-3": {
"states": "states.ap-southeast-3.amazonaws.com"
},
"ca-central-1": {
"states": "states.ca-central-1.amazonaws.com"
},
"cn-north-1": {
"states": "states.cn-north-1.amazonaws.com"
},
"cn-northwest-1": {
"states": "states.cn-northwest-1.amazonaws.com"
},
"eu-central-1": {
"states": "states.eu-central-1.amazonaws.com"
},
"eu-north-1": {
"states": "states.eu-north-1.amazonaws.com"
},
"eu-south-1": {
"states": "states.eu-south-1.amazonaws.com"
},
"eu-south-2": {
"states": "states.eu-south-2.amazonaws.com"
},
"eu-west-1": {
"states": "states.eu-west-1.amazonaws.com"
},
"eu-west-2": {
"states": "states.eu-west-2.amazonaws.com"
},
"eu-west-3": {
"states": "states.eu-west-3.amazonaws.com"
},
"me-south-1": {
"states": "states.me-south-1.amazonaws.com"
},
"sa-east-1": {
"states": "states.sa-east-1.amazonaws.com"
},
"us-east-1": {
"states": "states.us-east-1.amazonaws.com"
},
"us-east-2": {
"states": "states.us-east-2.amazonaws.com"
},
"us-gov-east-1": {
"states": "states.us-gov-east-1.amazonaws.com"
},
"us-gov-west-1": {
"states": "states.us-gov-west-1.amazonaws.com"
},
"us-iso-east-1": {
"states": "states.amazonaws.com"
},
"us-iso-west-1": {
"states": "states.amazonaws.com"
},
"us-isob-east-1": {
"states": "states.amazonaws.com"
},
"us-west-1": {
"states": "states.us-west-1.amazonaws.com"
},
"us-west-2": {
"states": "states.us-west-2.amazonaws.com"
}
}
},
"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."
}
]
}
}
}
@@ -0,0 +1 @@
{"version":"21.0.0"}
@@ -0,0 +1,12 @@
{
"version": "21.0.0",
"testCases": {
"StateMachineIntrinsicsTest/DefaultTest": {
"stacks": [
"aws-stepfunctions-intrinsics-integ"
],
"assertionStack": "StateMachineIntrinsicsTest/DefaultTest/DeployAssert",
"assertionStackName": "StateMachineIntrinsicsTestDefaultTestDeployAssert1C1E1D7E"
}
}
}

0 comments on commit ab29124

Please sign in to comment.