Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: changzhen <[email protected]>
  • Loading branch information
XiShanYongYe-Chang committed Jul 19, 2024
1 parent 32924ad commit 2f39909
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions test/e2e/framework/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ func WaitClusterFitWith(c client.Client, clusterName string, fit func(cluster *c
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

// WaitClusterFitWith01 wait cluster fit with fit func.
func WaitClusterFitWith01(c karmada.Interface, clusterName string, fit func(cluster *clusterv1alpha1.Cluster) bool) {
gomega.Eventually(func() (bool, error) {
currentCluster, _, err := util.GetClusterWithKarmadaClient(c, clusterName)
if err != nil {
return false, err
}
return fit(currentCluster), nil
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

// LoadRESTClientConfig creates a rest.Config using the passed kubeconfig. If context is empty, current context in kubeconfig will be used.
func LoadRESTClientConfig(kubeconfig string, context string) (*rest.Config, error) {
loader := &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/remedy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = framework.SerialDescribe("remedy testing", func() {
})

ginkgo.By(fmt.Sprintf("wait Cluster(%s) status has TrafficControl RemedyAction", targetCluster), func() {
framework.WaitClusterFitWith(controlPlaneClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
framework.WaitClusterFitWith01(karmadaClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
actions := sets.NewString(cluster.Status.RemedyActions...)
fmt.Printf("Cluster(%s) remedyActions: %v\n", cluster.Name, actions)
return actions.Has(string(remedyv1alpha1.TrafficControl))
Expand All @@ -85,7 +85,7 @@ var _ = framework.SerialDescribe("remedy testing", func() {
})

ginkgo.By(fmt.Sprintf("wait Cluster(%s) status doesn't has TrafficControl RemedyAction", targetCluster), func() {
framework.WaitClusterFitWith(controlPlaneClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
framework.WaitClusterFitWith01(karmadaClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
actions := sets.NewString(cluster.Status.RemedyActions...)
fmt.Printf("Cluster(%s) remedyActions: %v\n", cluster.Name, actions)
return !actions.Has(string(remedyv1alpha1.TrafficControl))
Expand All @@ -106,7 +106,7 @@ var _ = framework.SerialDescribe("remedy testing", func() {
})

ginkgo.By(fmt.Sprintf("wait Cluster(%s) status has TrafficControl RemedyAction", targetCluster), func() {
framework.WaitClusterFitWith(controlPlaneClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
framework.WaitClusterFitWith01(karmadaClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
actions := sets.NewString(cluster.Status.RemedyActions...)
fmt.Printf("Cluster(%s) remedyActions: %v\n", cluster.Name, actions)
return actions.Has(string(remedyv1alpha1.TrafficControl))
Expand All @@ -118,7 +118,7 @@ var _ = framework.SerialDescribe("remedy testing", func() {
})

ginkgo.By(fmt.Sprintf("wait Cluster(%s) status doesn't has TrafficControl RemedyAction", targetCluster), func() {
framework.WaitClusterFitWith(controlPlaneClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
framework.WaitClusterFitWith01(karmadaClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
actions := sets.NewString(cluster.Status.RemedyActions...)
fmt.Printf("Cluster(%s) remedyActions: %v\n", cluster.Name, actions)
return !actions.Has(string(remedyv1alpha1.TrafficControl))
Expand Down Expand Up @@ -155,7 +155,7 @@ var _ = framework.SerialDescribe("remedy testing", func() {
})

ginkgo.By(fmt.Sprintf("wait Cluster(%s) status has TrafficControl RemedyAction", targetCluster), func() {
framework.WaitClusterFitWith(controlPlaneClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
framework.WaitClusterFitWith01(karmadaClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
actions := sets.NewString(cluster.Status.RemedyActions...)
fmt.Printf("Cluster(%s) remedyActions: %v\n", cluster.Name, actions)
return actions.Has(string(remedyv1alpha1.TrafficControl))
Expand All @@ -167,7 +167,7 @@ var _ = framework.SerialDescribe("remedy testing", func() {
})

ginkgo.By(fmt.Sprintf("wait Cluster(%s) status doesn't has TrafficControl RemedyAction", targetCluster), func() {
framework.WaitClusterFitWith(controlPlaneClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
framework.WaitClusterFitWith01(karmadaClient, targetCluster, func(cluster *clusterv1alpha1.Cluster) bool {
actions := sets.NewString(cluster.Status.RemedyActions...)
fmt.Printf("Cluster(%s) remedyActions: %v\n", cluster.Name, actions)
return !actions.Has(string(remedyv1alpha1.TrafficControl))
Expand Down

0 comments on commit 2f39909

Please sign in to comment.