mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
integration: start informer and scheduler outside of InitTestScheduler
In case two or more controllers share the informers created through InitTestScheduler, it's not safe to start the informers until all controllers set their informer indexers. Otherwise, some controller might fail to register their indexers in time. Thus, it's responsibility of each consumer to make sure all informers are started after all controllers had time to get initiliazed.
This commit is contained in:
@@ -79,15 +79,21 @@ func initDisruptionController(t *testing.T, testCtx *testutils.TestContext) *dis
|
||||
// initTest initializes a test environment and creates master and scheduler with default
|
||||
// configuration.
|
||||
func initTest(t *testing.T, nsPrefix string, opts ...scheduler.Option) *testutils.TestContext {
|
||||
return testutils.InitTestSchedulerWithOptions(t, testutils.InitTestMaster(t, nsPrefix, nil), true, nil, time.Second, opts...)
|
||||
testCtx := testutils.InitTestSchedulerWithOptions(t, testutils.InitTestMaster(t, nsPrefix, nil), true, nil, time.Second, opts...)
|
||||
testutils.SyncInformerFactory(testCtx)
|
||||
go testCtx.Scheduler.Run(testCtx.Ctx)
|
||||
return testCtx
|
||||
}
|
||||
|
||||
// initTestDisablePreemption initializes a test environment and creates master and scheduler with default
|
||||
// configuration but with pod preemption disabled.
|
||||
func initTestDisablePreemption(t *testing.T, nsPrefix string) *testutils.TestContext {
|
||||
return testutils.InitTestSchedulerWithOptions(
|
||||
testCtx := testutils.InitTestSchedulerWithOptions(
|
||||
t, testutils.InitTestMaster(t, nsPrefix, nil), true, nil,
|
||||
time.Second, scheduler.WithPreemptionDisabled(true))
|
||||
testutils.SyncInformerFactory(testCtx)
|
||||
go testCtx.Scheduler.Run(testCtx.Ctx)
|
||||
return testCtx
|
||||
}
|
||||
|
||||
// waitForReflection waits till the passFunc confirms that the object it expects
|
||||
|
||||
Reference in New Issue
Block a user