MCPcopy
hub / github.com/containerd/containerd / runExecAndRemoveContainer

Function runExecAndRemoveContainer

integration/windows_hostprocess_test.go:130–150  ·  view source on GitHub ↗
(t *testing.T, sb string, sbConfig *runtime.PodSandboxConfig, cnConfig *runtime.ContainerConfig)

Source from the content-addressed store, hash-verified

128}
129
130func runExecAndRemoveContainer(t *testing.T, sb string, sbConfig *runtime.PodSandboxConfig, cnConfig *runtime.ContainerConfig) {
131 t.Log("Create the container")
132 cn, err := runtimeService.CreateContainer(sb, cnConfig, sbConfig)
133 require.NoError(t, err)
134 t.Log("Start the container")
135 require.NoError(t, runtimeService.StartContainer(cn))
136 // Wait few seconds for the container to be completely initialized
137 time.Sleep(5 * time.Second)
138
139 cmd := []string{"cmd", "/c", "echo", "hello"}
140 timeoutDuration := 10 * time.Second
141 stdout, _, err := runtimeService.ExecSync(cn, cmd, timeoutDuration)
142 require.NoError(t, err)
143 t.Logf("Exec response: %v", stdout)
144 require.Equal(t, "hello\r\n", string(stdout))
145
146 t.Log("Stop the container")
147 require.NoError(t, runtimeService.StopContainer(cn, 0))
148 t.Log("Remove the container")
149 require.NoError(t, runtimeService.RemoveContainer(cn))
150}
151
152func TestArgsEscapedImagesOnWindows(t *testing.T) {
153 // the ArgsEscaped test image is based on nanoserver:ltsc2022, so ensure we run on the correct OS version

Callers 1

Calls 6

LogMethod · 0.80
CreateContainerMethod · 0.65
StartContainerMethod · 0.65
StopContainerMethod · 0.65
RemoveContainerMethod · 0.65
ExecSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…