Browse code

Prepare tests for Windows containerd support

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>

Olli Janatuinen authored on 2021/03/19 00:55:11
Showing 6 changed files
... ...
@@ -440,7 +440,7 @@ func (s *DockerSuite) TestEventsCopy(c *testing.T) {
440 440
 }
441 441
 
442 442
 func (s *DockerSuite) TestEventsResize(c *testing.T) {
443
-	out := runSleepingContainer(c, "-d")
443
+	out := runSleepingContainer(c, "-d", "-t")
444 444
 	cID := strings.TrimSpace(out)
445 445
 	assert.NilError(c, waitRun(cID))
446 446
 
... ...
@@ -35,14 +35,19 @@ func TestCopyFromContainerPathDoesNotExist(t *testing.T) {
35 35
 
36 36
 func TestCopyFromContainerPathIsNotDir(t *testing.T) {
37 37
 	defer setupTest(t)()
38
-	skip.If(t, testEnv.OSType == "windows")
39 38
 
40 39
 	ctx := context.Background()
41 40
 	apiclient := testEnv.APIClient()
42 41
 	cid := container.Create(ctx, t, apiclient)
43 42
 
44
-	_, _, err := apiclient.CopyFromContainer(ctx, cid, "/etc/passwd/")
45
-	assert.Assert(t, is.ErrorContains(err, "not a directory"))
43
+	path := "/etc/passwd/"
44
+	expected := "not a directory"
45
+	if testEnv.OSType == "windows" {
46
+		path = "c:/windows/system32/drivers/etc/hosts/"
47
+		expected = "The filename, directory name, or volume label syntax is incorrect."
48
+	}
49
+	_, _, err := apiclient.CopyFromContainer(ctx, cid, path)
50
+	assert.Assert(t, is.ErrorContains(err, expected))
46 51
 }
47 52
 
48 53
 func TestCopyToContainerPathDoesNotExist(t *testing.T) {
... ...
@@ -60,13 +65,16 @@ func TestCopyToContainerPathDoesNotExist(t *testing.T) {
60 60
 
61 61
 func TestCopyToContainerPathIsNotDir(t *testing.T) {
62 62
 	defer setupTest(t)()
63
-	skip.If(t, testEnv.OSType == "windows")
64 63
 
65 64
 	ctx := context.Background()
66 65
 	apiclient := testEnv.APIClient()
67 66
 	cid := container.Create(ctx, t, apiclient)
68 67
 
69
-	err := apiclient.CopyToContainer(ctx, cid, "/etc/passwd/", nil, types.CopyToContainerOptions{})
68
+	path := "/etc/passwd/"
69
+	if testEnv.OSType == "windows" {
70
+		path = "c:/windows/system32/drivers/etc/hosts/"
71
+	}
72
+	err := apiclient.CopyToContainer(ctx, cid, path, nil, types.CopyToContainerOptions{})
70 73
 	assert.Assert(t, is.ErrorContains(err, "not a directory"))
71 74
 }
72 75
 
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"testing"
7 7
 	"time"
8 8
 
9
+	containerderrdefs "github.com/containerd/containerd/errdefs"
9 10
 	"github.com/docker/docker/api/types"
10 11
 	"github.com/docker/docker/api/types/events"
11 12
 	"github.com/docker/docker/api/types/filters"
... ...
@@ -62,7 +63,7 @@ func TestPauseFailsOnWindowsServerContainers(t *testing.T) {
62 62
 	poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
63 63
 
64 64
 	err := client.ContainerPause(ctx, cID)
65
-	assert.Check(t, is.ErrorContains(err, "cannot pause Windows Server Containers"))
65
+	assert.Check(t, is.ErrorContains(err, containerderrdefs.ErrNotImplemented.Error()))
66 66
 }
67 67
 
68 68
 func TestPauseStopPausedContainer(t *testing.T) {
... ...
@@ -123,7 +123,6 @@ func TestRenameInvalidName(t *testing.T) {
123 123
 // This test is to make sure once the container has been renamed,
124 124
 // the service discovery for the (re)named container works.
125 125
 func TestRenameAnonymousContainer(t *testing.T) {
126
-	skip.If(t, testEnv.OSType == "windows", "FIXME")
127 126
 	defer setupTest(t)()
128 127
 	ctx := context.Background()
129 128
 	client := testEnv.APIClient()
... ...
@@ -21,7 +21,7 @@ func TestResize(t *testing.T) {
21 21
 	client := testEnv.APIClient()
22 22
 	ctx := context.Background()
23 23
 
24
-	cID := container.Run(ctx, t, client)
24
+	cID := container.Run(ctx, t, client, container.WithTty(true))
25 25
 
26 26
 	poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
27 27
 
... ...
@@ -34,7 +34,6 @@ func TestResize(t *testing.T) {
34 34
 
35 35
 func TestResizeWithInvalidSize(t *testing.T) {
36 36
 	skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.32"), "broken in earlier versions")
37
-	skip.If(t, testEnv.OSType == "windows", "FIXME")
38 37
 	defer setupTest(t)()
39 38
 	client := testEnv.APIClient()
40 39
 	ctx := context.Background()
... ...
@@ -22,6 +22,7 @@ import (
22 22
 	opengcs "github.com/Microsoft/opengcs/client"
23 23
 	"github.com/containerd/containerd"
24 24
 	"github.com/containerd/containerd/cio"
25
+	containerderrdefs "github.com/containerd/containerd/errdefs"
25 26
 
26 27
 	"github.com/docker/docker/errdefs"
27 28
 	"github.com/docker/docker/libcontainerd/queue"
... ...
@@ -985,7 +986,7 @@ func (c *client) Pause(_ context.Context, containerID string) error {
985 985
 	}
986 986
 
987 987
 	if ctr.ociSpec.Windows.HyperV == nil {
988
-		return errors.New("cannot pause Windows Server Containers")
988
+		return containerderrdefs.ErrNotImplemented
989 989
 	}
990 990
 
991 991
 	ctr.Lock()