Blob Blame Raw
From 0580ce45fd7c5c630361e5cf1ac9ffed3a7eb8be Mon Sep 17 00:00:00 2001
From: Lantao Liu <lantaol@google.com>
Date: Fri, 5 Oct 2018 11:01:20 -0700
Subject: [PATCH] Update test based on new CRI.

Signed-off-by: Lantao Liu <lantaol@google.com>
---
 integration/addition_gids_test.go              |  2 +-
 integration/container_log_test.go              |  2 +-
 integration/container_stats_test.go            | 10 +++++-----
 integration/container_update_resources_test.go |  2 +-
 integration/containerd_image_test.go           |  2 +-
 integration/duplicate_name_test.go             |  4 ++--
 integration/image_load_test.go                 |  2 +-
 integration/imagefs_info_test.go               |  2 +-
 integration/pod_hostname_env_test.go           |  2 +-
 integration/restart_test.go                    |  2 +-
 integration/sandbox_clean_remove_test.go       |  2 +-
 integration/test_utils.go                      |  1 +
 integration/truncindex_test.go                 |  2 +-
 integration/volume_copy_up_test.go             |  4 ++--
 14 files changed, 20 insertions(+), 19 deletions(-)

diff -up cri-1.11.1/integration/container_log_test.go.new_cri cri-1.11.1/integration/container_log_test.go
--- cri-1.11.1/integration/container_log_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/container_log_test.go	2019-06-27 19:43:24.228231646 +0200
@@ -39,7 +39,7 @@ func TestLongContainerLog(t *testing.T)
 	sbConfig := PodSandboxConfig("sandbox", "long-container-log",
 		WithPodLogDirectory(testPodLogDir),
 	)
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
diff -up cri-1.11.1/integration/container_stats_test.go.new_cri cri-1.11.1/integration/container_stats_test.go
--- cri-1.11.1/integration/container_stats_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/container_stats_test.go	2019-06-27 19:43:24.232231632 +0200
@@ -31,7 +31,7 @@ import (
 func TestContainerStats(t *testing.T) {
 	t.Logf("Create a pod config and run sandbox container")
 	sbConfig := PodSandboxConfig("sandbox1", "stats")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
@@ -76,7 +76,7 @@ func TestContainerStats(t *testing.T) {
 func TestContainerListStats(t *testing.T) {
 	t.Logf("Create a pod config and run sandbox container")
 	sbConfig := PodSandboxConfig("running-pod", "statsls")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
@@ -131,7 +131,7 @@ func TestContainerListStats(t *testing.T
 func TestContainerListStatsWithIdFilter(t *testing.T) {
 	t.Logf("Create a pod config and run sandbox container")
 	sbConfig := PodSandboxConfig("running-pod", "statsls")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
@@ -191,7 +191,7 @@ func TestContainerListStatsWithIdFilter(
 func TestContainerListStatsWithSandboxIdFilter(t *testing.T) {
 	t.Logf("Create a pod config and run sandbox container")
 	sbConfig := PodSandboxConfig("running-pod", "statsls")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
@@ -247,7 +247,7 @@ func TestContainerListStatsWithSandboxId
 func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
 	t.Logf("Create a pod config and run sandbox container")
 	sbConfig := PodSandboxConfig("running-pod", "statsls")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
diff -up cri-1.11.1/integration/container_update_resources_test.go.new_cri cri-1.11.1/integration/container_update_resources_test.go
--- cri-1.11.1/integration/container_update_resources_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/container_update_resources_test.go	2019-06-27 19:43:24.232231632 +0200
@@ -39,7 +39,7 @@ func checkMemoryLimit(t *testing.T, spec
 func TestUpdateContainerResources(t *testing.T) {
 	t.Log("Create a sandbox")
 	sbConfig := PodSandboxConfig("sandbox", "update-container-resources")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
diff -up cri-1.11.1/integration/duplicate_name_test.go.new_cri cri-1.11.1/integration/duplicate_name_test.go
--- cri-1.11.1/integration/duplicate_name_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/duplicate_name_test.go	2019-06-27 19:43:26.118225186 +0200
@@ -26,7 +26,7 @@ import (
 func TestDuplicateName(t *testing.T) {
 	t.Logf("Create a sandbox")
 	sbConfig := PodSandboxConfig("sandbox", "duplicate-name")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
@@ -34,7 +34,7 @@ func TestDuplicateName(t *testing.T) {
 	}()
 
 	t.Logf("Create the sandbox again should fail")
-	_, err = runtimeService.RunPodSandbox(sbConfig)
+	_, err = runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.Error(t, err)
 
 	t.Logf("Create a container")
diff -up cri-1.11.1/integration/imagefs_info_test.go.new_cri cri-1.11.1/integration/imagefs_info_test.go
--- cri-1.11.1/integration/imagefs_info_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/imagefs_info_test.go	2019-06-27 19:43:26.120225179 +0200
@@ -37,7 +37,7 @@ func TestImageFSInfo(t *testing.T) {
 	}()
 	t.Logf("Create a sandbox to make sure there is an active snapshot")
 	config := PodSandboxConfig("running-pod", "imagefs")
-	sb, err := runtimeService.RunPodSandbox(config)
+	sb, err := runtimeService.RunPodSandbox(config, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
diff -up cri-1.11.1/integration/image_load_test.go.new_cri cri-1.11.1/integration/image_load_test.go
--- cri-1.11.1/integration/image_load_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/image_load_test.go	2019-06-27 19:43:26.119225182 +0200
@@ -70,7 +70,7 @@ func TestImageLoad(t *testing.T) {
 
 	t.Logf("create a container with the loaded image")
 	sbConfig := PodSandboxConfig("sandbox", Randomize("image-load"))
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
diff -up cri-1.11.1/integration/restart_test.go.new_cri cri-1.11.1/integration/restart_test.go
--- cri-1.11.1/integration/restart_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/restart_test.go	2019-06-27 19:43:28.039218619 +0200
@@ -90,7 +90,7 @@ func TestContainerdRestart(t *testing.T)
 	for i := range sandboxes {
 		s := &sandboxes[i]
 		sbCfg := PodSandboxConfig(s.name, sandboxNS)
-		sid, err := runtimeService.RunPodSandbox(sbCfg)
+		sid, err := runtimeService.RunPodSandbox(sbCfg, *runtimeHandler)
 		require.NoError(t, err)
 		defer func() {
 			// Make sure the sandbox is cleaned up in any case.
diff -up cri-1.11.1/integration/sandbox_clean_remove_test.go.new_cri cri-1.11.1/integration/sandbox_clean_remove_test.go
--- cri-1.11.1/integration/sandbox_clean_remove_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/sandbox_clean_remove_test.go	2019-06-27 19:43:28.039218619 +0200
@@ -31,7 +31,7 @@ func TestSandboxCleanRemove(t *testing.T
 	ctx := context.Background()
 	t.Logf("Create a sandbox")
 	sbConfig := PodSandboxConfig("sandbox", "clean-remove")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		// Make sure the sandbox is cleaned up in any case.
diff -up cri-1.11.1/integration/test_utils.go.new_cri cri-1.11.1/integration/test_utils.go
--- cri-1.11.1/integration/test_utils.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/test_utils.go	2019-06-27 19:43:28.040218616 +0200
@@ -58,6 +58,7 @@ var (
 
 var criEndpoint = flag.String("cri-endpoint", "unix:///run/containerd/containerd.sock", "The endpoint of cri plugin.")
 var criRoot = flag.String("cri-root", "/var/lib/containerd/io.containerd.grpc.v1.cri", "The root directory of cri plugin.")
+var runtimeHandler = flag.String("runtime-handler", "", "The runtime handler to use in the test.")
 
 func init() {
 	flag.Parse()
diff -up cri-1.11.1/integration/truncindex_test.go.new_cri cri-1.11.1/integration/truncindex_test.go
--- cri-1.11.1/integration/truncindex_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/truncindex_test.go	2019-06-27 19:43:28.040218616 +0200
@@ -55,7 +55,7 @@ func TestTruncIndex(t *testing.T) {
 
 	t.Logf("Create a sandbox")
 	sbConfig := PodSandboxConfig("sandbox", "truncindex")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	sbTruncIndex := genTruncIndex(sb)
 	var hasStoppedSandbox bool
diff -up cri-1.11.1/integration/volume_copy_up_test.go.new_cri cri-1.11.1/integration/volume_copy_up_test.go
--- cri-1.11.1/integration/volume_copy_up_test.go.new_cri	2018-08-09 20:37:54.000000000 +0200
+++ cri-1.11.1/integration/volume_copy_up_test.go	2019-06-27 19:43:28.041218613 +0200
@@ -35,7 +35,7 @@ func TestVolumeCopyUp(t *testing.T) {
 
 	t.Logf("Create a sandbox")
 	sbConfig := PodSandboxConfig("sandbox", "volume-copy-up")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))
@@ -97,7 +97,7 @@ func TestVolumeOwnership(t *testing.T) {
 
 	t.Logf("Create a sandbox")
 	sbConfig := PodSandboxConfig("sandbox", "volume-ownership")
-	sb, err := runtimeService.RunPodSandbox(sbConfig)
+	sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
 	require.NoError(t, err)
 	defer func() {
 		assert.NoError(t, runtimeService.StopPodSandbox(sb))