Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -10,13 +10,11 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/integration/internal/request" |
| 11 | 11 |
"github.com/docker/docker/pkg/archive" |
| 12 | 12 |
"github.com/gotestyourself/gotestyourself/poll" |
| 13 |
- "github.com/gotestyourself/gotestyourself/skip" |
|
| 14 | 13 |
"github.com/stretchr/testify/assert" |
| 15 | 14 |
"github.com/stretchr/testify/require" |
| 16 | 15 |
) |
| 17 | 16 |
|
| 18 |
-// ensure that an added file shows up in docker diff |
|
| 19 |
-func TestDiffFilenameShownInOutput(t *testing.T) {
|
|
| 17 |
+func TestDiff(t *testing.T) {
|
|
| 20 | 18 |
defer setupTest(t)() |
| 21 | 19 |
client := request.NewAPIClient(t) |
| 22 | 20 |
ctx := context.Background() |
| ... | ... |
@@ -27,72 +25,19 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
|
| 27 | 27 |
// it will take a few seconds to exit. Also there's no way in Windows to |
| 28 | 28 |
// differentiate between an Add or a Modify, and all files are under |
| 29 | 29 |
// a "Files/" prefix. |
| 30 |
- lookingFor := containertypes.ContainerChangeResponseItem{Kind: archive.ChangeAdd, Path: "/foo/bar"}
|
|
| 30 |
+ expected := []containertypes.ContainerChangeResponseItem{
|
|
| 31 |
+ {Kind: archive.ChangeAdd, Path: "/foo"},
|
|
| 32 |
+ {Kind: archive.ChangeAdd, Path: "/foo/bar"},
|
|
| 33 |
+ } |
|
| 31 | 34 |
if testEnv.OSType == "windows" {
|
| 32 | 35 |
poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(60*time.Second)) |
| 33 |
- lookingFor = containertypes.ContainerChangeResponseItem{Kind: archive.ChangeModify, Path: "Files/foo/bar"}
|
|
| 34 |
- } |
|
| 35 |
- |
|
| 36 |
- items, err := client.ContainerDiff(ctx, cID) |
|
| 37 |
- require.NoError(t, err) |
|
| 38 |
- assert.Contains(t, items, lookingFor) |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-// test to ensure GH #3840 doesn't occur any more |
|
| 42 |
-func TestDiffEnsureInitLayerFilesAreIgnored(t *testing.T) {
|
|
| 43 |
- skip.If(t, testEnv.DaemonInfo.OSType != "linux") |
|
| 44 |
- |
|
| 45 |
- defer setupTest(t)() |
|
| 46 |
- client := request.NewAPIClient(t) |
|
| 47 |
- ctx := context.Background() |
|
| 48 |
- |
|
| 49 |
- // this is a list of files which shouldn't show up in `docker diff` |
|
| 50 |
- initLayerFiles := []string{"/etc/resolv.conf", "/etc/hostname", "/etc/hosts", "/.dockerenv"}
|
|
| 51 |
- containerCount := 5 |
|
| 52 |
- |
|
| 53 |
- // we might not run into this problem from the first run, so start a few containers |
|
| 54 |
- for i := 0; i < containerCount; i++ {
|
|
| 55 |
- cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", `echo foo > /root/bar`))
|
|
| 56 |
- |
|
| 57 |
- items, err := client.ContainerDiff(ctx, cID) |
|
| 58 |
- require.NoError(t, err) |
|
| 59 |
- for _, item := range items {
|
|
| 60 |
- assert.NotContains(t, initLayerFiles, item.Path) |
|
| 36 |
+ expected = []containertypes.ContainerChangeResponseItem{
|
|
| 37 |
+ {Kind: archive.ChangeModify, Path: "Files/foo"},
|
|
| 38 |
+ {Kind: archive.ChangeModify, Path: "Files/foo/bar"},
|
|
| 61 | 39 |
} |
| 62 | 40 |
} |
| 63 |
-} |
|
| 64 |
- |
|
| 65 |
-func TestDiffEnsureDefaultDevs(t *testing.T) {
|
|
| 66 |
- skip.If(t, testEnv.DaemonInfo.OSType != "linux") |
|
| 67 |
- |
|
| 68 |
- defer setupTest(t)() |
|
| 69 |
- client := request.NewAPIClient(t) |
|
| 70 |
- ctx := context.Background() |
|
| 71 |
- |
|
| 72 |
- cID := container.Run(t, ctx, client, container.WithCmd("sleep", "0"))
|
|
| 73 | 41 |
|
| 74 | 42 |
items, err := client.ContainerDiff(ctx, cID) |
| 75 | 43 |
require.NoError(t, err) |
| 76 |
- |
|
| 77 |
- expected := []containertypes.ContainerChangeResponseItem{
|
|
| 78 |
- {Kind: archive.ChangeModify, Path: "/dev"},
|
|
| 79 |
- {Kind: archive.ChangeAdd, Path: "/dev/full"}, // busybox
|
|
| 80 |
- {Kind: archive.ChangeModify, Path: "/dev/ptmx"}, // libcontainer
|
|
| 81 |
- {Kind: archive.ChangeAdd, Path: "/dev/mqueue"},
|
|
| 82 |
- {Kind: archive.ChangeAdd, Path: "/dev/kmsg"},
|
|
| 83 |
- {Kind: archive.ChangeAdd, Path: "/dev/fd"},
|
|
| 84 |
- {Kind: archive.ChangeAdd, Path: "/dev/ptmx"},
|
|
| 85 |
- {Kind: archive.ChangeAdd, Path: "/dev/null"},
|
|
| 86 |
- {Kind: archive.ChangeAdd, Path: "/dev/random"},
|
|
| 87 |
- {Kind: archive.ChangeAdd, Path: "/dev/stdout"},
|
|
| 88 |
- {Kind: archive.ChangeAdd, Path: "/dev/stderr"},
|
|
| 89 |
- {Kind: archive.ChangeAdd, Path: "/dev/tty1"},
|
|
| 90 |
- {Kind: archive.ChangeAdd, Path: "/dev/stdin"},
|
|
| 91 |
- {Kind: archive.ChangeAdd, Path: "/dev/tty"},
|
|
| 92 |
- {Kind: archive.ChangeAdd, Path: "/dev/urandom"},
|
|
| 93 |
- } |
|
| 94 |
- |
|
| 95 |
- for _, item := range items {
|
|
| 96 |
- assert.Contains(t, expected, item) |
|
| 97 |
- } |
|
| 44 |
+ assert.Equal(t, expected, items) |
|
| 98 | 45 |
} |