Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
| ... | ... |
@@ -453,3 +453,38 @@ func TestExecCgroup(t *testing.T) {
|
| 453 | 453 |
|
| 454 | 454 |
logDone("exec - exec has the container cgroups")
|
| 455 | 455 |
} |
| 456 |
+ |
|
| 457 |
+func TestInspectExecID(t *testing.T) {
|
|
| 458 |
+ defer deleteAllContainers() |
|
| 459 |
+ |
|
| 460 |
+ out, exitCode, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-d", "busybox", "top")) |
|
| 461 |
+ if exitCode != 0 || err != nil {
|
|
| 462 |
+ t.Fatalf("failed to run container: %s, %v", out, err)
|
|
| 463 |
+ } |
|
| 464 |
+ id := strings.TrimSuffix(out, "\n") |
|
| 465 |
+ |
|
| 466 |
+ out, err = inspectField(id, "ExecIDs") |
|
| 467 |
+ if err != nil {
|
|
| 468 |
+ t.Fatalf("failed to inspect container: %s, %v", out, err)
|
|
| 469 |
+ } |
|
| 470 |
+ if out != "<no value>" {
|
|
| 471 |
+ t.Fatalf("ExecIDs should be empty, got: %s", out)
|
|
| 472 |
+ } |
|
| 473 |
+ |
|
| 474 |
+ exitCode, err = runCommand(exec.Command(dockerBinary, "exec", "-d", id, "ls", "/")) |
|
| 475 |
+ if exitCode != 0 || err != nil {
|
|
| 476 |
+ t.Fatalf("failed to exec in container: %s, %v", out, err)
|
|
| 477 |
+ } |
|
| 478 |
+ |
|
| 479 |
+ out, err = inspectField(id, "ExecIDs") |
|
| 480 |
+ if err != nil {
|
|
| 481 |
+ t.Fatalf("failed to inspect container: %s, %v", out, err)
|
|
| 482 |
+ } |
|
| 483 |
+ |
|
| 484 |
+ out = strings.TrimSuffix(out, "\n") |
|
| 485 |
+ if out == "[]" || out == "<no value>" {
|
|
| 486 |
+ t.Fatalf("ExecIDs should not be empty, got: %s", out)
|
|
| 487 |
+ } |
|
| 488 |
+ |
|
| 489 |
+ logDone("inspect - inspect a container with ExecIDs")
|
|
| 490 |
+} |
| ... | ... |
@@ -21,38 +21,3 @@ func TestInspectImage(t *testing.T) {
|
| 21 | 21 |
|
| 22 | 22 |
logDone("inspect - inspect an image")
|
| 23 | 23 |
} |
| 24 |
- |
|
| 25 |
-func TestInspectExecID(t *testing.T) {
|
|
| 26 |
- defer deleteAllContainers() |
|
| 27 |
- |
|
| 28 |
- out, exitCode, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-d", "busybox", "top")) |
|
| 29 |
- if exitCode != 0 || err != nil {
|
|
| 30 |
- t.Fatalf("failed to run container: %s, %v", out, err)
|
|
| 31 |
- } |
|
| 32 |
- id := strings.TrimSuffix(out, "\n") |
|
| 33 |
- |
|
| 34 |
- out, err = inspectField(id, "ExecIDs") |
|
| 35 |
- if err != nil {
|
|
| 36 |
- t.Fatalf("failed to inspect container: %s, %v", out, err)
|
|
| 37 |
- } |
|
| 38 |
- if out != "<no value>" {
|
|
| 39 |
- t.Fatalf("ExecIDs should be empty, got: %s", out)
|
|
| 40 |
- } |
|
| 41 |
- |
|
| 42 |
- exitCode, err = runCommand(exec.Command(dockerBinary, "exec", "-d", id, "ls", "/")) |
|
| 43 |
- if exitCode != 0 || err != nil {
|
|
| 44 |
- t.Fatalf("failed to exec in container: %s, %v", out, err)
|
|
| 45 |
- } |
|
| 46 |
- |
|
| 47 |
- out, err = inspectField(id, "ExecIDs") |
|
| 48 |
- if err != nil {
|
|
| 49 |
- t.Fatalf("failed to inspect container: %s, %v", out, err)
|
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- out = strings.TrimSuffix(out, "\n") |
|
| 53 |
- if out == "[]" || out == "<no value>" {
|
|
| 54 |
- t.Fatalf("ExecIDs should not be empty, got: %s", out)
|
|
| 55 |
- } |
|
| 56 |
- |
|
| 57 |
- logDone("inspect - inspect a container with ExecIDs")
|
|
| 58 |
-} |