mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 02:38:12 +00:00
check restartpolicy in getFinishTimeFromContainers
This commit is contained in:
@@ -202,6 +202,7 @@ func TestNewBackoffRecord(t *testing.T) {
|
||||
func TestGetFinishedTime(t *testing.T) {
|
||||
defaultTestTime := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
|
||||
defaultTestTimeMinus30s := defaultTestTime.Add(-30 * time.Second)
|
||||
containerRestartPolicyAlways := v1.ContainerRestartPolicyAlways
|
||||
testCases := map[string]struct {
|
||||
pod v1.Pod
|
||||
wantFinishTime time.Time
|
||||
@@ -358,8 +359,16 @@ func TestGetFinishedTime(t *testing.T) {
|
||||
// In this case, init container is stopped after the regular containers.
|
||||
// This is because with the sidecar (restartable init) containers,
|
||||
// sidecar containers will always finish later than regular containers.
|
||||
"Pod with init container and all containers terminated": {
|
||||
"Pod with sidecar container and all containers terminated": {
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
InitContainers: []v1.Container{
|
||||
{
|
||||
Name: "sidecar",
|
||||
RestartPolicy: &containerRestartPolicyAlways,
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: v1.PodStatus{
|
||||
ContainerStatuses: []v1.ContainerStatus{
|
||||
{
|
||||
@@ -370,6 +379,7 @@ func TestGetFinishedTime(t *testing.T) {
|
||||
},
|
||||
InitContainerStatuses: []v1.ContainerStatus{
|
||||
{
|
||||
Name: "sidecar",
|
||||
State: v1.ContainerState{
|
||||
Terminated: &v1.ContainerStateTerminated{FinishedAt: metav1.NewTime(defaultTestTime)},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user