mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Store config args instead of config factory in test context
Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
parent
8e9af0185d
commit
0ce1c95232
@ -354,7 +354,7 @@ func TestUnschedulableNodes(t *testing.T) {
|
|||||||
context := initTest(t, "unschedulable-nodes")
|
context := initTest(t, "unschedulable-nodes")
|
||||||
defer cleanupTest(t, context)
|
defer cleanupTest(t, context)
|
||||||
|
|
||||||
nodeLister := context.schedulerConfig.NodeLister
|
nodeLister := context.schedulerConfigArgs.NodeInformer.Lister()
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (Nodes).
|
// non-namespaced objects (Nodes).
|
||||||
defer context.clientSet.CoreV1().Nodes().DeleteCollection(nil, metav1.ListOptions{})
|
defer context.clientSet.CoreV1().Nodes().DeleteCollection(nil, metav1.ListOptions{})
|
||||||
@ -605,8 +605,8 @@ func TestMultiScheduler(t *testing.T) {
|
|||||||
stopCh := make(chan struct{})
|
stopCh := make(chan struct{})
|
||||||
defer close(stopCh)
|
defer close(stopCh)
|
||||||
|
|
||||||
schedulerConfigFactory2 := createConfiguratorWithPodInformer(fooScheduler, clientSet2, podInformer2, informerFactory2, schedulerframework.NewRegistry(),
|
schedulerConfigFactory2 := factory.NewConfigFactory(createConfiguratorArgsWithPodInformer(fooScheduler, clientSet2, podInformer2, informerFactory2, schedulerframework.NewRegistry(),
|
||||||
nil, []kubeschedulerconfig.PluginConfig{}, stopCh)
|
nil, []kubeschedulerconfig.PluginConfig{}, stopCh))
|
||||||
schedulerConfig2, err := schedulerConfigFactory2.Create()
|
schedulerConfig2, err := schedulerConfigFactory2.Create()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create scheduler config: %v", err)
|
t.Errorf("Couldn't create scheduler config: %v", err)
|
||||||
|
@ -66,14 +66,14 @@ type testContext struct {
|
|||||||
ns *v1.Namespace
|
ns *v1.Namespace
|
||||||
clientSet *clientset.Clientset
|
clientSet *clientset.Clientset
|
||||||
informerFactory informers.SharedInformerFactory
|
informerFactory informers.SharedInformerFactory
|
||||||
schedulerConfigFactory factory.Configurator
|
schedulerConfigArgs *factory.ConfigFactoryArgs
|
||||||
schedulerConfig *factory.Config
|
schedulerConfig *factory.Config
|
||||||
scheduler *scheduler.Scheduler
|
scheduler *scheduler.Scheduler
|
||||||
stopCh chan struct{}
|
stopCh chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// createConfiguratorWithPodInformer creates a configurator for scheduler.
|
// createConfiguratorWithPodInformer creates a configurator for scheduler.
|
||||||
func createConfiguratorWithPodInformer(
|
func createConfiguratorArgsWithPodInformer(
|
||||||
schedulerName string,
|
schedulerName string,
|
||||||
clientSet clientset.Interface,
|
clientSet clientset.Interface,
|
||||||
podInformer coreinformers.PodInformer,
|
podInformer coreinformers.PodInformer,
|
||||||
@ -82,8 +82,8 @@ func createConfiguratorWithPodInformer(
|
|||||||
plugins *schedulerconfig.Plugins,
|
plugins *schedulerconfig.Plugins,
|
||||||
pluginConfig []schedulerconfig.PluginConfig,
|
pluginConfig []schedulerconfig.PluginConfig,
|
||||||
stopCh <-chan struct{},
|
stopCh <-chan struct{},
|
||||||
) factory.Configurator {
|
) *factory.ConfigFactoryArgs {
|
||||||
return factory.NewConfigFactory(&factory.ConfigFactoryArgs{
|
return &factory.ConfigFactoryArgs{
|
||||||
SchedulerName: schedulerName,
|
SchedulerName: schedulerName,
|
||||||
Client: clientSet,
|
Client: clientSet,
|
||||||
NodeInformer: informerFactory.Core().V1().Nodes(),
|
NodeInformer: informerFactory.Core().V1().Nodes(),
|
||||||
@ -105,7 +105,7 @@ func createConfiguratorWithPodInformer(
|
|||||||
PercentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
|
PercentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
|
||||||
BindTimeoutSeconds: 600,
|
BindTimeoutSeconds: 600,
|
||||||
StopCh: stopCh,
|
StopCh: stopCh,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// initTestMasterAndScheduler initializes a test environment and creates a master with default
|
// initTestMasterAndScheduler initializes a test environment and creates a master with default
|
||||||
@ -186,16 +186,17 @@ func initTestSchedulerWithOptions(
|
|||||||
podInformer = context.informerFactory.Core().V1().Pods()
|
podInformer = context.informerFactory.Core().V1().Pods()
|
||||||
}
|
}
|
||||||
|
|
||||||
context.schedulerConfigFactory = createConfiguratorWithPodInformer(
|
context.schedulerConfigArgs = createConfiguratorArgsWithPodInformer(
|
||||||
v1.DefaultSchedulerName, context.clientSet, podInformer, context.informerFactory, pluginRegistry, plugins,
|
v1.DefaultSchedulerName, context.clientSet, podInformer, context.informerFactory, pluginRegistry, plugins,
|
||||||
pluginConfig, context.stopCh)
|
pluginConfig, context.stopCh)
|
||||||
|
configFactory := factory.NewConfigFactory(context.schedulerConfigArgs)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if policy != nil {
|
if policy != nil {
|
||||||
context.schedulerConfig, err = context.schedulerConfigFactory.CreateFromConfig(*policy)
|
context.schedulerConfig, err = configFactory.CreateFromConfig(*policy)
|
||||||
} else {
|
} else {
|
||||||
context.schedulerConfig, err = context.schedulerConfigFactory.Create()
|
context.schedulerConfig, err = configFactory.Create()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user