Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Dittamo <[email protected]>
  • Loading branch information
pvditt committed Apr 1, 2024
1 parent d735443 commit 9aa2cf2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1631,25 +1631,49 @@ func TestDemystifyFailure(t *testing.T) {
})

t.Run("GKE kubelet graceful node shutdown", func(t *testing.T) {
containerReason := "some reason"
phaseInfo, err := DemystifyFailure(v1.PodStatus{
Message: "Pod Node is in progress of shutting down, not admitting any new pods",
Reason: "Shutdown",
ContainerStatuses: []v1.ContainerStatus{
{
LastTerminationState: v1.ContainerState{
Terminated: &v1.ContainerStateTerminated{
Reason: containerReason,
ExitCode: SIGKILL,
},
},
},
},
}, pluginsCore.TaskInfo{})
assert.Nil(t, err)
assert.Equal(t, pluginsCore.PhaseRetryableFailure, phaseInfo.Phase())
assert.Equal(t, "Interrupted", phaseInfo.Err().Code)
assert.Equal(t, core.ExecutionError_SYSTEM, phaseInfo.Err().Kind)
assert.Contains(t, phaseInfo.Err().Message, containerReason)
})

t.Run("GKE kubelet graceful node shutdown", func(t *testing.T) {
containerReason := "some reason"
phaseInfo, err := DemystifyFailure(v1.PodStatus{
Message: "Foobar",
Reason: "Terminated",
ContainerStatuses: []v1.ContainerStatus{
{
LastTerminationState: v1.ContainerState{
Terminated: &v1.ContainerStateTerminated{
Reason: containerReason,
ExitCode: SIGKILL,
},
},
},
},
}, pluginsCore.TaskInfo{})
assert.Nil(t, err)
assert.Equal(t, pluginsCore.PhaseRetryableFailure, phaseInfo.Phase())
assert.Equal(t, "Interrupted", phaseInfo.Err().Code)
assert.Equal(t, core.ExecutionError_SYSTEM, phaseInfo.Err().Kind)
assert.Contains(t, phaseInfo.Err().Message, containerReason)
})
}

Expand Down

0 comments on commit 9aa2cf2

Please sign in to comment.