Store config args instead of config factory in test context

Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
Aldo Culquicondor 2019-07-23 14:29:19 -04:00
parent 8e9af0185d
commit 0ce1c95232
2 changed files with 20 additions and 19 deletions

View File

@ -354,7 +354,7 @@ func TestUnschedulableNodes(t *testing.T) {
context := initTest(t, "unschedulable-nodes")
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
// non-namespaced objects (Nodes).
defer context.clientSet.CoreV1().Nodes().DeleteCollection(nil, metav1.ListOptions{})
@ -605,8 +605,8 @@ func TestMultiScheduler(t *testing.T) {
stopCh := make(chan struct{})
defer close(stopCh)
schedulerConfigFactory2 := createConfiguratorWithPodInformer(fooScheduler, clientSet2, podInformer2, informerFactory2, schedulerframework.NewRegistry(),
nil, []kubeschedulerconfig.PluginConfig{}, stopCh)
schedulerConfigFactory2 := factory.NewConfigFactory(createConfiguratorArgsWithPodInformer(fooScheduler, clientSet2, podInformer2, informerFactory2, schedulerframework.NewRegistry(),
nil, []kubeschedulerconfig.PluginConfig{}, stopCh))
schedulerConfig2, err := schedulerConfigFactory2.Create()
if err != nil {
t.Errorf("Couldn't create scheduler config: %v", err)

View File

@ -61,19 +61,19 @@ import (
)
type testContext struct {
closeFn framework.CloseFunc
httpServer *httptest.Server
ns *v1.Namespace
clientSet *clientset.Clientset
informerFactory informers.SharedInformerFactory
schedulerConfigFactory factory.Configurator
schedulerConfig *factory.Config
scheduler *scheduler.Scheduler
stopCh chan struct{}
closeFn framework.CloseFunc
httpServer *httptest.Server
ns *v1.Namespace
clientSet *clientset.Clientset
informerFactory informers.SharedInformerFactory
schedulerConfigArgs *factory.ConfigFactoryArgs
schedulerConfig *factory.Config
scheduler *scheduler.Scheduler
stopCh chan struct{}
}
// createConfiguratorWithPodInformer creates a configurator for scheduler.
func createConfiguratorWithPodInformer(
func createConfiguratorArgsWithPodInformer(
schedulerName string,
clientSet clientset.Interface,
podInformer coreinformers.PodInformer,
@ -82,8 +82,8 @@ func createConfiguratorWithPodInformer(
plugins *schedulerconfig.Plugins,
pluginConfig []schedulerconfig.PluginConfig,
stopCh <-chan struct{},
) factory.Configurator {
return factory.NewConfigFactory(&factory.ConfigFactoryArgs{
) *factory.ConfigFactoryArgs {
return &factory.ConfigFactoryArgs{
SchedulerName: schedulerName,
Client: clientSet,
NodeInformer: informerFactory.Core().V1().Nodes(),
@ -105,7 +105,7 @@ func createConfiguratorWithPodInformer(
PercentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
BindTimeoutSeconds: 600,
StopCh: stopCh,
})
}
}
// initTestMasterAndScheduler initializes a test environment and creates a master with default
@ -186,16 +186,17 @@ func initTestSchedulerWithOptions(
podInformer = context.informerFactory.Core().V1().Pods()
}
context.schedulerConfigFactory = createConfiguratorWithPodInformer(
context.schedulerConfigArgs = createConfiguratorArgsWithPodInformer(
v1.DefaultSchedulerName, context.clientSet, podInformer, context.informerFactory, pluginRegistry, plugins,
pluginConfig, context.stopCh)
configFactory := factory.NewConfigFactory(context.schedulerConfigArgs)
var err error
if policy != nil {
context.schedulerConfig, err = context.schedulerConfigFactory.CreateFromConfig(*policy)
context.schedulerConfig, err = configFactory.CreateFromConfig(*policy)
} else {
context.schedulerConfig, err = context.schedulerConfigFactory.Create()
context.schedulerConfig, err = configFactory.Create()
}
if err != nil {