Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc225af9

Browse files
authored
Merge pull request#133047 from pohly/test-integration-scheduler-startup
scheduler integration: fail test instead of existing
2 parents20b601c +729cd58 commitc225af9

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

‎test/integration/dra/dra_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ type schedulerSingleton struct {
434434
mutex sync.Mutex
435435
usageCountint
436436
informerFactory informers.SharedInformerFactory
437-
cancelfunc(errerror)
437+
cancelfunc(causestring)
438438
}
439439

440440
func (scheduler*schedulerSingleton)start(tCtx ktesting.TContext,configstring) {
@@ -452,13 +452,14 @@ func (scheduler *schedulerSingleton) start(tCtx ktesting.TContext, config string
452452
// Run scheduler with default configuration. This must use the root context because
453453
// the per-test tCtx passed to start will get canceled once the test which triggered
454454
// starting the scheduler is done.
455-
schedulerCtx:=scheduler.rootCtx
456-
schedulerCtx.Logf("Starting the scheduler for test %s...",tCtx.Name())
457-
ctx:=klog.NewContext(schedulerCtx,klog.LoggerWithName(schedulerCtx.Logger(),"scheduler"))
458-
ctx,scheduler.cancel=context.WithCancelCause(ctx)
455+
tCtx=scheduler.rootCtx
456+
tCtx.Logf("Starting the scheduler for test %s...",tCtx.Name())
457+
tCtx=ktesting.WithLogger(tCtx,klog.LoggerWithName(tCtx.Logger(),"scheduler"))
458+
schedulerCtx:=ktesting.WithCancel(tCtx)
459+
scheduler.cancel=schedulerCtx.Cancel
459460
cfg:=newSchedulerComponentConfig(schedulerCtx,config)
460-
_,scheduler.informerFactory=util.StartScheduler(ctx,schedulerCtx.Client(),schedulerCtx.RESTConfig(),cfg,nil)
461-
schedulerCtx.Logf("Started the scheduler for test %s.",tCtx.Name())
461+
_,scheduler.informerFactory=util.StartScheduler(schedulerCtx,cfg,nil)
462+
tCtx.Logf("Started the scheduler for test %s.",tCtx.Name())
462463
}
463464

464465
func (scheduler*schedulerSingleton)stop(tCtx ktesting.TContext) {
@@ -473,7 +474,7 @@ func (scheduler *schedulerSingleton) stop(tCtx ktesting.TContext) {
473474

474475
scheduler.rootCtx.Logf("Stopping the scheduler after test %s...",tCtx.Name())
475476
ifscheduler.cancel!=nil {
476-
scheduler.cancel(errors.New("test is done"))
477+
scheduler.cancel("test is done")
477478
}
478479
ifscheduler.informerFactory!=nil {
479480
scheduler.informerFactory.Shutdown()

‎test/integration/scheduler_perf/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func mustSetupCluster(tCtx ktesting.TContext, config *config.KubeSchedulerConfig
131131

132132
// Not all config options will be effective but only those mostly related with scheduler performance will
133133
// be applied to start a scheduler, most of them are defined in `scheduler.schedulerOptions`.
134-
_,informerFactory:=util.StartScheduler(tCtx,tCtx.Client(),cfg,config,outOfTreePluginRegistry)
134+
_,informerFactory:=util.StartScheduler(tCtx,config,outOfTreePluginRegistry)
135135
util.StartFakePVController(tCtx,tCtx.Client(),informerFactory)
136136
runGC:=util.CreateGCController(tCtx,tCtx,*cfg,informerFactory)
137137
runNS:=util.CreateNamespaceController(tCtx,tCtx,*cfg,informerFactory)

‎test/integration/util/util.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,27 @@ type ShutdownFunc func()
8383
// StartScheduler configures and starts a scheduler given a handle to the clientSet interface
8484
// and event broadcaster. It returns the running scheduler and podInformer. Background goroutines
8585
// will keep running until the context is canceled.
86-
funcStartScheduler(ctx context.Context,clientSet clientset.Interface,kubeConfig*restclient.Config,cfg*kubeschedulerconfig.KubeSchedulerConfiguration,outOfTreePluginRegistry frameworkruntime.Registry) (*scheduler.Scheduler, informers.SharedInformerFactory) {
86+
funcStartScheduler(tCtx ktesting.TContext,cfg*kubeschedulerconfig.KubeSchedulerConfiguration,outOfTreePluginRegistry frameworkruntime.Registry) (*scheduler.Scheduler, informers.SharedInformerFactory) {
87+
clientSet:=tCtx.Client()
8788
informerFactory:=scheduler.NewInformerFactory(clientSet,0)
8889
evtBroadcaster:=events.NewBroadcaster(&events.EventSinkImpl{
8990
Interface:clientSet.EventsV1()})
9091
gofunc() {
91-
<-ctx.Done()
92+
<-tCtx.Done()
9293
evtBroadcaster.Shutdown()
9394
}()
9495

95-
evtBroadcaster.StartRecordingToSink(ctx.Done())
96+
evtBroadcaster.StartRecordingToSink(tCtx.Done())
9697

97-
logger:=klog.FromContext(ctx)
98+
logger:=tCtx.Logger()
9899

99100
sched,err:=scheduler.New(
100-
ctx,
101+
tCtx,
101102
clientSet,
102103
informerFactory,
103104
nil,
104105
profile.NewRecorderFactory(evtBroadcaster),
105-
scheduler.WithKubeConfig(kubeConfig),
106+
scheduler.WithKubeConfig(tCtx.RESTConfig()),
106107
scheduler.WithProfiles(cfg.Profiles...),
107108
scheduler.WithPercentageOfNodesToScore(cfg.PercentageOfNodesToScore),
108109
scheduler.WithPodMaxBackoffSeconds(cfg.PodMaxBackoffSeconds),
@@ -111,19 +112,14 @@ func StartScheduler(ctx context.Context, clientSet clientset.Interface, kubeConf
111112
scheduler.WithParallelism(cfg.Parallelism),
112113
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreePluginRegistry),
113114
)
114-
iferr!=nil {
115-
logger.Error(err,"Error creating scheduler")
116-
klog.FlushAndExit(klog.ExitFlushTimeout,1)
117-
}
115+
tCtx.ExpectNoError(err,"creating scheduler")
118116

119-
informerFactory.Start(ctx.Done())
120-
informerFactory.WaitForCacheSync(ctx.Done())
121-
iferr=sched.WaitForHandlersSync(ctx);err!=nil {
122-
logger.Error(err,"Failed waiting for handlers to sync")
123-
klog.FlushAndExit(klog.ExitFlushTimeout,1)
124-
}
117+
informerFactory.Start(tCtx.Done())
118+
informerFactory.WaitForCacheSync(tCtx.Done())
119+
err=sched.WaitForHandlersSync(tCtx)
120+
tCtx.ExpectNoError(err,"waiting for handlers to sync")
125121
logger.V(3).Info("Handlers synced")
126-
gosched.Run(ctx)
122+
gosched.Run(tCtx)
127123

128124
returnsched,informerFactory
129125
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp