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 <Kirtana.Ashok@microsoft.com>
This commit is contained in:
Kirtana Ashok
2023-04-05 15:30:28 -07:00
parent 2503bef581
commit e0b817ec15
3 changed files with 7 additions and 5 deletions

View File

@@ -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)
}