Skip to content

Commit 4c8b1fd

Browse files
committed
Enabling Windows integration tests
Signed-off-by: Salahuddin Khan <salah@docker.com>
1 parent d3cc071 commit 4c8b1fd

File tree

17 files changed

+630
-383
lines changed

17 files changed

+630
-383
lines changed

‎hack/ci/windowsRS1.ps1‎

Lines changed: 353 additions & 265 deletions
Large diffs are not rendered by default.

‎integration/build/build_squash_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
func TestBuildSquashParent(t *testing.T) {
2222
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
23+
skip.If(t, !testEnv.DaemonInfo.ExperimentalBuild)
2324
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
2425
d := daemon.New(t, daemon.WithExperimental)
2526
d.StartWithBusybox(t)

‎integration/build/build_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func TestBuildMultiStageParentConfig(t *testing.T) {
189189
// Test cases in #36996
190190
func TestBuildLabelWithTargets(t *testing.T) {
191191
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "test added after 1.38")
192+
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
192193
bldName := "build-a"
193194
testLabels := map[string]string{
194195
"foo": "bar",
@@ -443,6 +444,7 @@ RUN [ ! -f foo ]
443444

444445
// #37581
445446
func TestBuildWithHugeFile(t *testing.T) {
447+
skip.If(t, testEnv.OSType == "windows")
446448
ctx := context.TODO()
447449
defer setupTest(t)()
448450

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package container // import "github.com/docker/docker/integration/container"
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"strconv"
7+
"strings"
8+
"testing"
9+
"time"
10+
11+
"github.com/docker/docker/api/types"
12+
"github.com/docker/docker/integration/internal/container"
13+
"github.com/docker/docker/internal/test/request"
14+
"gotest.tools/assert"
15+
"gotest.tools/icmd"
16+
"gotest.tools/poll"
17+
"gotest.tools/skip"
18+
)
19+
20+
// TestStopContainerWithTimeout checks that ContainerStop with
21+
// a timeout works as documented, i.e. in case of negative timeout
22+
// waiting is not limited (issue #35311).
23+
func TestStopContainerWithTimeout(t *testing.T) {
24+
defer setupTest(t)()
25+
client := request.NewAPIClient(t)
26+
ctx := context.Background()
27+
28+
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
29+
testData := []struct {
30+
doc string
31+
timeout int
32+
expectedExitCode int
33+
}{
34+
// In case container is forcefully killed, 137 is returned,
35+
// otherwise the exit code from the above script
36+
{
37+
"zero timeout: expect forceful container kill",
38+
0, 137,
39+
},
40+
{
41+
"too small timeout: expect forceful container kill",
42+
1, 137,
43+
},
44+
{
45+
"big enough timeout: expect graceful container stop",
46+
3, 42,
47+
},
48+
{
49+
"unlimited timeout: expect graceful container stop",
50+
-1, 42,
51+
},
52+
}
53+
54+
for _, d := range testData {
55+
d := d
56+
t.Run(strconv.Itoa(d.timeout), func(t *testing.T) {
57+
t.Parallel()
58+
id := container.Run(t, ctx, client, testCmd)
59+
60+
timeout := time.Duration(d.timeout) * time.Second
61+
err := client.ContainerStop(ctx, id, &timeout)
62+
assert.NilError(t, err)
63+
64+
poll.WaitOn(t, container.IsStopped(ctx, client, id),
65+
poll.WithDelay(100*time.Millisecond))
66+
67+
inspect, err := client.ContainerInspect(ctx, id)
68+
assert.NilError(t, err)
69+
assert.Equal(t, inspect.State.ExitCode, d.expectedExitCode)
70+
})
71+
}
72+
}
73+
74+
func TestDeleteDevicemapper(t *testing.T) {
75+
skip.If(t, testEnv.DaemonInfo.Driver != "devicemapper")
76+
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
77+
78+
defer setupTest(t)()
79+
client := request.NewAPIClient(t)
80+
ctx := context.Background()
81+
82+
id := container.Run(t, ctx, client, container.WithName("foo-"+t.Name()), container.WithCmd("echo"))
83+
84+
poll.WaitOn(t, container.IsStopped(ctx, client, id), poll.WithDelay(100*time.Millisecond))
85+
86+
inspect, err := client.ContainerInspect(ctx, id)
87+
assert.NilError(t, err)
88+
89+
deviceID := inspect.GraphDriver.Data["DeviceId"]
90+
91+
// Find pool name from device name
92+
deviceName := inspect.GraphDriver.Data["DeviceName"]
93+
devicePrefix := deviceName[:strings.LastIndex(deviceName, "-")]
94+
devicePool := fmt.Sprintf("/dev/mapper/%s-pool", devicePrefix)
95+
96+
result := icmd.RunCommand("dmsetup", "message", devicePool, "0", fmt.Sprintf("delete %s", deviceID))
97+
result.Assert(t, icmd.Success)
98+
99+
err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{})
100+
assert.NilError(t, err)
101+
}

‎integration/container/stop_test.go‎

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@ package container // import "github.com/docker/docker/integration/container"
22

33
import (
44
"context"
5-
"fmt"
6-
"strconv"
7-
"strings"
85
"testing"
96
"time"
107

11-
"github.com/docker/docker/api/types"
128
"github.com/docker/docker/integration/internal/container"
139
"github.com/docker/docker/internal/test/request"
1410
"gotest.tools/assert"
15-
"gotest.tools/icmd"
1611
"gotest.tools/poll"
17-
"gotest.tools/skip"
1812
)
1913

2014
func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
@@ -42,86 +36,3 @@ func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
4236
poll.WaitOn(t, container.IsStopped(ctx, client, name), poll.WithDelay(100*time.Millisecond))
4337
}
4438
}
45-
46-
// TestStopContainerWithTimeout checks that ContainerStop with
47-
// a timeout works as documented, i.e. in case of negative timeout
48-
// waiting is not limited (issue #35311).
49-
func TestStopContainerWithTimeout(t *testing.T) {
50-
defer setupTest(t)()
51-
client := request.NewAPIClient(t)
52-
ctx := context.Background()
53-
54-
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
55-
testData := []struct {
56-
doc string
57-
timeout int
58-
expectedExitCode int
59-
}{
60-
// In case container is forcefully killed, 137 is returned,
61-
// otherwise the exit code from the above script
62-
{
63-
"zero timeout: expect forceful container kill",
64-
0, 137,
65-
},
66-
{
67-
"too small timeout: expect forceful container kill",
68-
1, 137,
69-
},
70-
{
71-
"big enough timeout: expect graceful container stop",
72-
3, 42,
73-
},
74-
{
75-
"unlimited timeout: expect graceful container stop",
76-
-1, 42,
77-
},
78-
}
79-
80-
for _, d := range testData {
81-
d := d
82-
t.Run(strconv.Itoa(d.timeout), func(t *testing.T) {
83-
t.Parallel()
84-
id := container.Run(t, ctx, client, testCmd)
85-
86-
timeout := time.Duration(d.timeout) * time.Second
87-
err := client.ContainerStop(ctx, id, &timeout)
88-
assert.NilError(t, err)
89-
90-
poll.WaitOn(t, container.IsStopped(ctx, client, id),
91-
poll.WithDelay(100*time.Millisecond))
92-
93-
inspect, err := client.ContainerInspect(ctx, id)
94-
assert.NilError(t, err)
95-
assert.Equal(t, inspect.State.ExitCode, d.expectedExitCode)
96-
})
97-
}
98-
}
99-
100-
func TestDeleteDevicemapper(t *testing.T) {
101-
skip.If(t, testEnv.DaemonInfo.Driver != "devicemapper")
102-
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
103-
104-
defer setupTest(t)()
105-
client := request.NewAPIClient(t)
106-
ctx := context.Background()
107-
108-
id := container.Run(t, ctx, client, container.WithName("foo-"+t.Name()), container.WithCmd("echo"))
109-
110-
poll.WaitOn(t, container.IsStopped(ctx, client, id), poll.WithDelay(100*time.Millisecond))
111-
112-
inspect, err := client.ContainerInspect(ctx, id)
113-
assert.NilError(t, err)
114-
115-
deviceID := inspect.GraphDriver.Data["DeviceId"]
116-
117-
// Find pool name from device name
118-
deviceName := inspect.GraphDriver.Data["DeviceName"]
119-
devicePrefix := deviceName[:strings.LastIndex(deviceName, "-")]
120-
devicePool := fmt.Sprintf("/dev/mapper/%s-pool", devicePrefix)
121-
122-
result := icmd.RunCommand("dmsetup", "message", devicePool, "0", fmt.Sprintf("delete %s", deviceID))
123-
result.Assert(t, icmd.Success)
124-
125-
err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{})
126-
assert.NilError(t, err)
127-
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package container // import "github.com/docker/docker/integration/container"
2+
3+
import (
4+
"context"
5+
"strconv"
6+
"testing"
7+
"time"
8+
9+
"github.com/docker/docker/integration/internal/container"
10+
"github.com/docker/docker/internal/test/request"
11+
"gotest.tools/assert"
12+
"gotest.tools/poll"
13+
"gotest.tools/skip"
14+
)
15+
16+
// TestStopContainerWithTimeout checks that ContainerStop with
17+
// a timeout works as documented, i.e. in case of negative timeout
18+
// waiting is not limited (issue #35311).
19+
func TestStopContainerWithTimeout(t *testing.T) {
20+
skip.If(t, testEnv.OSType == "windows")
21+
defer setupTest(t)()
22+
client := request.NewAPIClient(t)
23+
ctx := context.Background()
24+
25+
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
26+
testData := []struct {
27+
doc string
28+
timeout int
29+
expectedExitCode int
30+
}{
31+
// In case container is forcefully killed, 137 is returned,
32+
// otherwise the exit code from the above script
33+
{
34+
"zero timeout: expect forceful container kill",
35+
1, 0x40010004,
36+
},
37+
{
38+
"too small timeout: expect forceful container kill",
39+
2, 0x40010004,
40+
},
41+
{
42+
"big enough timeout: expect graceful container stop",
43+
120, 42,
44+
},
45+
{
46+
"unlimited timeout: expect graceful container stop",
47+
-1, 42,
48+
},
49+
}
50+
51+
for _, d := range testData {
52+
d := d
53+
t.Run(strconv.Itoa(d.timeout), func(t *testing.T) {
54+
t.Parallel()
55+
id := container.Run(t, ctx, client, testCmd)
56+
57+
timeout := time.Duration(d.timeout) * time.Second
58+
err := client.ContainerStop(ctx, id, &timeout)
59+
assert.NilError(t, err)
60+
61+
poll.WaitOn(t, container.IsStopped(ctx, client, id),
62+
poll.WithDelay(100*time.Millisecond))
63+
64+
inspect, err := client.ContainerInspect(ctx, id)
65+
assert.NilError(t, err)
66+
assert.Equal(t, inspect.State.ExitCode, d.expectedExitCode)
67+
})
68+
}
69+
}

