Skip to content

Commit 2111bb4

Browse files
committed
add tests for success/failure on docker pull retries
1 parent f2bc4ac commit 2111bb4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/command.bats

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,42 @@ setup() {
6666
unstub docker
6767
}
6868

69+
@test "Pull image first before running BUILDKITE_COMMAND, success on retries" {
70+
export BUILDKITE_PLUGIN_DOCKER_ALWAYS_PULL=true
71+
export BUILDKITE_PLUGIN_DOCKER_PULL_RETRIES=2
72+
73+
stub docker \
74+
"pull image:tag" \
75+
"pull image:tag : echo pulled latest image on retry" \
76+
"run -t -i --rm --init --volume $PWD:/workdir --workdir /workdir --label com.buildkite.job-id=1-2-3-4 image:tag /bin/sh -e -c 'pwd' : echo ran command in docker"
77+
78+
run "$PWD"/hooks/command
79+
80+
assert_success
81+
assert_output --partial "Retrying 1 more times..."
82+
assert_output --partial "pulled latest image on retry"
83+
assert_output --partial "ran command in docker"
84+
85+
unstub docker
86+
}
87+
88+
@test "Pull image first before running BUILDKITE_COMMAND, failure on retries" {
89+
export BUILDKITE_PLUGIN_DOCKER_ALWAYS_PULL=true
90+
export BUILDKITE_PLUGIN_DOCKER_PULL_RETRIES=2
91+
92+
stub docker \
93+
"pull image:tag" \
94+
"pull image:tag"
95+
96+
run "$PWD"/hooks/command
97+
98+
assert_failure
99+
assert_output --partial "Retrying 1 more times..."
100+
assert_output --partial "!!! :docker: Pull failed."
101+
102+
unstub docker
103+
}
104+
69105
@test "Runs BUILDKITE_COMMAND with mount-buildkite-agent disabled specifically" {
70106
export BUILDKITE_PLUGIN_DOCKER_MOUNT_BUILDKITE_AGENT=false
71107
export BUILDKITE_COMMAND="pwd"

0 commit comments

Comments
 (0)