Restart test must run sequentially.
(t *testing.T)
| 34 | // Restart test must run sequentially. |
| 35 | |
| 36 | func TestContainerdRestart(t *testing.T) { |
| 37 | type container struct { |
| 38 | name string |
| 39 | id string |
| 40 | state runtime.ContainerState |
| 41 | } |
| 42 | type sandbox struct { |
| 43 | name string |
| 44 | id string |
| 45 | state runtime.PodSandboxState |
| 46 | containers []container |
| 47 | } |
| 48 | ctx := context.Background() |
| 49 | sandboxNS := "restart-containerd" |
| 50 | sandboxes := []sandbox{ |
| 51 | { |
| 52 | name: "ready-sandbox", |
| 53 | state: runtime.PodSandboxState_SANDBOX_READY, |
| 54 | containers: []container{ |
| 55 | { |
| 56 | name: "created-container", |
| 57 | state: runtime.ContainerState_CONTAINER_CREATED, |
| 58 | }, |
| 59 | { |
| 60 | name: "running-container", |
| 61 | state: runtime.ContainerState_CONTAINER_RUNNING, |
| 62 | }, |
| 63 | { |
| 64 | name: "exited-container", |
| 65 | state: runtime.ContainerState_CONTAINER_EXITED, |
| 66 | }, |
| 67 | }, |
| 68 | }, |
| 69 | { |
| 70 | name: "notready-sandbox", |
| 71 | state: runtime.PodSandboxState_SANDBOX_NOTREADY, |
| 72 | containers: []container{ |
| 73 | { |
| 74 | name: "created-container", |
| 75 | state: runtime.ContainerState_CONTAINER_CREATED, |
| 76 | }, |
| 77 | { |
| 78 | name: "exited-container", |
| 79 | state: runtime.ContainerState_CONTAINER_EXITED, |
| 80 | }, |
| 81 | }, |
| 82 | }, |
| 83 | } |
| 84 | // NOTE(claudiub): The test will set the container's Linux.SecurityContext.NamespaceOptions.Pid = NamespaceMode_CONTAINER, |
| 85 | // and the expectation is that the container will keep running even if the sandbox container dies. |
| 86 | // We do not have that option on Windows. |
| 87 | if goruntime.GOOS != "windows" { |
| 88 | sandboxes[1].containers = append(sandboxes[1].containers, container{ |
| 89 | name: "running-container", |
| 90 | state: runtime.ContainerState_CONTAINER_RUNNING, |
| 91 | }) |
| 92 | } |
| 93 |
nothing calls this directly
no test coverage detected
searching dependent graphs…