From 035ce6c975cdabd7d32486c619e45832b64787e2 Mon Sep 17 00:00:00 2001 From: Haiyan Meng Date: Tue, 26 Feb 2019 12:19:01 -0800 Subject: [PATCH] Update test based on new PullImage CRI. Signed-off-by: Haiyan Meng --- integration/addition_gids_test.go | 2 +- integration/container_log_test.go | 4 ++-- integration/container_stop_test.go | 2 +- integration/container_without_image_ref_test.go | 2 +- integration/containerd_image_test.go | 3 ++- integration/imagefs_info_test.go | 5 +++-- integration/pod_hostname_test.go | 2 +- integration/restart_test.go | 7 ++++--- integration/truncindex_test.go | 5 +++-- integration/volume_copy_up_test.go | 4 ++-- 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/integration/addition_gids_test.go b/integration/addition_gids_test.go index f1433f1cd..3fcad9fb7 100644 --- a/integration/addition_gids_test.go +++ b/integration/addition_gids_test.go @@ -48,7 +48,7 @@ func TestAdditionalGids(t *testing.T) { containerName = "test-container" ) t.Logf("Pull test image %q", testImage) - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) diff --git a/integration/container_log_test.go b/integration/container_log_test.go index 27f6dbce2..2295fbb9f 100644 --- a/integration/container_log_test.go +++ b/integration/container_log_test.go @@ -51,7 +51,7 @@ func TestContainerLogWithoutTailingNewLine(t *testing.T) { containerName = "test-container" ) t.Logf("Pull test image %q", testImage) - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) @@ -111,7 +111,7 @@ func TestLongContainerLog(t *testing.T) { containerName = "test-container" ) t.Logf("Pull test image %q", testImage) - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) diff --git a/integration/container_stop_test.go b/integration/container_stop_test.go index 39998a021..3eb994a32 100644 --- a/integration/container_stop_test.go +++ b/integration/container_stop_test.go @@ -43,7 +43,7 @@ func TestSharedPidMultiProcessContainerStop(t *testing.T) { containerName = "test-container" ) t.Logf("Pull test image %q", testImage) - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) diff --git a/integration/container_without_image_ref_test.go b/integration/container_without_image_ref_test.go index ec7cd4e34..93b8504a7 100644 --- a/integration/container_without_image_ref_test.go +++ b/integration/container_without_image_ref_test.go @@ -40,7 +40,7 @@ func TestContainerLifecycleWithoutImageRef(t *testing.T) { containerName = "test-container" ) t.Log("Pull test image") - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) diff --git a/integration/containerd_image_test.go b/integration/containerd_image_test.go index 10be37134..4203d7ebe 100644 --- a/integration/containerd_image_test.go +++ b/integration/containerd_image_test.go @@ -182,8 +182,9 @@ func TestContainerdImageInOtherNamespaces(t *testing.T) { } require.NoError(t, Consistently(checkImage, 100*time.Millisecond, time.Second)) + sbConfig := PodSandboxConfig("sandbox", "test") t.Logf("pull the image into cri plugin") - id, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + id, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: id})) diff --git a/integration/imagefs_info_test.go b/integration/imagefs_info_test.go index 7f5b5c533..edeece849 100644 --- a/integration/imagefs_info_test.go +++ b/integration/imagefs_info_test.go @@ -28,15 +28,16 @@ import ( ) func TestImageFSInfo(t *testing.T) { + config := PodSandboxConfig("running-pod", "imagefs") + t.Logf("Pull an image to make sure image fs is not empty") - img, err := imageService.PullImage(&runtime.ImageSpec{Image: "busybox"}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: "busybox"}, nil, config) require.NoError(t, err) defer func() { err := imageService.RemoveImage(&runtime.ImageSpec{Image: img}) assert.NoError(t, err) }() t.Logf("Create a sandbox to make sure there is an active snapshot") - config := PodSandboxConfig("running-pod", "imagefs") sb, err := runtimeService.RunPodSandbox(config, *runtimeHandler) require.NoError(t, err) defer func() { diff --git a/integration/pod_hostname_test.go b/integration/pod_hostname_test.go index 1c01494b7..d9886fcb8 100644 --- a/integration/pod_hostname_test.go +++ b/integration/pod_hostname_test.go @@ -75,7 +75,7 @@ func TestPodHostname(t *testing.T) { containerName = "test-container" ) t.Logf("Pull test image %q", testImage) - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) diff --git a/integration/restart_test.go b/integration/restart_test.go index 90525d378..4ebb03f36 100644 --- a/integration/restart_test.go +++ b/integration/restart_test.go @@ -133,7 +133,7 @@ func TestContainerdRestart(t *testing.T) { t.Logf("Pull test images") for _, image := range []string{"busybox", "alpine"} { - img, err := imageService.PullImage(&runtime.ImageSpec{image}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{image}, nil, nil) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) @@ -209,15 +209,16 @@ func TestUnknownStateAfterContainerdRestart(t *testing.T) { t.Skip("unsupported config: runc not in PATH") } + sbConfig := PodSandboxConfig("sandbox", "sandbox-unknown-state") + const testImage = "busybox" t.Logf("Pull test image %q", testImage) - img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) defer func() { assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img})) }() - sbConfig := PodSandboxConfig("sandbox", "sandbox-unknown-state") t.Log("Should not be able to create sandbox without runc") tmpRuncPath := Randomize(runcPath) require.NoError(t, os.Rename(runcPath, tmpRuncPath)) diff --git a/integration/truncindex_test.go b/integration/truncindex_test.go index 54f87be00..1f18ac061 100644 --- a/integration/truncindex_test.go +++ b/integration/truncindex_test.go @@ -29,9 +29,11 @@ func genTruncIndex(normalName string) string { } func TestTruncIndex(t *testing.T) { + sbConfig := PodSandboxConfig("sandbox", "truncindex") + t.Logf("Pull an image") const appImage = "busybox" - imgID, err := imageService.PullImage(&runtimeapi.ImageSpec{Image: appImage}, nil) + imgID, err := imageService.PullImage(&runtimeapi.ImageSpec{Image: appImage}, nil, sbConfig) require.NoError(t, err) imgTruncId := genTruncIndex(imgID) defer func() { @@ -54,7 +56,6 @@ func TestTruncIndex(t *testing.T) { // TODO(yanxuean): add test case for ListImages t.Logf("Create a sandbox") - sbConfig := PodSandboxConfig("sandbox", "truncindex") sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler) require.NoError(t, err) sbTruncIndex := genTruncIndex(sb) diff --git a/integration/volume_copy_up_test.go b/integration/volume_copy_up_test.go index e1e02630e..841567fac 100644 --- a/integration/volume_copy_up_test.go +++ b/integration/volume_copy_up_test.go @@ -43,7 +43,7 @@ func TestVolumeCopyUp(t *testing.T) { }() t.Logf("Pull test image") - _, err = imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + _, err = imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) t.Logf("Create a container with volume-copy-up test image") @@ -105,7 +105,7 @@ func TestVolumeOwnership(t *testing.T) { }() t.Logf("Pull test image") - _, err = imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil) + _, err = imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig) require.NoError(t, err) t.Logf("Create a container with volume-ownership test image")