mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 22:05:25 +00:00
Skip uninstall and resource cleanup when fail-fast is enabled.
Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
@@ -67,7 +67,14 @@ func APIExtensionsVersionsTest() {
|
||||
})
|
||||
})
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
By(fmt.Sprintf("Switch to default kubeconfig context %s", veleroCfg.DefaultClusterContext), func() {
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
|
||||
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
|
||||
})
|
||||
|
||||
if CurrentSpecReport().Failed() && veleroCfg.FailFast {
|
||||
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
|
||||
} else {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||
})
|
||||
@@ -86,10 +93,6 @@ func APIExtensionsVersionsTest() {
|
||||
Expect(DeleteCRDByName(context.Background(), crdName)).To(Succeed())
|
||||
})
|
||||
}
|
||||
By(fmt.Sprintf("Switch to default kubeconfig context %s", veleroCfg.DefaultClusterContext), func() {
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
|
||||
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
|
||||
})
|
||||
}
|
||||
})
|
||||
Context("When EnableAPIGroupVersions flag is set", func() {
|
||||
|
||||
@@ -79,7 +79,9 @@ func APIGroupVersionsTest() {
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
if CurrentSpecReport().Failed() && veleroCfg.FailFast {
|
||||
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
|
||||
} else {
|
||||
for i := 0; i < testCaseNum; i++ {
|
||||
curResource := fmt.Sprintf("rockband%ds", i)
|
||||
curGroup := fmt.Sprintf("%s.%d", group, i)
|
||||
|
||||
@@ -116,7 +116,9 @@ func (n *NamespaceMapping) Verify() error {
|
||||
}
|
||||
|
||||
func (n *NamespaceMapping) Clean() error {
|
||||
if !n.VeleroCfg.Debug {
|
||||
if CurrentSpecReport().Failed() && n.VeleroCfg.FailFast {
|
||||
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
|
||||
} else {
|
||||
if err := DeleteStorageClass(context.Background(), n.Client, KibishiiStorageClassName); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -128,5 +130,6 @@ func (n *NamespaceMapping) Clean() error {
|
||||
|
||||
return n.GetTestCase().Clean()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -149,11 +149,14 @@ func (p *PVCSelectedNodeChanging) Verify() error {
|
||||
}
|
||||
|
||||
func (p *PVCSelectedNodeChanging) Clean() error {
|
||||
if !p.VeleroCfg.Debug {
|
||||
if CurrentSpecReport().Failed() && p.VeleroCfg.FailFast {
|
||||
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
|
||||
} else {
|
||||
p.TestCase.Clean()
|
||||
By(fmt.Sprintf("Clean namespace with prefix %s after test", p.mappedNS), func() {
|
||||
CleanupNamespaces(p.Ctx, p.Client, p.mappedNS)
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||
@@ -176,8 +177,11 @@ func (r *RBACCase) Destroy() error {
|
||||
}
|
||||
|
||||
func (r *RBACCase) Clean() error {
|
||||
if !r.VeleroCfg.Debug {
|
||||
if CurrentSpecReport().Failed() && r.VeleroCfg.FailFast {
|
||||
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
|
||||
} else {
|
||||
return r.Destroy()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -142,7 +142,9 @@ func (s *StorageClasssChanging) Verify() error {
|
||||
}
|
||||
|
||||
func (s *StorageClasssChanging) Clean() error {
|
||||
if !s.VeleroCfg.Debug {
|
||||
if CurrentSpecReport().Failed() && s.VeleroCfg.FailFast {
|
||||
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
|
||||
} else {
|
||||
By(fmt.Sprintf("Start to destroy namespace %s......", s.CaseBaseName), func() {
|
||||
Expect(CleanupNamespacesWithPoll(s.Ctx, s.Client, s.CaseBaseName)).To(Succeed(),
|
||||
fmt.Sprintf("Failed to delete namespace %s", s.CaseBaseName))
|
||||
@@ -151,5 +153,6 @@ func (s *StorageClasssChanging) Clean() error {
|
||||
DeleteStorageClass(s.Ctx, s.Client, s.desStorageClass)
|
||||
s.TestCase.Clean()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user