-
Notifications
You must be signed in to change notification settings - Fork 103
/
HelloWorldKesCmaECSServiceAutoScalingSpec.js
42 lines (37 loc) · 1.63 KB
/
HelloWorldKesCmaECSServiceAutoScalingSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const range = require('lodash.range');
const { sleep } = require('@cumulus/common/util');
const { getEcsClusterService, getEcsServiceEvents } = require('@cumulus/common/ecs');
const { buildAndExecuteWorkflow } = require('@cumulus/integration-tests');
const { loadConfig } = require('../../helpers/testUtils');
const awsConfig = loadConfig();
describe('The Hello World workflow using ECS and kes CMA', () => {
let workflowExecutions = [];
const startTime = new Date();
beforeAll(async () => {
const workflows = range(15).map(() =>
buildAndExecuteWorkflow(
awsConfig.stackName,
awsConfig.bucket,
'EcsKesCMAHelloWorldWorkflow',
null,
null,
{ taskDurationInSecs: 5 }
));
workflowExecutions = await Promise.all(workflows);
});
it('executes successfully', () => {
workflowExecutions.forEach((workflowExecution) => {
expect(workflowExecution.status).toEqual('SUCCEEDED');
});
});
it('performs ECS Service Autoscaling', async () => {
// wait for the event messages
await sleep(180 * 1000);
const { cluster, service } = await getEcsClusterService(awsConfig.stackName, 'EcsTaskHelloWorldKesCma');
console.log('getEcsServiceEvents', cluster, service, startTime);
const serviceEvents = await getEcsServiceEvents(cluster, service, startTime);
expect(serviceEvents.length).toBeGreaterThan(2);
expect(serviceEvents.filter((event) => event.message.includes('has started 1 tasks')).length).toBeGreaterThanOrEqual(1);
expect(serviceEvents.filter((event) => event.message.includes('has stopped 1 running tasks')).length).toBeGreaterThanOrEqual(1);
});
});