Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Conversation

@efekarakus
Copy link
Contributor

Description of changes: Add integration tests that follow our EC2 tutorial (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-ec2.html)


Testing

  • Unit tests passed
  • Integration tests passed
  • [N/A] Unit tests added for new functionality
  • Listed manual checks and their outputs in the comments (example)
  • [N/A] Link to issue or PR for the integration tests:

Documentation

  • [N/A] Contacted our doc writer
  • [N/A] Updated our README

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@efekarakus
Copy link
Contributor Author

efekarakus commented Apr 30, 2019

Output from CodeBuild:

[Container] 2019/04/30 17:50:48 Running command make integ-test 
Building ecs-cli... 
./scripts/build_binary.sh ./bin/local 
Running integration tests... 
go test -timeout 60m -tags integ -v ./ecs-cli/integ/e2e/... 
=== RUN   TestCreateClusterWithEC2Task 
=== PAUSE TestCreateClusterWithEC2Task 
=== RUN   TestCreateClusterWithFargateService 
=== PAUSE TestCreateClusterWithFargateService 
=== CONT  TestCreateClusterWithEC2Task 
=== CONT  TestCreateClusterWithFargateService 
--- PASS: TestCreateClusterWithFargateService (350.20s) 
    configure.go:42: Created config ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-fargate-tutorial-config 
    up.go:62: Created cluster ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-fargate-tutorial-cluster in stack amazon-ecs-cli-setup-ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-fargate-tutorial-cluster 
    fargate_service_test.go:84: Created /tmp/docker-compose-215676693.yml successfully 
    fargate_service_test.go:115: Created /tmp/ecs-params-333451120.yml successfully 
    compose.go:102: Created service with name e2e-fargate-test-service 
    compose.go:113: Project e2e-fargate-test-service has 1 running containers 
    compose.go:173: Scaled the service e2e-fargate-test-service to 2 tasks 
    compose.go:113: Project e2e-fargate-test-service has 2 running containers 
    compose.go:232: Deleted service e2e-fargate-test-service 
    cfn.go:50: Success: stack amazon-ecs-cli-setup-ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-fargate-tutorial-cluster does not exist 
    down.go:49: Deleted stack amazon-ecs-cli-setup-ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-fargate-tutorial-cluster 
--- PASS: TestCreateClusterWithEC2Task (563.52s) 
    configure.go:53: Created config ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-config 
    up.go:62: Created cluster ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster in stack amazon-ecs-cli-setup-ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster 
    ecs.go:43: Number of container instances mismatch, wanted = 2, got = 0 
    runner.go:70: Current timestamp=2019-04-30 17:54:43.71596758 +0000 UTC m=+182.094703973, sleeping for 15s 
    ecs.go:43: Number of container instances mismatch, wanted = 2, got = 0 
    runner.go:70: Current timestamp=2019-04-30 17:54:58.778706044 +0000 UTC m=+197.157442373, sleeping for 15s 
    ecs.go:43: Number of container instances mismatch, wanted = 2, got = 0 
    runner.go:70: Current timestamp=2019-04-30 17:55:13.804915269 +0000 UTC m=+212.183651669, sleeping for 15s 
    ecs.go:43: Number of container instances mismatch, wanted = 2, got = 1 
    runner.go:70: Current timestamp=2019-04-30 17:55:28.827058636 +0000 UTC m=+227.205795149, sleeping for 15s 
    ecs.go:51: Cluster ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster has 2 instances 
    ec2_task_test.go:94: Created /tmp/docker-compose-784761359.yml successfully 
    ec2_task_test.go:118: Created /tmp/ecs-params-949991970.yml successfully 
    compose.go:71: Created containers for e2e-ec2-tutorial-taskdef 
    ecs.go:75: Cluster ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster has 1 tasks 
    ps.go:34: Project e2e-ec2-tutorial-taskdef has 2 running containers 
    compose.go:141: Scaled the task e2e-ec2-tutorial-taskdef to 2 
    ecs.go:75: Cluster ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster has 2 tasks 
    ps.go:34: Project e2e-ec2-tutorial-taskdef has 4 running containers 
    compose.go:200: Deleted task e2e-ec2-tutorial-taskdef 
    ecs.go:75: Cluster ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster has 0 tasks 
    cfn.go:50: Success: stack amazon-ecs-cli-setup-ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster does not exist 
    down.go:49: Deleted stack amazon-ecs-cli-setup-ecs-cli-canary-d8f2192e-512f-417a-afff-7a5260b8ac8c-ec2-tutorial-cluster 
PASS 
ok      github.com/aws/amazon-ecs-cli/ecs-cli/integ/e2e 563.520s 
 
[Container] 2019/04/30 18:01:05 Running command ./bin/local/ecs-cli --version 
ecs-cli version 1.14.1 (*4d566d8) 


// Then
stdout.Stdout(out).TestHasAllSubstrings(t, []string{
"Started container",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was an easy way to guarantee that the right number of tasks are running.

I think this is fine for now though.

Copy link
Contributor

@PettitWesley PettitWesley Apr 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is done using ps in the actual integ test 👍🏻

// Increase the number of running tasks
cmd.TestTaskScale(t, project, 2)
ecs.TestListTasks(t, conf.ClusterName, 2)
cmd.TestPsRunning(t, project, 4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numbers here confuse me... after TestTaskUp, why are 2 containers expected in PS?

And after scaling to 2 tasks, why are 4 containers expected in PS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can totally understand the confusion.
If you look at the compose file, we have two containers listed out. So that 1 task with two containers. When we scale the number of tasks to 2, then we end up with 4 running containers in the cluster.

I'll add comments explaining this in the integ test.


// TestListTasks validates that a cluster has the expected number of
// tasks by periodically querying against ECS.
func TestListTasks(t *testing.T, clusterName string, wantedSize int) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

./scripts/build_binary.sh ./bin/local
@echo "Running integration tests..."
go test -tags integ -v ./ecs-cli/integ/e2e/...
go test -timeout 60m -tags integ -v ./ecs-cli/integ/e2e/...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious: do we know how long these tests are taking to run on average? wondering if we can track length of test runs in CloudWatch so we can keep an eye on things as we add more tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After making the tests run in parallel, it came down to ~11 mins from ~17mins.

The default go test timeout is 10m, that's why i had to override that value. I picked 60m to be consistent with the codebuild timeout.


func createEC2TutorialComposeFile(t *testing.T) string {
content := `
version: '3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about using version: 2 compose for this test? We support both but parsing takes diff code paths, so using v2 here and keeping v3 in the Fargate test would increase total line coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, updated!

@efekarakus efekarakus merged commit f4cc7e4 into aws:dev May 2, 2019
@efekarakus efekarakus deleted the integ-tests/ec2-task branch June 19, 2019 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants