Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E2E] log more err info when wait resource exist on member clusters #1848

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions test/e2e/framework/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ func WaitDeploymentDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for deployment disappear on cluster(%s)", cluster)
klog.Infof("Waiting for deployment(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.AppsV1().Deployments(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get deployment(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
12 changes: 10 additions & 2 deletions test/e2e/framework/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ func WaitJobDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for job disappear on cluster(%s)", cluster)
klog.Infof("Waiting for job(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.BatchV1().Jobs(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get job(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
12 changes: 10 additions & 2 deletions test/e2e/framework/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,18 @@ func WaitNamespaceDisappearOnCluster(cluster, name string) {
clusterClient := GetClusterClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for namespace disappear on cluster(%s)", cluster)
klog.Infof("Waiting for namespace(%s) disappear on cluster(%s)", name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.CoreV1().Namespaces().Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get namespace(%s) on cluster(%s), err: %v", name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
12 changes: 10 additions & 2 deletions test/e2e/framework/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ func WaitPodDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for pod disappear on cluster(%s)", cluster)
klog.Infof("Waiting for pod(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get pod(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
10 changes: 9 additions & 1 deletion test/e2e/framework/resourcequota.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func WaitResourceQuotaDisappearOnCluster(cluster, namespace, name string) {
klog.Infof("Waiting for resourceQuota(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.CoreV1().ResourceQuotas(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get resourceQuota(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}
12 changes: 10 additions & 2 deletions test/e2e/framework/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ func WaitSecretDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for secret disappear on cluster(%s)", cluster)
klog.Infof("Waiting for secret(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.CoreV1().Secrets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get secret(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
12 changes: 10 additions & 2 deletions test/e2e/framework/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ func WaitServiceDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for service disappear on cluster(%s)", cluster)
klog.Infof("Waiting for service(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.CoreV1().Services(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get service(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
12 changes: 10 additions & 2 deletions test/e2e/framework/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,18 @@ func WaitWorkloadDisappearOnCluster(cluster, namespace, name string) {
clusterClient := GetClusterDynamicClient(cluster)
gomega.Expect(clusterClient).ShouldNot(gomega.BeNil())

klog.Infof("Waiting for workload disappear on cluster(%s)", cluster)
klog.Infof("Waiting for workload(%s/%s) disappear on cluster(%s)", namespace, name, cluster)
gomega.Eventually(func() bool {
_, err := clusterClient.Resource(workloadGVR).Namespace(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return apierrors.IsNotFound(err)
if err == nil {
return false
}
if apierrors.IsNotFound(err) {
return true
}

klog.Errorf("Failed to get workload(%s/%s) on cluster(%s), err: %v", namespace, name, cluster, err)
return false
}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var _ = ginkgo.Describe("[resource-status collection] resource status collection

ginkgo.BeforeEach(func() {
policyNamespace = testNamespace
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
policyName = serviceNamePrefix + rand.String(RandomStrLength)
serviceNamespace = testNamespace
serviceName = policyName

Expand Down