From 151ac846a29c705b5ffd7b2aa03b04c84d2cd0fc Mon Sep 17 00:00:00 2001 From: dom4ha Date: Thu, 26 Sep 2024 01:08:38 +0000 Subject: [PATCH 1/3] Increase the readability of the test preconditions and double check that all test pods are really unschedulable. --- test/integration/scheduler/queue_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/integration/scheduler/queue_test.go b/test/integration/scheduler/queue_test.go index 735b81d0028..fe896595b06 100644 --- a/test/integration/scheduler/queue_test.go +++ b/test/integration/scheduler/queue_test.go @@ -954,27 +954,30 @@ func TestCoreResourceEnqueue(t *testing.T) { } } - // Wait for the tt.pods to be present in the scheduling queue. + // Wait for the tt.pods to be present in the scheduling active queue. if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*200, wait.ForeverTestTimeout, false, func(ctx context.Context) (bool, error) { - pendingPods, _ := testCtx.Scheduler.SchedulingQueue.PendingPods() - return len(pendingPods) == len(tt.pods), nil + return len(testCtx.Scheduler.SchedulingQueue.PodsInActiveQ()) == len(tt.pods), nil }); err != nil { t.Fatal(err) } t.Log("Confirmed Pods in the scheduling queue, starting to schedule them") - // Pop all pods out. They should be unschedulable. + // Pop all pods out. They should become unschedulable. for i := 0; i < len(tt.pods); i++ { testCtx.Scheduler.ScheduleOne(testCtx.Ctx) } - // Wait for the tt.pods to be still present in the scheduling queue. + // Wait for the tt.pods to be still present in the scheduling (unschedulable) queue. if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*200, wait.ForeverTestTimeout, false, func(ctx context.Context) (bool, error) { pendingPods, _ := testCtx.Scheduler.SchedulingQueue.PendingPods() return len(pendingPods) == len(tt.pods), nil }); err != nil { t.Fatal(err) } + activePodsCount := len(testCtx.Scheduler.SchedulingQueue.PodsInActiveQ()) + if activePodsCount > 0 { + t.Fatalf("Active queue was expected to be empty, but found %v Pods", activePodsCount) + } t.Log("finished initial schedulings for all Pods, will trigger triggerFn") From 54b0ed45b76a07edbcd986695bc878cad99d483a Mon Sep 17 00:00:00 2001 From: dom4ha Date: Thu, 26 Sep 2024 09:15:54 +0000 Subject: [PATCH 2/3] Add one more check to the test case precondition assessment. --- test/integration/scheduler/queue_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/scheduler/queue_test.go b/test/integration/scheduler/queue_test.go index fe896595b06..8b0f09f368e 100644 --- a/test/integration/scheduler/queue_test.go +++ b/test/integration/scheduler/queue_test.go @@ -956,7 +956,8 @@ func TestCoreResourceEnqueue(t *testing.T) { // Wait for the tt.pods to be present in the scheduling active queue. if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*200, wait.ForeverTestTimeout, false, func(ctx context.Context) (bool, error) { - return len(testCtx.Scheduler.SchedulingQueue.PodsInActiveQ()) == len(tt.pods), nil + pendingPods, _ := testCtx.Scheduler.SchedulingQueue.PendingPods() + return len(pendingPods) == len(tt.pods) && len(testCtx.Scheduler.SchedulingQueue.PodsInActiveQ()) == len(tt.pods), nil }); err != nil { t.Fatal(err) } From 9bf6ee976bc0b5fb7e3d55734fcfa5c0e681105a Mon Sep 17 00:00:00 2001 From: dom4ha Date: Fri, 27 Sep 2024 15:05:47 +0000 Subject: [PATCH 3/3] Assert whethere there are no pod in active queue while waiting for all pods to get scheduled instead of asserting it afterwards. --- test/integration/scheduler/queue_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/integration/scheduler/queue_test.go b/test/integration/scheduler/queue_test.go index 8b0f09f368e..4e5da499c1f 100644 --- a/test/integration/scheduler/queue_test.go +++ b/test/integration/scheduler/queue_test.go @@ -970,15 +970,16 @@ func TestCoreResourceEnqueue(t *testing.T) { } // Wait for the tt.pods to be still present in the scheduling (unschedulable) queue. if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*200, wait.ForeverTestTimeout, false, func(ctx context.Context) (bool, error) { + activePodsCount := len(testCtx.Scheduler.SchedulingQueue.PodsInActiveQ()) + if activePodsCount > 0 { + return false, fmt.Errorf("Active queue was expected to be empty, but found %v Pods", activePodsCount) + } + pendingPods, _ := testCtx.Scheduler.SchedulingQueue.PendingPods() return len(pendingPods) == len(tt.pods), nil }); err != nil { t.Fatal(err) } - activePodsCount := len(testCtx.Scheduler.SchedulingQueue.PodsInActiveQ()) - if activePodsCount > 0 { - t.Fatalf("Active queue was expected to be empty, but found %v Pods", activePodsCount) - } t.Log("finished initial schedulings for all Pods, will trigger triggerFn")