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

retry deleting test ns after reconnecting cloud node #1060

Merged
merged 1 commit into from
Nov 16, 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
13 changes: 7 additions & 6 deletions test/e2e/autonomy/autonomy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ var _ = ginkgo.BeforeSuite(func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "fail to get client set")

err = ns.DeleteNameSpace(c, YurtE2ENamespaceName)
util.ExpectNoError(err)
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to delete namespace")
ginkgo.By("create e2e-test namespace")
_, err = ns.CreateNameSpace(c, YurtE2ENamespaceName)
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "fail to create namespaces")
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "fail to create namespace")

// get nginx podIP on edge node worker2
cs := c
Expand Down Expand Up @@ -251,13 +251,14 @@ var _ = ginkgo.BeforeSuite(func() {
var _ = ginkgo.AfterSuite(func() {
// reconnect cloud node to docker network
cmd := exec.Command("/bin/bash", "-c", "docker network connect kind "+YurtCloudNodeName)
error := cmd.Run()
gomega.Expect(error).NotTo(gomega.HaveOccurred(), "fail to reconnect cloud node to kind bridge")
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "fail to reconnect cloud node to kind bridge")
klog.Infof("successfully reconnected cloud node")

ginkgo.By("delete namespace:" + YurtE2ENamespaceName)
err = ns.DeleteNameSpace(c, YurtE2ENamespaceName)
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "fail to delete created namespaces")
gomega.Eventually(func() error {
return ns.DeleteNameSpace(c, YurtE2ENamespaceName)
}).WithTimeout(10 * time.Second).WithPolling(1 * time.Second).Should(gomega.Succeed())
Congrool marked this conversation as resolved.
Show resolved Hide resolved
})

func TestEdgeAutonomy(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/common/ns/ns.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package ns
import (
"context"

"github.com/onsi/gomega"
apiv1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -33,8 +32,8 @@ func DeleteNameSpace(c clientset.Interface, ns string) (err error) {
err = c.CoreV1().Namespaces().Delete(context.Background(), ns, metav1.DeleteOptions{
PropagationPolicy: &deletePolicy,
})
if !apierrs.IsNotFound(err) {
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "fail to delete created namespaces:"+ns)
if err != nil && !apierrs.IsNotFound(err) {
return
}
err = util.WaitForNamespacesDeleted(c, []string{ns}, util.DefaultNamespaceDeletionTimeout)
return
Expand Down