Skip to content

Commit f12f7fe

Browse files
authored
Merge pull request containerd#3624 from apostasie/series-13
Enable more tests to run on windows
2 parents 2b0550f + dc2c7b9 commit f12f7fe

File tree

6 files changed

+58
-35
lines changed

6 files changed

+58
-35
lines changed

cmd/nerdctl/image/image_convert_linux_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestImageConvert(t *testing.T) {
3131

3232
testCase := &test.Case{
3333
Require: test.Require(
34+
// FIXME: windows does not support stargz
3435
test.Not(test.Windows),
3536
test.Not(nerdtest.Docker),
3637
),

cmd/nerdctl/image/image_inspect_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) {
8787
testCase := &test.Case{
8888
Require: test.Require(
8989
test.Not(nerdtest.Docker),
90+
// FIXME: this test depends on hub images that do not have windows versions
9091
test.Not(test.Windows),
9192
// We need a clean slate
9293
nerdtest.Private,

cmd/nerdctl/image/image_remove_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func TestRemove(t *testing.T) {
4343
Description: "Remove image with stopped container - without -f",
4444
NoParallel: true,
4545
Require: test.Require(
46-
test.Not(test.Windows),
4746
test.Not(nerdtest.Docker),
4847
),
4948
Setup: func(data test.Data, helpers test.Helpers) {
@@ -68,7 +67,6 @@ func TestRemove(t *testing.T) {
6867
{
6968
Description: "Remove image with stopped container - with -f",
7069
NoParallel: true,
71-
Require: test.Not(test.Windows),
7270
Setup: func(data test.Data, helpers test.Helpers) {
7371
helpers.Ensure("run", "--pull", "always", "--name", data.Identifier(), testutil.CommonImage)
7472
},
@@ -90,7 +88,6 @@ func TestRemove(t *testing.T) {
9088
Description: "Remove image with running container - without -f",
9189
NoParallel: true,
9290
Require: test.Require(
93-
test.Not(test.Windows),
9491
test.Not(nerdtest.Docker),
9592
),
9693
Setup: func(data test.Data, helpers test.Helpers) {
@@ -121,7 +118,6 @@ func TestRemove(t *testing.T) {
121118
// untags `imageName` (left a `<none>` image) without deletion; `docker rmi -rf imageID` fails.
122119
// In both cases, `nerdctl rmi -f` will fail.
123120
Require: test.Require(
124-
test.Not(test.Windows),
125121
test.Not(nerdtest.Docker),
126122
),
127123
Setup: func(data test.Data, helpers test.Helpers) {
@@ -146,7 +142,6 @@ func TestRemove(t *testing.T) {
146142
{
147143
Description: "Remove image with created container - without -f",
148144
NoParallel: true,
149-
Require: test.Not(test.Windows),
150145
Setup: func(data test.Data, helpers test.Helpers) {
151146
helpers.Ensure("create", "--pull", "always", "--name", data.Identifier(), testutil.CommonImage, "sleep", nerdtest.Infinity)
152147
},
@@ -169,7 +164,6 @@ func TestRemove(t *testing.T) {
169164
{
170165
Description: "Remove image with created container - with -f",
171166
NoParallel: true,
172-
Require: test.Not(test.Windows),
173167
Setup: func(data test.Data, helpers test.Helpers) {
174168
helpers.Ensure("pull", "--quiet", testutil.NginxAlpineImage)
175169
helpers.Ensure("create", "--pull", "always", "--name", data.Identifier(), testutil.CommonImage, "sleep", nerdtest.Infinity)
@@ -197,7 +191,6 @@ func TestRemove(t *testing.T) {
197191
Description: "Remove image with paused container - without -f",
198192
NoParallel: true,
199193
Require: test.Require(
200-
test.Not(test.Windows),
201194
test.Not(nerdtest.Docker),
202195
nerdtest.CGroup,
203196
),
@@ -225,7 +218,6 @@ func TestRemove(t *testing.T) {
225218
Description: "Remove image with paused container - with -f",
226219
NoParallel: true,
227220
Require: test.Require(
228-
test.Not(test.Windows),
229221
nerdtest.CGroup,
230222
// FIXME: nerdctl is broken
231223
// https://github.com/containerd/nerdctl/issues/3454
@@ -258,7 +250,6 @@ func TestRemove(t *testing.T) {
258250
Description: "Remove image with killed container - without -f",
259251
NoParallel: true,
260252
Require: test.Require(
261-
test.Not(test.Windows),
262253
test.Not(nerdtest.Docker),
263254
),
264255
Setup: func(data test.Data, helpers test.Helpers) {
@@ -284,7 +275,6 @@ func TestRemove(t *testing.T) {
284275
{
285276
Description: "Remove image with killed container - with -f",
286277
NoParallel: true,
287-
Require: test.Not(test.Windows),
288278
Setup: func(data test.Data, helpers test.Helpers) {
289279
helpers.Ensure("run", "--pull", "always", "-d", "--name", data.Identifier(), testutil.CommonImage, "sleep", nerdtest.Infinity)
290280
helpers.Ensure("kill", data.Identifier())

cmd/nerdctl/image/image_save_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestSaveContent(t *testing.T) {
3535
nerdtest.Setup()
3636

3737
testCase := &test.Case{
38+
// FIXME: move to busybox for windows?
3839
Require: test.Not(test.Windows),
3940
Setup: func(data test.Data, helpers test.Helpers) {
4041
helpers.Ensure("pull", "--quiet", testutil.CommonImage)

cmd/nerdctl/issues/main_linux_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ func TestMain(m *testing.M) {
3333
func TestIssue108(t *testing.T) {
3434
testCase := nerdtest.Setup()
3535

36-
testCase.Require = test.Linux
37-
3836
testCase.SubTests = []*test.Case{
3937
{
4038
Description: "-it --net=host",

cmd/nerdctl/network/network_inspect_test.go

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ func TestNetworkInspect(t *testing.T) {
3838
testIPRange = "10.24.24.0/25"
3939
)
4040

41+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
42+
helpers.Ensure("network", "create", data.Identifier("basenet"))
43+
data.Set("basenet", data.Identifier("basenet"))
44+
}
45+
46+
testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
47+
helpers.Anyhow("network", "rm", data.Identifier("basenet"))
48+
}
49+
4150
testCase.SubTests = []*test.Case{
4251
{
4352
Description: "non existent network",
@@ -87,6 +96,18 @@ func TestNetworkInspect(t *testing.T) {
8796
assert.Equal(t, dc[0].Name, "bridge")
8897
}),
8998
},
99+
{
100+
Description: "nat",
101+
Require: test.Windows,
102+
Command: test.Command("network", "inspect", "nat"),
103+
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
104+
var dc []dockercompat.Network
105+
err := json.Unmarshal([]byte(stdout), &dc)
106+
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
107+
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
108+
assert.Equal(t, dc[0].Name, "nat")
109+
}),
110+
},
90111
{
91112
Description: "custom",
92113
Setup: func(data test.Data, helpers test.Helpers) {
@@ -106,45 +127,56 @@ func TestNetworkInspect(t *testing.T) {
106127
},
107128
{
108129
Description: "match exact id",
109-
Require: test.Not(test.Windows),
130+
// See notes below
110131
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
111-
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
132+
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Get("basenet"), "--format", "{{ .Id }}"))
112133
return helpers.Command("network", "inspect", id)
113134
},
114-
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
115-
var dc []dockercompat.Network
116-
err := json.Unmarshal([]byte(stdout), &dc)
117-
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
118-
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
119-
assert.Equal(t, dc[0].Name, "bridge")
120-
}),
135+
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
136+
return &test.Expected{
137+
Output: func(stdout string, info string, t *testing.T) {
138+
var dc []dockercompat.Network
139+
err := json.Unmarshal([]byte(stdout), &dc)
140+
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
141+
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
142+
assert.Equal(t, dc[0].Name, data.Get("basenet"))
143+
},
144+
}
145+
},
121146
},
122147
{
123148
Description: "match part of id",
124-
Require: test.Not(test.Windows),
149+
// FIXME: for windows, network inspect testnetworkinspect-basenet-468cf999 --format {{ .Id }} MAY fail here
150+
// This is bizarre, as it is working in the match exact id test - and there does not seem to be a particular reason for that
151+
Require: test.Not(test.Windows),
125152
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
126-
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
153+
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Get("basenet"), "--format", "{{ .Id }}"))
127154
return helpers.Command("network", "inspect", id[0:25])
128155
},
129-
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
130-
var dc []dockercompat.Network
131-
err := json.Unmarshal([]byte(stdout), &dc)
132-
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
133-
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
134-
assert.Equal(t, dc[0].Name, "bridge")
135-
}),
156+
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
157+
return &test.Expected{
158+
Output: func(stdout string, info string, t *testing.T) {
159+
var dc []dockercompat.Network
160+
err := json.Unmarshal([]byte(stdout), &dc)
161+
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
162+
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
163+
assert.Equal(t, dc[0].Name, data.Get("basenet"))
164+
},
165+
}
166+
},
136167
},
137168
{
138169
Description: "using another net short id",
139-
Require: test.Not(test.Windows),
170+
// FIXME: for windows, network inspect testnetworkinspect-basenet-468cf999 --format {{ .Id }} MAY fail here
171+
// This is bizarre, as it is working in the match exact id test - and there does not seem to be a particular reason for that
172+
Require: test.Not(test.Windows),
140173
Setup: func(data test.Data, helpers test.Helpers) {
141-
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
174+
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Get("basenet"), "--format", "{{ .Id }}"))
142175
helpers.Ensure("network", "create", id[0:12])
143176
data.Set("netname", id[0:12])
144177
},
145178
Cleanup: func(data test.Data, helpers test.Helpers) {
146-
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
147-
helpers.Anyhow("network", "remove", id[0:12])
179+
helpers.Anyhow("network", "remove", data.Get("netname"))
148180
},
149181
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
150182
return helpers.Command("network", "inspect", data.Get("netname"))
@@ -163,7 +195,7 @@ func TestNetworkInspect(t *testing.T) {
163195
},
164196
{
165197
Description: "basic",
166-
// IPAMConfig is not implemented on Windows yet
198+
// FIXME: IPAMConfig is not implemented on Windows yet
167199
Require: test.Not(test.Windows),
168200
Setup: func(data test.Data, helpers test.Helpers) {
169201
helpers.Ensure("network", "create", "--label", "tag=testNetwork", "--subnet", testSubnet,

0 commit comments

Comments
 (0)