Skip to content
Snippets Groups Projects
Commit 5a86b8a9 authored by ale's avatar ale
Browse files

Fix the tests

The 'echo hi' test command has been replaced by 'sleep 1': previously
the container would exit so quickly that systemd-docker would fail to
detect its PID, thinking it didn't start at all.
parent 711caeab
No related branches found
No related tags found
No related merge requests found
Pipeline #5208 passed
......@@ -204,8 +204,8 @@ func TestBadExec(t *testing.T) {
if e, ok := err.(*exec.ExitError); ok {
if status, ok := e.Sys().(syscall.WaitStatus); ok {
if status.ExitStatus() != 2 {
log.Fatal("Expect 2 exit code got ", status.ExitStatus())
if status.ExitStatus() != 125 {
log.Fatal("Expect 125 exit code got ", status.ExitStatus())
}
}
} else {
......@@ -215,7 +215,7 @@ func TestBadExec(t *testing.T) {
func TestGoodExec(t *testing.T) {
c := &Context{
Args: []string{"-d", "busybox", "echo", "hi"},
Args: []string{"-d", "busybox", "sleep", "1"},
}
err := runContainer(c)
......@@ -243,7 +243,7 @@ func TestParseCgroups(t *testing.T) {
if val, ok := cgroups["blkio"]; ok {
p := path.Join(SYSFS, "blkio", val)
if _, err := os.Stat(p); os.IsNotExist(err) {
log.Fatalf("Path does not exist %s", p, err)
log.Fatalf("Path does not exist %s", err)
}
} else {
log.Fatal("Failed to find blkio cgroup", val)
......@@ -252,7 +252,7 @@ func TestParseCgroups(t *testing.T) {
func TestMoveCgroup(t *testing.T) {
c := &Context{
Args: []string{"-d", "busybox", "echo", "hi"},
Args: []string{"-d", "busybox", "sleep", "1"},
}
err := runContainer(c)
......@@ -277,7 +277,7 @@ func TestMoveCgroup(t *testing.T) {
}
func TestRemoveNoLogs(t *testing.T) {
c, err := mainWithArgs([]string{"--logs=false", "run", "-rm", "busybox", "echo", "hi"})
c, err := mainWithArgs([]string{"--logs=false", "run", "-rm", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -294,7 +294,7 @@ func TestRemoveNoLogs(t *testing.T) {
}
func TestRemoveWithLogs(t *testing.T) {
c, err := mainWithArgs([]string{"--logs", "run", "-rm", "busybox", "echo", "hi"})
c, err := mainWithArgs([]string{"--logs", "run", "-rm", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -338,7 +338,7 @@ func TestNamedContainerNoRm(t *testing.T) {
deleteTestContainer(t)
c, err := mainWithArgs([]string{"--logs", "run", "--privileged=true", "--name", "systemd-docker-test", "--privileged=true", "busybox", "echo", "hi"})
_, err = mainWithArgs([]string{"--logs", "run", "--privileged=true", "--name", "systemd-docker-test", "--privileged=true", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -352,7 +352,7 @@ func TestNamedContainerNoRm(t *testing.T) {
t.Fatal("Should not be running")
}
c, err = mainWithArgs([]string{"--logs", "run", "--privileged=true", "--name", "systemd-docker-test", "busybox", "echo", "hi"})
c, err := mainWithArgs([]string{"--logs", "run", "--privileged=true", "--name", "systemd-docker-test", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -385,7 +385,7 @@ func TestNamedContainerRmPrevious(t *testing.T) {
deleteTestContainer(t)
c, err := mainWithArgs([]string{"--logs", "run", "--name", "systemd-docker-test", "busybox", "echo", "hi"})
c, err := mainWithArgs([]string{"--logs", "run", "--name", "systemd-docker-test", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -399,7 +399,7 @@ func TestNamedContainerRmPrevious(t *testing.T) {
t.Fatal("Should not be running")
}
c, err = mainWithArgs([]string{"--logs", "run", "--rm", "--name", "systemd-docker-test", "busybox", "echo", "hi"})
c, err = mainWithArgs([]string{"--logs", "run", "--rm", "--name", "systemd-docker-test", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -438,7 +438,7 @@ func TestNamedContainerAttach(t *testing.T) {
t.Fatal("Should be running")
}
c, err = mainWithArgs([]string{"--logs=false", "run", "--name", "systemd-docker-test", "busybox", "echo", "hi"})
c, err = mainWithArgs([]string{"--logs=false", "run", "--name", "systemd-docker-test", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......@@ -474,7 +474,7 @@ func TestPidFile(t *testing.T) {
os.Remove(pidFileName)
c, err := mainWithArgs([]string{"--logs=false", "--pid-file", "./pid-file", "run", "--rm", "busybox", "echo", "hi"})
c, err := mainWithArgs([]string{"--logs=false", "--pid-file", "./pid-file", "run", "--rm", "busybox", "sleep", "1"})
if err != nil {
t.Fatal(err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment