MCPcopy
hub / github.com/kubernetes/kubernetes / TestDeletePod

Function TestDeletePod

pkg/scheduler/eventhandlers_test.go:1037–1142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1035}
1036
1037func TestDeletePod(t *testing.T) {
1038 pod := st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").SchedulerName("supported-scheduler").Obj()
1039 otherPod := st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").SchedulerName("other-scheduler").Obj()
1040 scheduledPod := st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Node("node1").SchedulerName("supported-scheduler").Obj()
1041 otherScheduledPod := st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Node("node1").SchedulerName("other-scheduler").Obj()
1042
1043 tests := []struct {
1044 name string
1045 initialPod *v1.Pod
1046 assumed bool
1047 waitingOnPermit bool
1048 podToDelete any
1049 }{
1050 {
1051 name: "delete unscheduled pod",
1052 initialPod: pod,
1053 podToDelete: pod,
1054 },
1055 {
1056 name: "delete unscheduled pod with other scheduler name",
1057 initialPod: otherPod,
1058 podToDelete: otherPod,
1059 },
1060 {
1061 name: "delete unscheduled pod with unknown state",
1062 initialPod: pod,
1063 podToDelete: cache.DeletedFinalStateUnknown{Obj: pod},
1064 },
1065 {
1066 name: "delete assumed pod",
1067 initialPod: scheduledPod,
1068 assumed: true,
1069 podToDelete: pod,
1070 },
1071 {
1072 name: "delete scheduled pod",
1073 initialPod: scheduledPod,
1074 podToDelete: scheduledPod,
1075 },
1076 {
1077 name: "delete scheduled pod with other scheduler name",
1078 initialPod: otherScheduledPod,
1079 podToDelete: otherScheduledPod,
1080 },
1081 {
1082 name: "delete scheduled pod with unknown state",
1083 initialPod: scheduledPod,
1084 podToDelete: cache.DeletedFinalStateUnknown{Obj: scheduledPod},
1085 },
1086 {
1087 name: "delete scheduled pod with unknown older state",
1088 initialPod: scheduledPod,
1089 podToDelete: cache.DeletedFinalStateUnknown{Obj: pod},
1090 },
1091 }
1092 for _, tt := range tests {
1093 t.Run(tt.name, func(t *testing.T) {
1094 logger, ctx := ktesting.NewTestContext(t)

Callers

nothing calls this directly

Calls 15

addPodMethod · 0.95
deletePodMethod · 0.95
WithCancelMethod · 0.80
ObjMethod · 0.65
SchedulerNameMethod · 0.65
UIDMethod · 0.65
NamespaceMethod · 0.65
NameMethod · 0.65
NodeMethod · 0.65
RunMethod · 0.65
FatalfMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…