From ff983bbfbf21c248b8ee90acc4187eefc841b717 Mon Sep 17 00:00:00 2001 From: googs1025 Date: Tue, 20 Aug 2024 09:07:48 +0800 Subject: [PATCH] scheduler(queue): fix flake test for InFlightPods --- pkg/scheduler/internal/queue/scheduling_queue_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 013d33aa202..e78be3d2163 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -675,6 +675,7 @@ func Test_InFlightPods(t *testing.T) { } fakeClock := testingclock.NewFakeClock(time.Now()) q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), obj, WithQueueingHintMapPerProfile(test.queueingHintMap), WithClock(fakeClock)) + sortOpt := cmpopts.SortSlices(func(a, b string) bool { return a < b }) // When a Pod is added to the queue, the QueuedPodInfo will have a new timestamp. // On Windows, time.Now() is not as precise, 2 consecutive calls may return the same timestamp. @@ -734,7 +735,7 @@ func Test_InFlightPods(t *testing.T) { for _, pod := range pods { podNames = append(podNames, pod.Name) } - if diff := cmp.Diff(test.wantActiveQPodNames, podNames); diff != "" { + if diff := cmp.Diff(test.wantActiveQPodNames, podNames, sortOpt); diff != "" { t.Fatalf("Unexpected diff of activeQ pod names (-want, +got):\n%s", diff) } @@ -752,7 +753,7 @@ func Test_InFlightPods(t *testing.T) { for _, pInfo := range podInfos { podNames = append(podNames, pInfo.Pod.Name) } - if diff := cmp.Diff(test.wantBackoffQPodNames, podNames); diff != "" { + if diff := cmp.Diff(test.wantBackoffQPodNames, podNames, sortOpt); diff != "" { t.Fatalf("Unexpected diff of backoffQ pod names (-want, +got):\n%s", diff) }