@@ -20,7 +20,7 @@ setup() {
2020 " ecs register-task-definition --family hello-world --container-definitions \* : echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
2121 " ecs update-service --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
2222 " ecs wait services-stable --cluster my-cluster --services my-service : echo ok" \
23- " ecs describe-services --cluster my-cluster --services my-service --query 'services[].events' --output text : echo ok"
23+ " ecs describe-services --cluster my-cluster --services my-service --query \* --output text : echo ok"
2424
2525 run " $PWD /hooks/command"
2626
@@ -43,7 +43,7 @@ setup() {
4343 " ecs register-task-definition --family hello-world --container-definitions $'$expected_multiple_container_definition ' : echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
4444 " ecs update-service --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
4545 " ecs wait services-stable --cluster my-cluster --services my-service : echo ok" \
46- " ecs describe-services --cluster my-cluster --services my-service --query 'services[].events' --output text : echo ok"
46+ " ecs describe-services --cluster my-cluster --services my-service --query \* --output text : echo ok"
4747
4848 run " $PWD /hooks/command"
4949
@@ -61,28 +61,27 @@ setup() {
6161 export BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_0=" FOO=bar"
6262 export BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_1=" BAZ=bing"
6363
64-
6564 # first command stubbed saves the container definition to ${TMP_DIR}/container_definition for later review and manipulation
6665 # we should be stubbing a lot more calls, but we don't care about those so let the stubbing fail
6766 stub aws \
6867 " ecs describe-task-definition --task-definition hello-world --query 'taskDefinition' : echo '{}'" \
6968 " ecs register-task-definition --family hello-world --container-definitions \* : echo \"\$ 6\" > ${_TMP_DIR} /container_definition ; echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
7069 " ecs update-service --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
7170 " ecs wait services-stable --cluster my-cluster --services my-service : echo ok" \
72- " ecs describe-services --cluster my-cluster --services my-service --query 'services[].events' --output text : echo ok"
71+ " ecs describe-services --cluster my-cluster --services my-service --query \* --output text : echo ok"
7372
7473 run " $PWD /hooks/command"
7574
7675 assert_success
7776
7877 # check that the definition was updated accordingly
79- assert_equal " $( jq -r ' .[0].environment[0].name' " ${_TMP_DIR} " /container_definition) " ' FOO'
78+ assert_equal " $( jq -r ' .[0].environment[0].name' " ${_TMP_DIR} " /container_definition) " ' FOO'
8079 assert_equal " $( jq -r ' .[0].environment[0].value' " ${_TMP_DIR} " /container_definition) " ' bar'
81- assert_equal " $( jq -r ' .[1].environment[0].name' " ${_TMP_DIR} " /container_definition) " ' FOO'
80+ assert_equal " $( jq -r ' .[1].environment[0].name' " ${_TMP_DIR} " /container_definition) " ' FOO'
8281 assert_equal " $( jq -r ' .[1].environment[0].value' " ${_TMP_DIR} " /container_definition) " ' bar'
83- assert_equal " $( jq -r ' .[0].environment[1].name' " ${_TMP_DIR} " /container_definition) " ' BAZ'
82+ assert_equal " $( jq -r ' .[0].environment[1].name' " ${_TMP_DIR} " /container_definition) " ' BAZ'
8483 assert_equal " $( jq -r ' .[0].environment[1].value' " ${_TMP_DIR} " /container_definition) " ' bing'
85- assert_equal " $( jq -r ' .[1].environment[1].name' " ${_TMP_DIR} " /container_definition) " ' BAZ'
84+ assert_equal " $( jq -r ' .[1].environment[1].name' " ${_TMP_DIR} " /container_definition) " ' BAZ'
8685 assert_equal " $( jq -r ' .[1].environment[1].value' " ${_TMP_DIR} " /container_definition) " ' bing'
8786
8887 unstub aws
@@ -96,7 +95,7 @@ setup() {
9695 " ecs register-task-definition --family hello-world --container-definitions \* --task-role-arn arn:aws:iam::012345678910:role/world : echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
9796 " ecs update-service --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
9897 " ecs wait services-stable --cluster my-cluster --services my-service : echo ok" \
99- " ecs describe-services --cluster my-cluster --services my-service --query 'services[].events' --output text : echo ok"
98+ " ecs describe-services --cluster my-cluster --services my-service --query \* --output text : echo ok"
10099
101100 run " $PWD /hooks/command"
102101
@@ -114,7 +113,7 @@ setup() {
114113 " ecs register-task-definition --family hello-world --container-definitions \* --execution-role-arn arn:aws:iam::012345678910:role/world : echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
115114 " ecs update-service --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
116115 " ecs wait services-stable --cluster my-cluster --services my-service : echo ok" \
117- " ecs describe-services --cluster my-cluster --services my-service --query 'services[].events' --output text : echo ok"
116+ " ecs describe-services --cluster my-cluster --services my-service --query \* --output text : echo ok"
118117
119118 run " $PWD /hooks/command"
120119
@@ -124,7 +123,6 @@ setup() {
124123 unstub aws
125124}
126125
127-
128126@test " Region parameter is applied to all AWS calls" {
129127 export BUILDKITE_PLUGIN_ECS_DEPLOY_REGION=custom-region
130128
@@ -133,7 +131,7 @@ setup() {
133131 " ecs register-task-definition --region custom-region --family hello-world --container-definitions \* : echo '{\" taskDefinition\" :{\" revision\" :1}}'" \
134132 " ecs update-service --region custom-region --cluster my-cluster --service my-service --task-definition hello-world:1 : echo ok" \
135133 " ecs wait services-stable --region custom-region --cluster my-cluster --services my-service : echo ok" \
136- " ecs describe-services --region custom-region --cluster my-cluster --services my-service --query 'services[].events' --output text : echo ok"
134+ " ecs describe-services --region custom-region --cluster my-cluster --services my-service --query \* --output text : echo ok"
137135
138136 run " $PWD /hooks/command"
139137
@@ -142,3 +140,22 @@ setup() {
142140
143141 unstub aws
144142}
143+
144+ @test " Filters past events and sorts them" {
145+ current_date=" 2024-05-04T12:34:56.789000+08:00"
146+ stub date " +'%Y-%m-%dT%H:%M:%S' : echo $current_date "
147+ stub aws \
148+ " ecs describe-task-definition \* \* \* \* : echo '{}'" \
149+ " ecs register-task-definition \* \* \* \* : echo '{}'" \
150+ " ecs update-service \* \* \* \* \* \* : echo ok" \
151+ " ecs wait services-stable \* \* \* \* : echo ok" \
152+ " ecs describe-services \* \* \* \* --query \" services[].events[?createdAt >= '$current_date ']\" --output text : echo '2019-12-12T00:00:01.000Z\tnope\n$current_date \tok'"
153+
154+ run " $PWD /hooks/command"
155+
156+ assert_success
157+ assert_output --partial " ok"
158+
159+ unstub aws
160+ unstub date
161+ }
0 commit comments