@@ -15,7 +15,7 @@ load '/usr/local/lib/bats/load.bash'
1515 export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION=examples/hello-world.json
1616
1717 stub jq \
18- " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' examples/hello-world.json : echo '{\" json\" :true}'" \
18+ " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' : echo '{\" json\" :true}'" \
1919 " '.taskDefinition.revision' : echo 1" \
2020 " -r '.[0].loadBalancers[0]' : echo null"
2121
@@ -38,7 +38,43 @@ load '/usr/local/lib/bats/load.bash'
3838 unset BUILDKITE_PLUGIN_ECS_DEPLOY_SERVICE
3939 unset BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION
4040 unset BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE
41+ }
42+
43+ @test " Run a deploy with multiple images" {
44+ export BUILDKITE_BUILD_NUMBER=1
45+ export BUILDKITE_PLUGIN_ECS_DEPLOY_CLUSTER=my-cluster
46+ export BUILDKITE_PLUGIN_ECS_DEPLOY_SERVICE=my-service
47+ export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_FAMILY=hello-world
48+ export BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_0=hello-world:llamas
49+ export BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_1=hello-world:alpacas
50+ export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION=examples/multiple-images.json
51+
52+ stub jq \
53+ " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' : echo '[{\" image\" :\" hello-world:llamas\" },{\" image\" :\" replaceme\" }]'" \
54+ " --arg IMAGE hello-world:alpacas '.[1].image=\$ IMAGE' : echo '[{\" image\" :\" hello-world:llamas\" },{\" image\" :\" hello-world:alpacas\" }]'" \
55+ " '.taskDefinition.revision' : echo 1" \
56+ " -r '.[0].loadBalancers[0]' : echo null"
57+
58+ stub aws \
59+ " ecs register-task-definition --family hello-world --container-definitions '[{\" image\" :\" hello-world:llamas\" },{\" image\" :\" hello-world:alpacas\" }]' : echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
60+ " ecs describe-services --cluster my-cluster --service my-service --query 'services[?status==\` ACTIVE\` ].status' --output text : echo '1'" \
61+ " ecs describe-services --cluster my-cluster --services my-service --query 'services[?status==\` ACTIVE\` ]' : echo 'null'" \
62+ " ecs update-service --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
63+ " ecs wait services-stable --cluster my-cluster --services my-service : echo ok" \
64+ " ecs describe-services --cluster my-cluster --service my-service : echo ok"
65+
66+ run " $PWD /hooks/command"
67+
68+ assert_success
69+ assert_output --partial " Service is up 🚀"
70+
71+ unstub aws
72+ unstub jq
73+ unset BUILDKITE_PLUGIN_ECS_DEPLOY_CLUSTER
74+ unset BUILDKITE_PLUGIN_ECS_DEPLOY_SERVICE
4175 unset BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION
76+ unset BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_0
77+ unset BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_1
4278}
4379
4480@test " Run a deploy when service does not exist" {
@@ -50,7 +86,7 @@ load '/usr/local/lib/bats/load.bash'
5086 export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION=examples/hello-world.json
5187
5288 stub jq \
53- " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' examples/hello-world.json : echo '{\" json\" :true}'" \
89+ " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' : echo '{\" json\" :true}'" \
5490 " '.taskDefinition.revision' : echo 1" \
5591 " -r '.[0].loadBalancers[0]' : echo null"
5692
@@ -87,7 +123,7 @@ load '/usr/local/lib/bats/load.bash'
87123 export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_ROLE_ARN=arn:aws:iam::012345678910:role/world
88124
89125 stub jq \
90- " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' examples/hello-world.json : echo '{\" json\" :true}'" \
126+ " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' : echo '{\" json\" :true}'" \
91127 " '.taskDefinition.revision' : echo 1" \
92128 " -r '.[0].loadBalancers[0]' : echo null"
93129
@@ -125,7 +161,7 @@ load '/usr/local/lib/bats/load.bash'
125161 export BUILDKITE_PLUGIN_ECS_DEPLOY_TARGET_CONTAINER_PORT=80
126162
127163 stub jq \
128- " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' examples/hello-world.json : echo '{\" json\" :true}'" \
164+ " --arg IMAGE hello-world:llamas '.[0].image=\$ IMAGE' : echo '{\" json\" :true}'" \
129165 " '.taskDefinition.revision' : echo 1" \
130166 " -r '.[0].loadBalancers[0]' : echo alb" \
131167 " -r .containerName : echo nginx" \
0 commit comments