Skip to content

Commit 09a0c94

Browse files
committed
tests: Adds support for Windows cri-integration tests
Currently, the cri-integration tests do not work on Windows due to various reasons. One of the reasons is because all the tests are using Linux-specific images. Previous commits refactored the image pulling / usage in the cri-integration tests, making it easier to update, and easier to configure a custom registry to pull images with Windows support. For Windows runs, custom registries can be created, which will also contain Windows images, and the cri-integration tests can be configured to use those registries by specifying the "--repo-list" argument, a YAML file which will contain an alternative mapping of the default registries. This is similar to how E2E tests are handled for Windows runs in Kubernetes. Some of the tests are Skipped, as they do not pass yet on Windows. Windows does not collect inodes used stats, thus, the tests that were expecting non-zero inodes stats were failing. Signed-off-by: Claudiu Belu <[email protected]>
1 parent fe5d349 commit 09a0c94

21 files changed

Lines changed: 153 additions & 81 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ bin/cri-integration.test:
194194

195195
cri-integration: binaries bin/cri-integration.test ## run cri integration tests
196196
@echo "$(WHALE) $@"
197-
@./script/test/cri-integration.sh
197+
@bash -x ./script/test/cri-integration.sh
198198
@rm -rf bin/cri-integration.test
199199

200200
benchmark: ## run benchmarks tests

integration/common.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53

integration/container_log_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53

