Add debug switcher for E2E test

Signed-off-by: danfengl <danfengl@vmware.com>
This commit is contained in:
danfengl
2022-04-06 03:53:20 +00:00
parent 4f358af902
commit 7b35f94f84
12 changed files with 56 additions and 28 deletions

View File

@@ -84,6 +84,7 @@ ADDITIONAL_BSL_PREFIX ?=
ADDITIONAL_BSL_CONFIG ?=
FEATURES ?=
DEBUG_E2E_TEST ?= false
.PHONY:ginkgo
ginkgo: # Make sure ginkgo is in $GOPATH/bin
@@ -121,7 +122,8 @@ run: ginkgo
-features=$(FEATURES) \
-install-velero=$(INSTALL_VELERO) \
-registry-credential-file=$(REGISTRY_CREDENTIAL_FILE) \
-kibishii-directory=$(KIBISHII_DIRECTORY)
-kibishii-directory=$(KIBISHII_DIRECTORY) \
-debug-e2e-test=$(DEBUG_E2E_TEST)
build: ginkgo
mkdir -p $(OUTPUT_DIR)

View File

@@ -60,13 +60,12 @@ func BackupRestoreTest(useVolumeSnapshots bool) {
})
AfterEach(func() {
DeleteNamespace(context.Background(), client, kibishiiNamespace, true)
Expect(err).To(Succeed(), fmt.Sprintf("failed to delete the namespace %q", kibishiiNamespace))
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
err = VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)
Expect(err).To(Succeed())
}
}
})
When("kibishii is the sample workload", func() {

View File

@@ -67,9 +67,11 @@ func backup_deletion_test(useVolumeSnapshots bool) {
AfterEach(func() {
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
err = VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)
Expect(err).To(Succeed())
}
}
})
When("kibishii is the sample workload", func() {

View File

@@ -67,8 +67,10 @@ func BackupsSyncTest() {
AfterEach(func() {
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
}
}
})
It("Backups in object storage should be synced to a new Velero successfully", func() {

View File

@@ -76,9 +76,11 @@ func APIGropuVersionsTest() {
Expect(err).NotTo(HaveOccurred())
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
err = VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)
Expect(err).NotTo(HaveOccurred())
}
}
})

View File

@@ -70,12 +70,14 @@ func BslDeletionTest(useVolumeSnapshots bool) {
AfterEach(func() {
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
Expect(DeleteNamespace(context.Background(), client, bslDeletionTestNs,
true)).To(Succeed(), fmt.Sprintf("failed to delete the namespace %q",
bslDeletionTestNs))
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI,
VeleroCfg.VeleroNamespace)).To(Succeed())
}
}
})
When("kibishii is the sample workload", func() {

View File

@@ -64,6 +64,7 @@ func init() {
flag.StringVar(&VeleroCfg.AdditionalBSLConfig, "additional-bsl-config", "", "configuration to use for the additional backup storage location. Format is key1=value1,key2=value2")
flag.StringVar(&VeleroCfg.AdditionalBSLCredentials, "additional-bsl-credentials-file", "", "file containing credentials for additional backup storage location provider. Required if testing multiple credentials support.")
flag.StringVar(&VeleroCfg.Features, "features", "", "Comma-separated list of features to enable for this Velero process.")
flag.BoolVar(&VeleroCfg.Debug, "debug-e2e-test", false, "Switch to control namespace cleaning.")
}
var _ = Describe("[APIGroup] Velero tests with various CRD API group versions", APIGropuVersionsTest)

View File

@@ -51,8 +51,10 @@ func SSRTest() {
AfterEach(func() {
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
}
}
})
It(fmt.Sprintf("Should create an ssr object in the %s namespace and later removed by controller", VeleroCfg.VeleroNamespace), func() {

View File

@@ -84,8 +84,10 @@ func TestFunc(test VeleroBackupRestoreTest) func() {
})
AfterEach(func() {
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To((Succeed()))
}
}
})
It(test.GetTestMsg().Text, func() {
Expect(RunTestCase(test)).To(Succeed(), test.GetTestMsg().FailedMSG)
@@ -115,7 +117,7 @@ func TestFuncWithMultiIt(tests []VeleroBackupRestoreTest) func() {
AfterEach(func() {
if VeleroCfg.InstallVelero {
if countIt == len(tests) {
if countIt == len(tests) && !VeleroCfg.Debug {
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To((Succeed()))
}
}

View File

@@ -50,6 +50,7 @@ type VerleroConfig struct {
InstallVelero bool
KibishiiDirectory string
Features string
Debug bool
}
type SnapshotCheckPoint struct {

View File

@@ -94,6 +94,7 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, upgradeFromVelero Upgrade
})
AfterEach(func() {
if VeleroCfg.InstallVelero {
if !VeleroCfg.Debug {
By(fmt.Sprintf("Delete sample workload namespace %s", upgradeNamespace), func() {
DeleteNamespace(context.Background(), client, upgradeNamespace, true)
})
@@ -102,6 +103,7 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, upgradeFromVelero Upgrade
VeleroCfg.VeleroNamespace)).To(Succeed())
})
}
}
})
When("kibishii is the sample workload", func() {
It("should be successfully backed up and restored to the default BackupStorageLocation", func() {

View File

@@ -46,11 +46,22 @@ func RunKibishiiTests(client TestClient, veleroCfg VerleroConfig, backupName, re
registryCredentialFile := VeleroCfg.RegistryCredentialFile
veleroFeatures := VeleroCfg.Features
kibishiiDirectory := VeleroCfg.KibishiiDirectory
if _, err := GetNamespace(context.Background(), client, kibishiiNamespace); err == nil {
fmt.Printf("Workload namespace %s exists, delete it first.", kibishiiNamespace)
if err = DeleteNamespace(context.Background(), client, kibishiiNamespace, true); err != nil {
fmt.Println(errors.Wrapf(err, "failed to delete the namespace %q", kibishiiNamespace))
}
}
if err := CreateNamespace(oneHourTimeout, client, kibishiiNamespace); err != nil {
return errors.Wrapf(err, "Failed to create namespace %s to install Kibishii workload", kibishiiNamespace)
}
defer func() {
if !veleroCfg.Debug {
if err := DeleteNamespace(context.Background(), client, kibishiiNamespace, true); err != nil {
fmt.Println(errors.Wrapf(err, "failed to delete the namespace %q", kibishiiNamespace))
}
}
}()
if err := KibishiiPrepareBeforeBackup(oneHourTimeout, client, providerName,
kibishiiNamespace, registryCredentialFile, veleroFeatures,
kibishiiDirectory, useVolumeSnapshots); err != nil {