From c8a0c4bee32d989f97f237d9da23c6de981bb1c3 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Tue, 5 May 2026 11:11:40 +0000 Subject: [PATCH] Fix flaky TestSchedulerRestartWithNominatedNode --- .../nominated_node_name/nominated_node_name_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/scheduler/nominated_node_name/nominated_node_name_test.go b/test/integration/scheduler/nominated_node_name/nominated_node_name_test.go index 58eb66b1185..58a0e12600f 100644 --- a/test/integration/scheduler/nominated_node_name/nominated_node_name_test.go +++ b/test/integration/scheduler/nominated_node_name/nominated_node_name_test.go @@ -828,17 +828,23 @@ func TestSchedulerRestartWithNominatedNode(t *testing.T) { pls = append(pls, mockQueueSort, mockPreBind) pls = append(pls, additionalPlugins...) registry, prof := schedulerutils.InitRegistryAndConfig(t, nil, pls...) - return schedulerutils.InitTestSchedulerForFrameworkTest(t, testContext, 0, + testCtx, teardown := schedulerutils.InitTestSchedulerForFrameworkTest(t, testContext, 0, false, /* do not run scheduler immediately after init */ scheduler.WithProfiles(prof), scheduler.WithFrameworkOutOfTreeRegistry(registry), ) + // Ensure both nodes are in the cache before proceeding + if err := testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, 2); err != nil { + t.Fatalf("Failed to wait for nodes in cache: %v", err) + } + return testCtx, teardown } // To allow triggering scheduler restart in binding phase, we need to initialize the scheduler // and pass the testCtx.SchedulerCloseFn to the bind plugin before calling Scheduler.Run. mockBind := &mockBindPlugin{} testCtx, _ := initSched(mockBind) + // This will fail the binding cycle and stop the scheduler // Scheduler should set NNN for podA before this step. mockBind.bindFn = func() *fwk.Status {