cleanup the ci about interpreter-interpret-health test

Signed-off-by: yike21 <yike21@qq.com>
This commit is contained in:
yike21 2023-06-10 20:21:36 +08:00
parent f385694e3f
commit 3c312b7d30
2 changed files with 14 additions and 17 deletions

View File

@ -43,21 +43,6 @@ func UpdateDeploymentPaused(client kubernetes.Interface, deployment *appsv1.Depl
})
}
// UpdateDeploymentStatus updates the Deployment status.
func UpdateDeploymentStatus(client kubernetes.Interface, deployment *appsv1.Deployment) {
ginkgo.By(fmt.Sprintf("Update Deployment(%s/%s) status", deployment.Namespace, deployment.Name), func() {
gomega.Eventually(func() error {
deploy, err := client.AppsV1().Deployments(deployment.Namespace).Get(context.TODO(), deployment.Name, metav1.GetOptions{})
if err != nil {
return err
}
deploy.Status = deployment.Status
_, err = client.AppsV1().Deployments(deploy.Namespace).UpdateStatus(context.TODO(), deploy, metav1.UpdateOptions{})
return err
}, pollTimeout, pollInterval).ShouldNot(gomega.HaveOccurred())
})
}
// RemoveDeployment delete Deployment.
func RemoveDeployment(client kubernetes.Interface, namespace, name string) {
ginkgo.By(fmt.Sprintf("Removing Deployment(%s/%s)", namespace, name), func() {
@ -90,6 +75,19 @@ func WaitDeploymentPresentOnClustersFitWith(clusters []string, namespace, name s
})
}
// WaitDeploymentStatus wait the deployment on the cluster to have the specified replicas
func WaitDeploymentStatus(client kubernetes.Interface, deployment *appsv1.Deployment, replicas int32) {
ginkgo.By(fmt.Sprintf("Waiting for deployment(%s/%s) status to have %d replicas", deployment.Namespace, deployment.Name, replicas), func() {
gomega.Eventually(func() bool {
deploy, err := client.AppsV1().Deployments(deployment.Namespace).Get(context.TODO(), deployment.Name, metav1.GetOptions{})
if err != nil {
return false
}
return CheckDeploymentReadyStatus(deploy, replicas)
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
})
}
// WaitDeploymentDisappearOnCluster wait deployment disappear on cluster until timeout.
func WaitDeploymentDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterClient(cluster)

View File

@ -611,8 +611,7 @@ var _ = framework.SerialDescribe("Resource interpreter customization testing", f
memberDeployment = deployment
return true
})
memberDeployment.Status.ReadyReplicas = readyReplicas
framework.UpdateDeploymentStatus(clusterClient, memberDeployment)
framework.WaitDeploymentStatus(clusterClient, memberDeployment, readyReplicas)
}
CheckResult := func(result workv1alpha2.ResourceHealth) interface{} {