Browse code

integration/TestExportContainerAfterDaemonRestart: add

This test case checks that a container created before start
of the currently running dockerd can be exported (as reported
in #36561). To satisfy this condition, either a pre-existing
container is required, or a daemon restart after container
creation.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Kir Kolyshkin authored on 2018/03/15 16:30:11
Showing 1 changed files
... ...
@@ -7,7 +7,9 @@ import (
7 7
 	"time"
8 8
 
9 9
 	"github.com/docker/docker/api/types"
10
+	containerTypes "github.com/docker/docker/api/types/container"
10 11
 	"github.com/docker/docker/api/types/filters"
12
+	"github.com/docker/docker/integration-cli/daemon"
11 13
 	"github.com/docker/docker/integration/internal/container"
12 14
 	"github.com/docker/docker/integration/internal/request"
13 15
 	"github.com/docker/docker/pkg/jsonmessage"
... ...
@@ -51,3 +53,32 @@ func TestExportContainerAndImportImage(t *testing.T) {
51 51
 	require.NoError(t, err)
52 52
 	assert.Equal(t, jm.Status, images[0].ID)
53 53
 }
54
+
55
+// TestExportContainerAfterDaemonRestart checks that a container
56
+// created before start of the currently running dockerd
57
+// can be exported (as reported in #36561). To satisfy this
58
+// condition, daemon restart is needed after container creation.
59
+func TestExportContainerAfterDaemonRestart(t *testing.T) {
60
+	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
61
+	skip.If(t, testEnv.IsRemoteDaemon())
62
+
63
+	d := daemon.New(t, "", "dockerd", daemon.Config{})
64
+	client, err := d.NewClient()
65
+	require.NoError(t, err)
66
+
67
+	d.StartWithBusybox(t)
68
+	defer d.Stop(t)
69
+
70
+	ctx := context.Background()
71
+	cfg := containerTypes.Config{
72
+		Image: "busybox",
73
+		Cmd:   []string{"top"},
74
+	}
75
+	ctr, err := client.ContainerCreate(ctx, &cfg, nil, nil, "")
76
+	require.NoError(t, err)
77
+
78
+	d.Restart(t)
79
+
80
+	_, err = client.ContainerExport(ctx, ctr.ID)
81
+	assert.NoError(t, err)
82
+}