integration/container_restart_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53
@@ -35,6 +33,9 @@ func TestContainerRestart(t *testing.T) {
3533
assert.NoError(t, runtimeService.StopPodSandbox(sb))
3634
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
3735
}()
36+
37+
EnsureImageExists(t, pauseImage)
38+
3839
t.Logf("Create a container config and run container in a pod")
3940
containerConfig := ContainerConfig(
4041
"container1",

integration/container_stats_test.go

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53
@@ -40,6 +38,9 @@ func TestContainerStats(t *testing.T) {
4038
assert.NoError(t, runtimeService.StopPodSandbox(sb))
4139
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
4240
}()
41+
42+
EnsureImageExists(t, pauseImage)
43+
4344
t.Logf("Create a container config and run container in a pod")
4445
containerConfig := ContainerConfig(
4546
"container1",
@@ -64,8 +65,7 @@ func TestContainerStats(t *testing.T) {
6465
if err != nil {
6566
return false, err
6667
}
67-
if s.GetWritableLayer().GetUsedBytes().GetValue() != 0 &&
68-
s.GetWritableLayer().GetInodesUsed().GetValue() != 0 {
68+
if s.GetWritableLayer().GetUsedBytes().GetValue() != 0 {
6969
return true, nil
7070
}
7171
return false, nil
@@ -162,6 +162,9 @@ func TestContainerListStats(t *testing.T) {
162162
assert.NoError(t, runtimeService.StopPodSandbox(sb))
163163
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
164164
}()
165+
166+
EnsureImageExists(t, pauseImage)
167+
165168
t.Logf("Create a container config and run containers in a pod")
166169
containerConfigMap := make(map[string]*runtime.ContainerConfig)
167170
for i := 0; i < 3; i++ {
@@ -192,8 +195,7 @@ func TestContainerListStats(t *testing.T) {
192195
return false, err
193196
}
194197
for _, s := range stats {
195-
if s.GetWritableLayer().GetUsedBytes().GetValue() == 0 &&
196-
s.GetWritableLayer().GetInodesUsed().GetValue() == 0 {
198+
if s.GetWritableLayer().GetUsedBytes().GetValue() == 0 {
197199
return false, nil
198200
}
199201
}
@@ -217,6 +219,9 @@ func TestContainerListStatsWithIdFilter(t *testing.T) {
217219
assert.NoError(t, runtimeService.StopPodSandbox(sb))
218220
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
219221
}()
222+
223+
EnsureImageExists(t, pauseImage)
224+
220225
t.Logf("Create a container config and run containers in a pod")
221226
containerConfigMap := make(map[string]*runtime.ContainerConfig)
222227
for i := 0; i < 3; i++ {
@@ -251,8 +256,7 @@ func TestContainerListStatsWithIdFilter(t *testing.T) {
251256
if len(stats) != 1 {
252257
return false, errors.New("unexpected stats length")
253258
}
254-
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 &&
255-
stats[0].GetWritableLayer().GetInodesUsed().GetValue() != 0 {
259+
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
256260
return true, nil
257261
}
258262
return false, nil
@@ -277,6 +281,9 @@ func TestContainerListStatsWithSandboxIdFilter(t *testing.T) {
277281
assert.NoError(t, runtimeService.StopPodSandbox(sb))
278282
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
279283
}()
284+
285+
EnsureImageExists(t, pauseImage)
286+
280287
t.Logf("Create a container config and run containers in a pod")
281288
containerConfigMap := make(map[string]*runtime.ContainerConfig)
282289
for i := 0; i < 3; i++ {
@@ -310,12 +317,12 @@ func TestContainerListStatsWithSandboxIdFilter(t *testing.T) {
310317
if len(stats) != 3 {
311318
return false, errors.New("unexpected stats length")
312319
}
313-
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 &&
314-
stats[0].GetWritableLayer().GetInodesUsed().GetValue() != 0 {
320+
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
315321
return true, nil
316322
}
317323
return false, nil
318-
}, time.Second, 30*time.Second))
324+
}, time.Second, 45*time.Second))
325+
// TODO(claudiub): Reduce the timer above to 30 seconds once Windows flakiness has been addressed.
319326
t.Logf("Verify container stats for sandbox %q", sb)
320327
for _, s := range stats {
321328
testStats(t, s, containerConfigMap[s.GetAttributes().GetId()])
@@ -333,6 +340,9 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
333340
assert.NoError(t, runtimeService.StopPodSandbox(sb))
334341
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
335342
}()
343+
344+
EnsureImageExists(t, pauseImage)
345+
336346
t.Logf("Create container config and run containers in a pod")
337347
containerConfigMap := make(map[string]*runtime.ContainerConfig)
338348
for i := 0; i < 3; i++ {
@@ -366,8 +376,7 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
366376
if len(stats) != 1 {
367377
return false, errors.New("unexpected stats length")
368378
}
369-
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 &&
370-
stats[0].GetWritableLayer().GetInodesUsed().GetValue() != 0 {
379+
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
371380
return true, nil
372381
}
373382
return false, nil
@@ -389,8 +398,7 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
389398
if len(stats) != 1 {
390399
return false, errors.New("unexpected stats length")
391400
}
392-
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 &&
393-
stats[0].GetWritableLayer().GetInodesUsed().GetValue() != 0 {
401+
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
394402
return true, nil
395403
}
396404
return false, nil
@@ -421,5 +429,9 @@ func testStats(t *testing.T,
421429
require.NotEmpty(t, s.GetWritableLayer().GetTimestamp())
422430
require.NotEmpty(t, s.GetWritableLayer().GetFsId().GetMountpoint())
423431
require.NotEmpty(t, s.GetWritableLayer().GetUsedBytes().GetValue())
424-
require.NotEmpty(t, s.GetWritableLayer().GetInodesUsed().GetValue())
432+
433+
// Windows does not collect inodes stats.
434+
if goruntime.GOOS != "windows" {
435+
require.NotEmpty(t, s.GetWritableLayer().GetInodesUsed().GetValue())
436+
}
425437
}

integration/container_stop_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53
@@ -20,6 +18,7 @@ package integration
2018

2119
import (
2220
"context"
21+
goruntime "runtime"
2322
"testing"
2423
"time"
2524

@@ -73,6 +72,9 @@ func TestSharedPidMultiProcessContainerStop(t *testing.T) {
7372
}
7473

7574
func TestContainerStopCancellation(t *testing.T) {
75+
if goruntime.GOOS == "windows" {
76+
t.Skip("Skipped on Windows.")
77+
}
7678
t.Log("Create a pod sandbox")
7779
sbConfig := PodSandboxConfig("sandbox", "cancel-container-stop")
7880
sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)

integration/container_update_resources_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func checkMemoryLimit(t *testing.T, spec *runtimespec.Spec, memLimit int64) {
3939
}
4040

4141
func TestUpdateContainerResources(t *testing.T) {
42+
// TODO(claudiub): Make this test work once https://github.com/microsoft/hcsshim/pull/931 merges.
4243
t.Log("Create a sandbox")
4344
sbConfig := PodSandboxConfig("sandbox", "update-container-resources")
4445
sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
@@ -48,6 +49,8 @@ func TestUpdateContainerResources(t *testing.T) {
4849
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
4950
}()
5051

52+
EnsureImageExists(t, pauseImage)
53+
5154
t.Log("Create a container with memory limit")
5255
cnConfig := ContainerConfig(
5356
"container",

integration/container_without_image_ref_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53

integration/containerd_image_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53
@@ -135,7 +133,7 @@ func TestContainerdImage(t *testing.T) {
135133
cnConfig := ContainerConfig(
136134
"test-container",
137135
id,
138-
WithCommand("top"),
136+
WithCommand("sleep", "300"),
139137
)
140138
cn, err := runtimeService.CreateContainer(sb, cnConfig, sbConfig)
141139
require.NoError(t, err)

integration/duplicate_name_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53
@@ -39,6 +37,8 @@ func TestDuplicateName(t *testing.T) {
3937
_, err = runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
4038
require.Error(t, err)
4139

40+
EnsureImageExists(t, pauseImage)
41+
4242
t.Logf("Create a container")
4343
cnConfig := ContainerConfig(
4444
"container",

0 commit comments

Comments
 (0)