From e8c41b8892a63a26873645f822018a631a3484d2 Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Thu, 8 Aug 2019 07:27:27 +0000 Subject: [PATCH] Remove printOnce() on e2e tests Originally, printOnce() was implemented for printing debugging message once for checking actual value is the same as expected value. However even if an error doesn't happen in ExpectEqual(), printOnce() is called internally. Then the second ExpectEqual() doesn't output the debugging message if an error happens. This makes debugging difficult, let's just remove it for debugging. --- test/e2e/scheduling/predicates.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index e0202e79c87..805f365d0f2 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -745,17 +745,8 @@ func verifyResult(c clientset.Interface, expectedScheduled int, expectedNotSched framework.ExpectNoError(err) scheduledPods, notScheduledPods := e2epod.GetPodsScheduled(masterNodes, allPods) - printed := false - printOnce := func(msg string) string { - if !printed { - printed = true - return msg - } - return "" - } - - framework.ExpectEqual(len(notScheduledPods), expectedNotScheduled, printOnce(fmt.Sprintf("Not scheduled Pods: %#v", notScheduledPods))) - framework.ExpectEqual(len(scheduledPods), expectedScheduled, printOnce(fmt.Sprintf("Scheduled Pods: %#v", scheduledPods))) + framework.ExpectEqual(len(notScheduledPods), expectedNotScheduled, fmt.Sprintf("Not scheduled Pods: %#v", notScheduledPods)) + framework.ExpectEqual(len(scheduledPods), expectedScheduled, fmt.Sprintf("Scheduled Pods: %#v", scheduledPods)) } // verifyReplicasResult is wrapper of verifyResult for a group pods with same "name: labelName" label, which means they belong to same RC @@ -763,17 +754,8 @@ func verifyReplicasResult(c clientset.Interface, expectedScheduled int, expected allPods := getPodsByLabels(c, ns, map[string]string{"name": labelName}) scheduledPods, notScheduledPods := e2epod.GetPodsScheduled(masterNodes, allPods) - printed := false - printOnce := func(msg string) string { - if !printed { - printed = true - return msg - } - return "" - } - - framework.ExpectEqual(len(notScheduledPods), expectedNotScheduled, printOnce(fmt.Sprintf("Not scheduled Pods: %#v", notScheduledPods))) - framework.ExpectEqual(len(scheduledPods), expectedScheduled, printOnce(fmt.Sprintf("Scheduled Pods: %#v", scheduledPods))) + framework.ExpectEqual(len(notScheduledPods), expectedNotScheduled, fmt.Sprintf("Not scheduled Pods: %#v", notScheduledPods)) + framework.ExpectEqual(len(scheduledPods), expectedScheduled, fmt.Sprintf("Scheduled Pods: %#v", scheduledPods)) } func getPodsByLabels(c clientset.Interface, ns string, labelsMap map[string]string) *v1.PodList {