‎integration/image/import_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/docker/docker/api/types"
1212
"github.com/docker/docker/internal/test/request"
1313
"github.com/docker/docker/internal/testutil"
14-
"github.com/gotestyourself/gotestyourself/skip"
14+
"gotest.tools/skip"
1515
)
1616

1717
// Ensure we don't regress on CVE-2017-14992.

‎integration/image/tag_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/docker/docker/internal/testutil"
1010
"gotest.tools/assert"
1111
is "gotest.tools/assert/cmp"
12+
"gotest.tools/skip"
1213
)
1314

1415
// tagging a named image in a new unprefixed repo should work
@@ -95,6 +96,7 @@ func TestTagExistedNameWithoutForce(t *testing.T) {
9596
// ensure tagging using official names works
9697
// ensure all tags result in the same name
9798
func TestTagOfficialNames(t *testing.T) {
99+
skip.If(t, testEnv.OSType == "windows")
98100
defer setupTest(t)()
99101
client := request.NewAPIClient(t)
100102
ctx := context.Background()

‎integration/internal/requirement/requirement.go‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import (
55
"strings"
66
"testing"
77
"time"
8-
9-
"github.com/docker/docker/pkg/parsers/kernel"
10-
"gotest.tools/icmd"
118
)
129

1310
// HasHubConnectivity checks to see if https://hub.docker.com is
@@ -28,26 +25,3 @@ func HasHubConnectivity(t *testing.T) bool {
2825
}
2926
return err == nil
3027
}
31-
32-
func overlayFSSupported() bool {
33-
result := icmd.RunCommand("/bin/sh", "-c", "cat /proc/filesystems")
34-
if result.Error != nil {
35-
return false
36-
}
37-
return strings.Contains(result.Combined(), "overlay\n")
38-
}
39-
40-
// Overlay2Supported returns true if the current system supports overlay2 as graphdriver
41-
func Overlay2Supported(kernelVersion string) bool {
42-
if !overlayFSSupported() {
43-
return false
44-
}
45-
46-
daemonV, err := kernel.ParseRelease(kernelVersion)
47-
if err != nil {
48-
return false
49-
}
50-
requiredV := kernel.VersionInfo{Kernel: 4}
51-
return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
52-
53-
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package requirement // import "github.com/docker/docker/integration/internal/requirement"
2+
3+
import (
4+
"strings"
5+
6+
"github.com/docker/docker/pkg/parsers/kernel"
7+
"gotest.tools/icmd"
8+
)
9+
10+
func overlayFSSupported() bool {
11+
result := icmd.RunCommand("/bin/sh", "-c", "cat /proc/filesystems")
12+
if result.Error != nil {
13+
return false
14+
}
15+
return strings.Contains(result.Combined(), "overlay\n")
16+
}
17+
18+
// Overlay2Supported returns true if the current system supports overlay2 as graphdriver
19+
func Overlay2Supported(kernelVersion string) bool {
20+
if !overlayFSSupported() {
21+
return false
22+
}
23+
24+
daemonV, err := kernel.ParseRelease(kernelVersion)
25+
if err != nil {
26+
return false
27+
}
28+
requiredV := kernel.VersionInfo{Kernel: 4}
29+
return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
30+
31+
}

0 commit comments

Comments
 (0)