Merge pull request #5933 from zhzhuang-zju/ctl-top

fix flake test of KarmadactlTopPod
This commit is contained in:
karmada-bot 2024-12-10 20:45:14 +08:00 committed by GitHub
commit 8457cd2f64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -544,10 +544,12 @@ var _ = ginkgo.Describe("Karmadactl top testing", func() {
ginkgo.It("Karmadactl top pod which does not exist", func() { ginkgo.It("Karmadactl top pod which does not exist", func() {
podName := podNamePrefix + rand.String(RandomStrLength) podName := podNamePrefix + rand.String(RandomStrLength)
for _, clusterName := range framework.ClusterNames() { for _, clusterName := range framework.ClusterNames() {
gomega.Eventually(func() bool {
cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, "", karmadactlTimeout, "top", "pod", podName, "-n", testNamespace, "-C", clusterName) cmd := framework.NewKarmadactlCommand(kubeconfig, karmadaContext, karmadactlPath, "", karmadactlTimeout, "top", "pod", podName, "-n", testNamespace, "-C", clusterName)
_, err := cmd.ExecOrDie() _, err := cmd.ExecOrDie()
gomega.Expect(err).Should(gomega.HaveOccurred()) fmt.Printf("Should receive a NotFound error, and actually received: %+v\n", err)
gomega.Expect(strings.Contains(err.Error(), fmt.Sprintf("pods \"%s\" not found", podName))).To(gomega.BeTrue(), "should not found", fmt.Sprintf("errMsg: %s", err.Error())) return err != nil && strings.Contains(err.Error(), fmt.Sprintf("pods \"%s\" not found", podName))
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
} }
}) })
}) })