Show right tag for container in ps

Fixes #10599

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: e45deceb462351f841aa077819fdef3166381c50
Component: engine
This commit is contained in:
Alexander Morozov
2015-02-05 14:55:08 -08:00
parent a99f7cd89b
commit 915f96f67c
2 changed files with 57 additions and 1 deletions

View File

@ -490,3 +490,52 @@ func TestPsListContainersFilterExited(t *testing.T) {
logDone("ps - test ps filter exited")
}
func TestPsRightTagName(t *testing.T) {
tag := "asybox:shmatest"
defer deleteAllContainers()
defer deleteImages(tag)
if out, err := exec.Command(dockerBinary, "tag", "busybox", tag).CombinedOutput(); err != nil {
t.Fatalf("Failed to tag image: %s, out: %q", err, out)
}
var id1 string
if out, err := exec.Command(dockerBinary, "run", "-d", "busybox", "top").CombinedOutput(); err != nil {
t.Fatalf("Failed to run container: %s, out: %q", err, out)
} else {
id1 = strings.TrimSpace(string(out))
}
var id2 string
if out, err := exec.Command(dockerBinary, "run", "-d", tag, "top").CombinedOutput(); err != nil {
t.Fatalf("Failed to run container: %s, out: %q", err, out)
} else {
id2 = strings.TrimSpace(string(out))
}
out, err := exec.Command(dockerBinary, "ps", "--no-trunc").CombinedOutput()
if err != nil {
t.Fatalf("Failed to run 'ps': %s, out: %q", err, out)
}
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
// skip header
lines = lines[1:]
if len(lines) != 2 {
t.Fatalf("There should be 2 running container, got %d", len(lines))
}
for _, line := range lines {
f := strings.Fields(line)
switch f[0] {
case id1:
if f[1] != "busybox:latest" {
t.Fatalf("Expected %s tag for id %s, got %s", "busybox", id1, f[1])
}
case id2:
if f[1] != tag {
t.Fatalf("Expected %s tag for id %s, got %s", tag, id1, f[1])
}
default:
t.Fatalf("Unexpected id %s, expected %s and %s", f[0], id1, id2)
}
}
logDone("ps - right tags for containers")
}