test: Use dedicated informerFactory for node lifecycle controller

This commit is contained in:
Wei Huang 2020-05-07 15:01:55 -07:00
parent eec809aa93
commit fc11871c61
No known key found for this signature in database
GPG Key ID: BE5E9752F8B6E005
2 changed files with 12 additions and 14 deletions

View File

@ -134,7 +134,6 @@ func TestTaintBasedEvictions(t *testing.T) {
testCtx = testutils.InitTestScheduler(t, testCtx, true, nil)
defer testutils.CleanupTest(t, testCtx)
cs := testCtx.ClientSet
informers := testCtx.InformerFactory
_, err := cs.CoreV1().Namespaces().Create(context.TODO(), testCtx.NS, metav1.CreateOptions{})
if err != nil {
t.Errorf("Failed to create namespace %+v", err)
@ -142,10 +141,10 @@ func TestTaintBasedEvictions(t *testing.T) {
// Start NodeLifecycleController for taint.
nc, err := nodelifecycle.NewNodeLifecycleController(
informers.Coordination().V1().Leases(),
informers.Core().V1().Pods(),
informers.Core().V1().Nodes(),
informers.Apps().V1().DaemonSets(),
externalInformers.Coordination().V1().Leases(),
externalInformers.Core().V1().Pods(),
externalInformers.Core().V1().Nodes(),
externalInformers.Apps().V1().DaemonSets(),
cs,
5*time.Second, // Node monitor grace period
time.Minute, // Node startup grace period
@ -167,8 +166,8 @@ func TestTaintBasedEvictions(t *testing.T) {
// Waiting for all controller sync.
externalInformers.Start(testCtx.Ctx.Done())
externalInformers.WaitForCacheSync(testCtx.Ctx.Done())
informers.Start(testCtx.Ctx.Done())
informers.WaitForCacheSync(testCtx.Ctx.Done())
testCtx.InformerFactory.Start(testCtx.Ctx.Done())
testCtx.InformerFactory.WaitForCacheSync(testCtx.Ctx.Done())
nodeRes := v1.ResourceList{
v1.ResourceCPU: resource.MustParse("4000m"),

View File

@ -79,15 +79,14 @@ func TestTaintNodeByCondition(t *testing.T) {
defer testutils.CleanupTest(t, testCtx)
cs := testCtx.ClientSet
informers := testCtx.InformerFactory
nsName := testCtx.NS.Name
// Start NodeLifecycleController for taint.
nc, err := nodelifecycle.NewNodeLifecycleController(
informers.Coordination().V1().Leases(),
informers.Core().V1().Pods(),
informers.Core().V1().Nodes(),
informers.Apps().V1().DaemonSets(),
externalInformers.Coordination().V1().Leases(),
externalInformers.Core().V1().Pods(),
externalInformers.Core().V1().Nodes(),
externalInformers.Apps().V1().DaemonSets(),
cs,
time.Hour, // Node monitor grace period
time.Second, // Node startup grace period
@ -108,8 +107,8 @@ func TestTaintNodeByCondition(t *testing.T) {
// Waiting for all controller sync.
externalInformers.Start(testCtx.Ctx.Done())
externalInformers.WaitForCacheSync(testCtx.Ctx.Done())
informers.Start(testCtx.Ctx.Done())
informers.WaitForCacheSync(testCtx.Ctx.Done())
testCtx.InformerFactory.Start(testCtx.Ctx.Done())
testCtx.InformerFactory.WaitForCacheSync(testCtx.Ctx.Done())
// -------------------------------------------
// Test TaintNodeByCondition feature.