mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
Fix docker tests
Some tests have containers that die almost immediately, and may die and cleaned up before `driver.WaitUntilStarted` runs. The causes for container dying seems special for each test: * TestDockerDriver_Cleanup: `hello-world` image just emits a message and exits immediately * TestDockerDriver_ForcePull_RepoDigest: the busybox image in `TestDockerDriver_ForcePull_RepoDigest` test didn't support `-p 0` argument * TestDockerDriver_Entrypoint: with the entrypoint being `/bin/sh -c`, the command needs to be the entire string; otherwise, it ignores the comments
This commit is contained in:
@@ -1089,6 +1089,8 @@ func TestDockerDriver_ForcePull_RepoDigest(t *testing.T) {
|
||||
cfg.Image = "library/busybox@sha256:58ac43b2cc92c687a32c8be6278e50a063579655fe3090125dcb2af0ff9e1a64"
|
||||
localDigest := "sha256:8ac48589692a53a9b8c2d1ceaa6b402665aa7fe667ba51ccc03002300856d8c7"
|
||||
cfg.ForcePull = true
|
||||
cfg.Command = "/bin/sleep"
|
||||
cfg.Args = []string{"100"}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
@@ -1908,15 +1910,19 @@ func TestDockerDriver_Cleanup(t *testing.T) {
|
||||
t.Skip("Docker not connected")
|
||||
}
|
||||
|
||||
imageName := "hello-world:latest"
|
||||
// using a small image and an specific point release to avoid accidental conflicts with other tasks
|
||||
imageName := "busybox:1.27.1"
|
||||
task := &drivers.TaskConfig{
|
||||
ID: uuid.Generate(),
|
||||
Name: "cleanup_test",
|
||||
Resources: basicResources,
|
||||
}
|
||||
cfg := &TaskConfig{
|
||||
Image: imageName,
|
||||
Image: imageName,
|
||||
Command: "/bin/sleep",
|
||||
Args: []string{"100"},
|
||||
}
|
||||
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, driver, handle, cleanup := dockerSetup(t, task)
|
||||
@@ -2133,6 +2139,9 @@ func TestDockerDriver_Entrypoint(t *testing.T) {
|
||||
entrypoint := []string{"/bin/sh", "-c"}
|
||||
task, cfg, _ := dockerTask(t)
|
||||
cfg.Entrypoint = entrypoint
|
||||
cfg.Command = "/bin/sleep 100"
|
||||
cfg.Args = []string{}
|
||||
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, driver, handle, cleanup := dockerSetup(t, task)
|
||||
@@ -2275,7 +2284,7 @@ func TestDockerDriver_AdvertiseIPv6Address(t *testing.T) {
|
||||
handle, ok := driver.Impl().(*Driver).tasks.Get(task.ID)
|
||||
require.True(t, ok)
|
||||
|
||||
driver.WaitUntilStarted(task.ID, time.Second)
|
||||
require.NoError(t, driver.WaitUntilStarted(task.ID, time.Second))
|
||||
|
||||
container, err := client.InspectContainer(handle.containerID)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user