-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coverage/integ test & refactor using EKS L2 Construct
- Loading branch information
Showing
7 changed files
with
1,691 additions
and
79 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
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
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
135 changes: 92 additions & 43 deletions
135
packages/@aws-cdk/aws-stepfunctions-tasks/test/eks/call.test.ts
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 |
---|---|---|
@@ -1,54 +1,103 @@ | ||
import * as eks from '@aws-cdk/aws-eks'; | ||
import * as sfn from '@aws-cdk/aws-stepfunctions'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import { EksCall, MethodType } from '../../lib/eks/call'; | ||
import { Stack } from '@aws-cdk/core'; | ||
import { EksCall, HttpMethods } from '../../lib/eks/call'; | ||
|
||
describe('Call an EKS endpoint', () => { | ||
let stack: Stack; | ||
let cluster: eks.Cluster; | ||
|
||
test('default settings', () => { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
beforeEach(() => { | ||
//GIVEN | ||
stack = new Stack(); | ||
cluster = new eks.Cluster(stack, 'Cluster', { | ||
version: eks.KubernetesVersion.V1_18, | ||
clusterName: 'eksCluster', | ||
}); | ||
}); | ||
|
||
// WHEN | ||
const task = new EksCall(stack, 'Call', { | ||
clusterName: 'clusterName', | ||
certificateAuthority: 'certificateAuthority', | ||
endpoint: 'endpoint', | ||
httpMethod: MethodType.GET, | ||
path: 'path', | ||
requestBody: sfn.TaskInput.fromObject({ | ||
RequestBody: 'requestBody', | ||
}), | ||
}); | ||
test('Call an EKS endpoint', () => { | ||
// WHEN | ||
const task = new EksCall(stack, 'Call', { | ||
cluster: cluster, | ||
httpMethod: HttpMethods.GET, | ||
httpPath: 'path', | ||
requestBody: sfn.TaskInput.fromObject({ | ||
RequestBody: 'requestBody', | ||
}), | ||
}); | ||
|
||
// THEN | ||
expect(stack.resolve(task.toStateJson())).toEqual({ | ||
Type: 'Task', | ||
Resource: { | ||
'Fn::Join': [ | ||
'', | ||
[ | ||
'arn:', | ||
{ | ||
Ref: 'AWS::Partition', | ||
}, | ||
':states:::eks:call', | ||
], | ||
// THEN | ||
expect(stack.resolve(task.toStateJson())).toEqual({ | ||
Type: 'Task', | ||
Resource: { | ||
'Fn::Join': [ | ||
'', | ||
[ | ||
'arn:', | ||
{ | ||
Ref: 'AWS::Partition', | ||
}, | ||
':states:::eks:call', | ||
], | ||
], | ||
}, | ||
End: true, | ||
Parameters: { | ||
ClusterName: { | ||
Ref: 'Cluster9EE0221C', | ||
}, | ||
End: true, | ||
Parameters: { | ||
ClusterName: 'clusterName', | ||
CertificateAuthority: 'certificateAuthority', | ||
Endpoint: 'endpoint', | ||
Method: 'GET', | ||
Path: 'path', | ||
RequestBody: { | ||
type: 1, | ||
value: { | ||
RequestBody: 'requestBody', | ||
}, | ||
CertificateAuthority: { | ||
'Fn::GetAtt': [ | ||
'Cluster9EE0221C', | ||
'CertificateAuthorityData', | ||
], | ||
}, | ||
Endpoint: { | ||
'Fn::GetAtt': [ | ||
'Cluster9EE0221C', | ||
'Endpoint', | ||
], | ||
}, | ||
Method: 'GET', | ||
Path: 'path', | ||
RequestBody: { | ||
type: 1, | ||
value: { | ||
RequestBody: 'requestBody', | ||
}, | ||
}, | ||
}); | ||
}, | ||
}); | ||
}); | ||
|
||
test('Task throws if RUN_JOB is supplied as service integration pattern', () => { | ||
expect(() => { | ||
new EksCall(stack, 'Call', { | ||
cluster: cluster, | ||
httpMethod: HttpMethods.GET, | ||
httpPath: 'path', | ||
requestBody: sfn.TaskInput.fromObject({ | ||
RequestBody: 'requestBody', | ||
}), | ||
integrationPattern: sfn.IntegrationPattern.RUN_JOB, | ||
}); | ||
}).toThrow( | ||
/Unsupported service integration pattern. Supported Patterns: REQUEST_RESPONSE. Received: RUN_JOB/, | ||
); | ||
}); | ||
|
||
test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration pattern', () => { | ||
expect(() => { | ||
new EksCall(stack, 'Call', { | ||
cluster: cluster, | ||
httpMethod: HttpMethods.GET, | ||
httpPath: 'path', | ||
requestBody: sfn.TaskInput.fromObject({ | ||
RequestBody: 'requestBody', | ||
}), | ||
integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN, | ||
}); | ||
}).toThrow( | ||
/Unsupported service integration pattern. Supported Patterns: REQUEST_RESPONSE. Received: WAIT_FOR_TASK_TOKEN/, | ||
); | ||
}); |
Oops, something went wrong.