(t *testing.T, expectErr bool, image string, action hpcAction, opts ...ContainerOpts)
| 99 | } |
| 100 | |
| 101 | func runHostProcess(t *testing.T, expectErr bool, image string, action hpcAction, opts ...ContainerOpts) { |
| 102 | t.Logf("Create a pod config and run sandbox container") |
| 103 | sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox1", "hostprocess", WithWindowsHostProcessPod) |
| 104 | |
| 105 | t.Logf("Create a container config and run container in a pod") |
| 106 | containerConfig := ContainerConfig( |
| 107 | "container1", |
| 108 | image, |
| 109 | opts..., |
| 110 | ) |
| 111 | cn, err := runtimeService.CreateContainer(sb, containerConfig, sbConfig) |
| 112 | require.NoError(t, err) |
| 113 | defer func() { |
| 114 | assert.NoError(t, runtimeService.RemoveContainer(cn)) |
| 115 | }() |
| 116 | _, err = t, runtimeService.StartContainer(cn) |
| 117 | if err != nil { |
| 118 | if !expectErr { |
| 119 | t.Fatalf("Unexpected error while starting Container: %v", err) |
| 120 | } |
| 121 | return |
| 122 | } |
| 123 | defer func() { |
| 124 | assert.NoError(t, runtimeService.StopContainer(cn, 10)) |
| 125 | }() |
| 126 | |
| 127 | action(t, cn, containerConfig) |
| 128 | } |
| 129 | |
| 130 | func runExecAndRemoveContainer(t *testing.T, sb string, sbConfig *runtime.PodSandboxConfig, cnConfig *runtime.ContainerConfig) { |
| 131 | t.Log("Create the container") |
no test coverage detected
searching dependent graphs…