From a48c597eb610e6d499aa56ca65abaf070f38962d Mon Sep 17 00:00:00 2001 From: changluyi <47097611+changluyi@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:59:40 +0800 Subject: [PATCH] fix ic e2e (#3831) * fix e2e Signed-off-by: Changlu Yi * fix Signed-off-by: Changlu Yi --------- Signed-off-by: Changlu Yi --- test/e2e/ovn-ic/e2e_test.go | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/test/e2e/ovn-ic/e2e_test.go b/test/e2e/ovn-ic/e2e_test.go index 92c875079f5..15690c68553 100644 --- a/test/e2e/ovn-ic/e2e_test.go +++ b/test/e2e/ovn-ic/e2e_test.go @@ -347,16 +347,29 @@ var _ = framework.SerialDescribe("[group:ovn-ic]", func() { func checkECMPCount(expectCount int) { ecmpCount := 0 maxRetryTimes := 30 - for i := 0; i < maxRetryTimes; i++ { - time.Sleep(3 * time.Second) - execCmd := "kubectl ko nbctl lr-route-list ovn-cluster " - output, err := exec.Command("bash", "-c", execCmd).CombinedOutput() - framework.ExpectNoError(err) - ecmpCount = strings.Count(string(output), "ecmp") - if ecmpCount == expectCount { - break + + for _, cluster := range clusters { + clusterName := "kind-" + cluster + ginkgo.By("Switching kubectl config context to " + clusterName) + switchCmd := "kubectl config use-context " + clusterName + _, err := exec.Command("bash", "-c", switchCmd).CombinedOutput() + framework.ExpectNoError(err, "failed to switch kubectl config context to %s", clusterName) + + ginkgo.By("Checking logical router route count") + for i := 0; i < maxRetryTimes; i++ { + time.Sleep(3 * time.Second) + execCmd := "kubectl ko nbctl lr-route-list ovn-cluster " + output, err := exec.Command("bash", "-c", execCmd).CombinedOutput() + framework.ExpectNoError(err) + ecmpCount = strings.Count(string(output), "ecmp") + if ecmpCount == expectCount { + break + } } + framework.ExpectEqual(ecmpCount, expectCount) } - framework.ExpectEqual(ecmpCount, expectCount) + switchCmd := "kubectl config use-context kind-kube-ovn" + _, err := exec.Command("bash", "-c", switchCmd).CombinedOutput() + framework.ExpectNoError(err, "switch to kube-ovn cluster failed") }