MCPcopy
hub / github.com/kubernetes/kubernetes / TestUpdatePodStatus

Function TestUpdatePodStatus

pkg/scheduler/schedule_one_test.go:2431–2683  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2429}
2430
2431func TestUpdatePodStatus(t *testing.T) {
2432 tests := []struct {
2433 name string
2434 currentPodConditions []v1.PodCondition
2435 newPodCondition *v1.PodCondition
2436 currentNominatedNodeName string
2437 newNominatingInfo *fwk.NominatingInfo
2438 expectPatchRequest bool
2439 expectedPatchDataPattern string
2440 }{
2441 {
2442 name: "Should make patch request to add pod condition when there are none currently",
2443 currentPodConditions: []v1.PodCondition{},
2444 newPodCondition: &v1.PodCondition{
2445 Type: "newType",
2446 Status: "newStatus",
2447 LastProbeTime: metav1.NewTime(time.Date(2020, 5, 13, 1, 1, 1, 1, time.UTC)),
2448 LastTransitionTime: metav1.NewTime(time.Date(2020, 5, 12, 1, 1, 1, 1, time.UTC)),
2449 Reason: "newReason",
2450 Message: "newMessage",
2451 },
2452 expectPatchRequest: true,
2453 expectedPatchDataPattern: `{"status":{"conditions":\[{"lastProbeTime":"2020-05-13T01:01:01Z","lastTransitionTime":".*","message":"newMessage","reason":"newReason","status":"newStatus","type":"newType"}]}}`,
2454 },
2455 {
2456 name: "Should make patch request to add a new pod condition when there is already one with another type",
2457 currentPodConditions: []v1.PodCondition{
2458 {
2459 Type: "someOtherType",
2460 Status: "someOtherTypeStatus",
2461 LastProbeTime: metav1.NewTime(time.Date(2020, 5, 11, 0, 0, 0, 0, time.UTC)),
2462 LastTransitionTime: metav1.NewTime(time.Date(2020, 5, 10, 0, 0, 0, 0, time.UTC)),
2463 Reason: "someOtherTypeReason",
2464 Message: "someOtherTypeMessage",
2465 },
2466 },
2467 newPodCondition: &v1.PodCondition{
2468 Type: "newType",
2469 Status: "newStatus",
2470 LastProbeTime: metav1.NewTime(time.Date(2020, 5, 13, 1, 1, 1, 1, time.UTC)),
2471 LastTransitionTime: metav1.NewTime(time.Date(2020, 5, 12, 1, 1, 1, 1, time.UTC)),
2472 Reason: "newReason",
2473 Message: "newMessage",
2474 },
2475 expectPatchRequest: true,
2476 expectedPatchDataPattern: `{"status":{"\$setElementOrder/conditions":\[{"type":"someOtherType"},{"type":"newType"}],"conditions":\[{"lastProbeTime":"2020-05-13T01:01:01Z","lastTransitionTime":".*","message":"newMessage","reason":"newReason","status":"newStatus","type":"newType"}]}}`,
2477 },
2478 {
2479 name: "Should make patch request to update an existing pod condition",
2480 currentPodConditions: []v1.PodCondition{
2481 {
2482 Type: "currentType",
2483 Status: "currentStatus",
2484 LastProbeTime: metav1.NewTime(time.Date(2020, 5, 13, 0, 0, 0, 0, time.UTC)),
2485 LastTransitionTime: metav1.NewTime(time.Date(2020, 5, 12, 0, 0, 0, 0, time.UTC)),
2486 Reason: "currentReason",
2487 Message: "currentMessage",
2488 },

Callers

nothing calls this directly

Calls 15

NewMetricsAsyncRecorderFunction · 0.92
ConditionsMethod · 0.80
NominatedNodeNameMethod · 0.80
WithCancelMethod · 0.80
MatchStringMethod · 0.80
updatePodFunction · 0.70
RunMethod · 0.65
AddReactorMethod · 0.65
GetPatchMethod · 0.65
ObjMethod · 0.65
NameMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…