Merge pull request #2147 from lonelyCZ/pr-fix-kubeclient

[E2E] Fix check whether deployment propagated to member cluster
This commit is contained in:
karmada-bot 2022-07-07 21:47:36 +08:00 committed by GitHub
commit 348baf041c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -337,7 +337,7 @@ var _ = framework.SerialDescribe("Karmadactl unjoin testing", ginkgo.Labels{Need
},
}, policyv1alpha1.Placement{
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
ClusterNames: []string{deploymentName},
ClusterNames: []string{clusterName},
},
})
karmadaConfig = karmadactl.NewKarmadaConfig(clientcmd.NewDefaultPathOptions())
@ -380,8 +380,13 @@ var _ = framework.SerialDescribe("Karmadactl unjoin testing", ginkgo.Labels{Need
})
ginkgo.By("Waiting for deployment have been propagated to the member cluster.", func() {
klog.Infof("Waiting for deployment(%s/%s) synced on cluster(%s)", deploymentNamespace, deploymentName, clusterName)
clusterConfig, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
clusterClient := kubernetes.NewForConfigOrDie(clusterConfig)
gomega.Eventually(func() bool {
_, err := kubeClient.AppsV1().Deployments(deploymentNamespace).Get(context.TODO(), deploymentName, metav1.GetOptions{})
_, err := clusterClient.AppsV1().Deployments(deploymentNamespace).Get(context.TODO(), deploymentName, metav1.GetOptions{})
return err == nil
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
})