From e0b817ec1535b73cb4915fa8abacb0454c7f8862 Mon Sep 17 00:00:00 2001 From: Kirtana Ashok Date: Wed, 5 Apr 2023 15:30:28 -0700 Subject: [PATCH] Fix argsEscaped tests - Rename test name - Add a tag to the container image used in the tests instead of the latest tag - Add a 5 second delay between container start and stop to ensure that the container is fully initialized Signed-off-by: Kirtana Ashok --- integration/images/image_list.go | 2 +- integration/images/image_list.sample.toml | 2 +- integration/windows_hostprocess_test.go | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/integration/images/image_list.go b/integration/images/image_list.go index ccdd373b7..0232a787d 100644 --- a/integration/images/image_list.go +++ b/integration/images/image_list.go @@ -54,7 +54,7 @@ func initImages(imageListFile string) { ResourceConsumer: "registry.k8s.io/e2e-test-images/resource-consumer:1.10", VolumeCopyUp: "ghcr.io/containerd/volume-copy-up:2.1", VolumeOwnership: "ghcr.io/containerd/volume-ownership:2.1", - ArgsEscaped: "cplatpublic.azurecr.io/args-escaped-test-image-ns:latest", + ArgsEscaped: "cplatpublic.azurecr.io/args-escaped-test-image-ns:1.0", } if imageListFile != "" { diff --git a/integration/images/image_list.sample.toml b/integration/images/image_list.sample.toml index b317d43a5..a19961bf1 100644 --- a/integration/images/image_list.sample.toml +++ b/integration/images/image_list.sample.toml @@ -3,4 +3,4 @@ busybox = "docker.io/library/busybox:latest" pause = "registry.k8s.io/pause:3.7" VolumeCopyUp = "ghcr.io/containerd/volume-copy-up:2.1" VolumeOwnership = "ghcr.io/containerd/volume-ownership:2.1" -ArgsEscaped = "cplatpublic.azurecr.io/args-escaped-test-image-ns:latest" +ArgsEscaped = "cplatpublic.azurecr.io/args-escaped-test-image-ns:1.0" diff --git a/integration/windows_hostprocess_test.go b/integration/windows_hostprocess_test.go index 7176d163f..650126d64 100644 --- a/integration/windows_hostprocess_test.go +++ b/integration/windows_hostprocess_test.go @@ -127,12 +127,14 @@ func runHostProcess(t *testing.T, expectErr bool, image string, action hpcAction action(t, cn, containerConfig) } -func startAndTestContainer(t *testing.T, sb string, sbConfig *runtime.PodSandboxConfig, cnConfig *runtime.ContainerConfig) { +func runAndRemoveContainer(t *testing.T, sb string, sbConfig *runtime.PodSandboxConfig, cnConfig *runtime.ContainerConfig) { t.Log("Create the container") cn, err := runtimeService.CreateContainer(sb, cnConfig, sbConfig) require.NoError(t, err) t.Log("Start the container") require.NoError(t, runtimeService.StartContainer(cn)) + // Wait few seconds for the container to be completely initialized + time.Sleep(5 * time.Second) t.Log("Stop the container") require.NoError(t, runtimeService.StopContainer(cn, 0)) @@ -185,6 +187,6 @@ func TestArgsEscapedImagesOnWindows(t *testing.T) { localSystemUsername, ) - startAndTestContainer(t, sb, sbConfig, cnConfigWithCtrCmd) - startAndTestContainer(t, sb, sbConfig, cnConfigNoCtrCmd) + runAndRemoveContainer(t, sb, sbConfig, cnConfigWithCtrCmd) + runAndRemoveContainer(t, sb, sbConfig, cnConfigNoCtrCmd) }