Skip to content

Commit 01aaeef

Browse files
committed
fix test
1 parent 8984909 commit 01aaeef

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

integration/integration_test.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -1970,18 +1970,27 @@ RUN date --utc > /root/date.txt`, testImageAlpine),
19701970
envbuilderEnv("GIT_URL", srv.URL),
19711971
envbuilderEnv("CACHE_REPO", notRegURL),
19721972
envbuilderEnv("PUSH_IMAGE", "1"),
1973-
envbuilderEnv("INIT_SCRIPT", "exit \\${ENVBUILDER_EXIT_CODE:-254}"),
1973+
envbuilderEnv("INIT_SCRIPT", `exit ${ENVBUILDER_EXIT_CODE:-254}`),
19741974
}})
19751975
require.NoError(t, err)
19761976

19771977
// Then: envbuilder should fail with a descriptive status code.
19781978
client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
19791979
require.NoError(t, err)
19801980
defer client.Close()
1981-
// Get the container exit status.
1982-
status, err := client.ContainerInspect(context.Background(), ctrID)
1983-
require.NoError(t, err)
1984-
require.Equal(t, 254, status.State.ExitCode)
1981+
// Get the container exit status. Note that the container may take a while to fully exit
1982+
// so we need to retry a couple of times.
1983+
require.Eventually(t, func() bool {
1984+
status, err := client.ContainerInspect(context.Background(), ctrID)
1985+
if !assert.NoError(t, err) {
1986+
return false
1987+
}
1988+
if status.State.Running {
1989+
t.Logf("container %q still running", ctrID)
1990+
return false
1991+
}
1992+
return assert.Equal(t, status.State.ExitCode, 254, "unexpected exit code")
1993+
}, 10*time.Second, time.Second, "unexpected exit code")
19851994
})
19861995

19871996
t.Run("CacheAndPushDevcontainerFeatures", func(t *testing.T) {

0 commit comments

Comments
 (0)