mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 22:44:21 +00:00
monitor velero logs and fix E2E issues
1. Capture Velero pod log and K8S cluster event; 2. Fix wrong path of storageclass yaml file issue caused by pert test; 3. Fix change storageclass test issue that no sc named 'default' in EKS cluster; 4. Support AWS credential as config format; 5. Support more E2E script input parameters like standy cluster plugins and provider. Signed-off-by: danfengl <danfengl@vmware.com>
This commit is contained in:
+8
-3
@@ -51,7 +51,6 @@ SKIP_STR := $(foreach var, $(subst ., ,$(GINKGO_SKIP)),-skip "$(var)")
|
||||
FOCUS_STR := $(foreach var, $(subst ., ,$(GINKGO_FOCUS)),-focus "$(var)")
|
||||
VELERO_CLI ?=$$(pwd)/../../_output/bin/$(GOOS)/$(GOARCH)/velero
|
||||
VELERO_IMAGE ?= velero/velero:main
|
||||
VELERO_VERSION ?= $(VERSION)
|
||||
PLUGINS ?=
|
||||
RESTORE_HELPER_IMAGE ?=
|
||||
#Released version only
|
||||
@@ -74,6 +73,8 @@ BSL_CONFIG ?=
|
||||
VSL_CONFIG ?=
|
||||
CLOUD_PROVIDER ?=
|
||||
STANDBY_CLUSTER_CLOUD_PROVIDER ?=
|
||||
STANDBY_CLUSTER_PLUGINS ?=
|
||||
STANDBY_CLUSTER_OBJECT_STORE_PROVIDER ?=
|
||||
OBJECT_STORE_PROVIDER ?=
|
||||
INSTALL_VELERO ?= true
|
||||
REGISTRY_CREDENTIAL_FILE ?=
|
||||
@@ -90,6 +91,7 @@ ADDITIONAL_BSL_CONFIG ?=
|
||||
|
||||
FEATURES ?=
|
||||
DEBUG_E2E_TEST ?= false
|
||||
DEBUG_VELERO_POD_RESTART ?= false
|
||||
VELERO_SERVER_DEBUG_MODE ?= false
|
||||
|
||||
# Parameters to run migration tests along with all other E2E tests, and both of them should
|
||||
@@ -119,7 +121,7 @@ run: ginkgo
|
||||
@$(GINKGO) -v $(FOCUS_STR) $(SKIP_STR) . -- -velerocli=$(VELERO_CLI) \
|
||||
-velero-image=$(VELERO_IMAGE) \
|
||||
-plugins=$(PLUGINS) \
|
||||
-velero-version=$(VELERO_VERSION) \
|
||||
-velero-version=$(VERSION) \
|
||||
-restore-helper-image=$(RESTORE_HELPER_IMAGE) \
|
||||
-upgrade-from-velero-cli=$(UPGRADE_FROM_VELERO_CLI) \
|
||||
-upgrade-from-velero-version=$(UPGRADE_FROM_VELERO_VERSION) \
|
||||
@@ -150,7 +152,10 @@ run: ginkgo
|
||||
-uploader-type=$(UPLOADER_TYPE) \
|
||||
-snapshot-move-data=$(SNAPSHOT_MOVE_DATA) \
|
||||
-data-mover-plugin=$(DATA_MOVER_plugin) \
|
||||
-standby-cluster-cloud-provider=$(STANDBY_CLUSTER_CLOUD_PROVIDER)
|
||||
-standby-cluster-cloud-provider=$(STANDBY_CLUSTER_CLOUD_PROVIDER) \
|
||||
-standby-cluster-plugins=$(STANDBY_CLUSTER_PLUGINS) \
|
||||
-standby-cluster-object-store-provider=$(STANDBY_CLUSTER_OBJECT_STORE_PROVIDER) \
|
||||
-debug-velero-pod-restart=$(DEBUG_VELERO_POD_RESTART)
|
||||
|
||||
build: ginkgo
|
||||
mkdir -p $(OUTPUT_DIR)
|
||||
|
||||
@@ -66,7 +66,7 @@ func BackupRestoreTest(useVolumeSnapshots bool) {
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
})
|
||||
if veleroCfg.InstallVelero {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
|
||||
@@ -69,7 +69,7 @@ func backup_deletion_test(useVolumeSnapshots bool) {
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -66,7 +66,7 @@ func BackupsSyncTest() {
|
||||
AfterEach(func() {
|
||||
if !VeleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *VeleroCfg.ClientToInstallVelero)
|
||||
DeleteAllBackups(context.Background(), *VeleroCfg.ClientToInstallVelero)
|
||||
})
|
||||
if VeleroCfg.InstallVelero {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
|
||||
@@ -78,7 +78,7 @@ func TTLTest() {
|
||||
veleroCfg.GCFrequency = ""
|
||||
if !veleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
})
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer ctxCancel()
|
||||
|
||||
@@ -69,7 +69,7 @@ func APIExtensionsVersionsTest() {
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.DefaultClient)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.DefaultClient)
|
||||
})
|
||||
if veleroCfg.InstallVelero {
|
||||
By("Uninstall Velero and delete CRD ", func() {
|
||||
|
||||
@@ -94,7 +94,7 @@ func APIGropuVersionsTest() {
|
||||
}
|
||||
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
})
|
||||
if veleroCfg.InstallVelero {
|
||||
By("Uninstall Velero in api group version case", func() {
|
||||
|
||||
@@ -73,6 +73,14 @@ func (p *PVCSelectedNodeChanging) CreateResources() error {
|
||||
fmt.Sprintf("Failed to create namespace %s", p.namespace))
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create a storage class %s.", StorageClassName), func() {
|
||||
Expect(InstallStorageClass(context.Background(), fmt.Sprintf("../testdata/storage-class/%s.yaml", p.VeleroCfg.CloudProvider))).To(Succeed())
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create a storage class %s.", StorageClassName), func() {
|
||||
Expect(InstallTestStorageClasses(fmt.Sprintf("../testdata/storage-class/%s.yaml", VeleroCfg.CloudProvider))).To(Succeed(), "Failed to install storage class")
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create pod %s in namespace %s", p.podName, p.namespace), func() {
|
||||
nodeNameList, err := GetWorkerNodes(p.Ctx)
|
||||
Expect(err).To(Succeed())
|
||||
@@ -80,7 +88,7 @@ func (p *PVCSelectedNodeChanging) CreateResources() error {
|
||||
p.oldNodeName = nodeName
|
||||
fmt.Printf("Create PVC on node %s\n", p.oldNodeName)
|
||||
pvcAnn := map[string]string{p.ann: nodeName}
|
||||
_, err := CreatePod(p.Client, p.namespace, p.podName, "default", p.pvcName, []string{p.volume}, pvcAnn, nil)
|
||||
_, err := CreatePod(p.Client, p.namespace, p.podName, StorageClassName, p.pvcName, []string{p.volume}, pvcAnn, nil)
|
||||
Expect(err).To(Succeed())
|
||||
err = WaitForPods(p.Ctx, p.Client, p.namespace, []string{p.podName})
|
||||
Expect(err).To(Succeed())
|
||||
|
||||
@@ -50,8 +50,8 @@ func (s *StorageClasssChanging) Init() error {
|
||||
Text: "Change the storage class of persistent volumes and persistent" +
|
||||
" volume claims during restores",
|
||||
}
|
||||
s.srcStorageClass = "default"
|
||||
s.desStorageClass = StorageClassName
|
||||
s.srcStorageClass = StorageClassName
|
||||
s.desStorageClass = StorageClassName2
|
||||
s.labels = map[string]string{"velero.io/change-storage-class": "RestoreItemAction",
|
||||
"velero.io/plugin-config": ""}
|
||||
s.data = map[string]string{s.srcStorageClass: s.desStorageClass}
|
||||
@@ -75,10 +75,11 @@ func (s *StorageClasssChanging) CreateResources() error {
|
||||
"app": "test",
|
||||
}
|
||||
s.Ctx, s.CtxCancel = context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
By(fmt.Sprintf("Create a storage class %s", s.desStorageClass), func() {
|
||||
Expect(InstallStorageClass(s.Ctx, fmt.Sprintf("../testdata/storage-class/%s.yaml",
|
||||
s.VeleroCfg.CloudProvider))).To(Succeed())
|
||||
|
||||
By(("Installing storage class..."), func() {
|
||||
Expect(InstallTestStorageClasses(fmt.Sprintf("../testdata/storage-class/%s.yaml", s.VeleroCfg.CloudProvider))).To(Succeed(), "Failed to install storage class")
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create namespace %s", s.namespace), func() {
|
||||
Expect(CreateNamespace(s.Ctx, s.Client, s.namespace)).To(Succeed(),
|
||||
fmt.Sprintf("Failed to create namespace %s", s.namespace))
|
||||
|
||||
@@ -77,7 +77,7 @@ func BslDeletionTest(useVolumeSnapshots bool) {
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.DefaultClient)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.DefaultClient)
|
||||
})
|
||||
By(fmt.Sprintf("Delete sample workload namespace %s", bslDeletionTestNs), func() {
|
||||
Expect(DeleteNamespace(context.Background(), *veleroCfg.ClientToInstallVelero, bslDeletionTestNs,
|
||||
|
||||
@@ -85,10 +85,13 @@ func init() {
|
||||
flag.StringVar(&VeleroCfg.DefaultCluster, "default-cluster", "", "Default cluster context for migration test.")
|
||||
flag.StringVar(&VeleroCfg.StandbyCluster, "standby-cluster", "", "Standby cluster context for migration test.")
|
||||
flag.StringVar(&VeleroCfg.UploaderType, "uploader-type", "", "Identify persistent volume backup uploader.")
|
||||
flag.BoolVar(&VeleroCfg.VeleroServerDebugMode, "velero-server-debug-mode", false, "Identify persistent volume backup uploader.")
|
||||
flag.BoolVar(&VeleroCfg.VeleroServerDebugMode, "velero-server-debug-mode", false, "Switch for enabling Velero server log debug level.")
|
||||
flag.BoolVar(&VeleroCfg.SnapshotMoveData, "snapshot-move-data", false, "Install default plugin for data mover.")
|
||||
flag.StringVar(&VeleroCfg.DataMoverPlugin, "data-mover-plugin", "", "Install customized plugin for data mover.")
|
||||
flag.StringVar(&VeleroCfg.StandbyClusterCloudProvider, "standby-cluster-cloud-provider", "", "Install customized plugin for data mover.")
|
||||
flag.StringVar(&VeleroCfg.StandbyClusterCloudProvider, "standby-cluster-cloud-provider", "", "Cloud provider for standby cluster.")
|
||||
flag.StringVar(&VeleroCfg.StandbyClusterPlugins, "standby-cluster-plugins", "", "Plugins provider for standby cluster.")
|
||||
flag.StringVar(&VeleroCfg.StandbyClusterOjbectStoreProvider, "standby-cluster-object-store-provider", "", "Object store provider for standby cluster.")
|
||||
flag.BoolVar(&VeleroCfg.DebugVeleroPodRestart, "debug-velero-pod-restart", false, "Switch for debugging velero pod restart.")
|
||||
}
|
||||
|
||||
var _ = Describe("[APIGroup][APIVersion] Velero tests with various CRD API group versions", APIGropuVersionsTest)
|
||||
|
||||
@@ -82,22 +82,26 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
})
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
// TODO: delete backup created by case self, not all
|
||||
// By("Clean backups after test", func() {
|
||||
// DeleteBackups(context.Background(), *veleroCfg.DefaultClient)
|
||||
// })
|
||||
if veleroCfg.InstallVelero {
|
||||
By(fmt.Sprintf("Uninstall Velero and delete sample workload namespace %s", migrationNamespace), func() {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer ctxCancel()
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultCluster)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
|
||||
veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
DeleteNamespace(context.Background(), *veleroCfg.DefaultClient, migrationNamespace, true)
|
||||
By(fmt.Sprintf("Uninstall Velero on cluster %s", veleroCfg.DefaultCluster), func() {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer ctxCancel()
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultCluster)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
|
||||
veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
DeleteNamespace(context.Background(), *veleroCfg.DefaultClient, migrationNamespace, true)
|
||||
})
|
||||
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.StandbyCluster)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
|
||||
veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
By(fmt.Sprintf("Uninstall Velero on cluster %s", veleroCfg.StandbyCluster), func() {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer ctxCancel()
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.StandbyCluster)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
|
||||
veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
DeleteNamespace(context.Background(), *veleroCfg.StandbyClient, migrationNamespace, true)
|
||||
})
|
||||
|
||||
if veleroCfg.InstallVelero {
|
||||
By(fmt.Sprintf("Delete sample workload namespace %s", migrationNamespace), func() {
|
||||
DeleteNamespace(context.Background(), *veleroCfg.StandbyClient, migrationNamespace, true)
|
||||
})
|
||||
}
|
||||
@@ -110,7 +114,7 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
})
|
||||
When("kibishii is the sample workload", func() {
|
||||
It("should be successfully backed up and restored to the default BackupStorageLocation", func() {
|
||||
|
||||
var backupNames []string
|
||||
if veleroCfg.SnapshotMoveData {
|
||||
if !useVolumeSnapshots {
|
||||
Skip("FSB migration test is not needed in data mover scenario")
|
||||
@@ -185,7 +189,7 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
KibishiiData := *DefaultKibishiiData
|
||||
By("Deploy sample workload of Kibishii", func() {
|
||||
if OriginVeleroCfg.SnapshotMoveData {
|
||||
KibishiiData.ExpectedNodes = 6
|
||||
KibishiiData.ExpectedNodes = 3
|
||||
}
|
||||
|
||||
Expect(KibishiiPrepareBeforeBackup(oneHourTimeout, *veleroCfg.DefaultClient, veleroCfg.CloudProvider,
|
||||
@@ -206,6 +210,7 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
RunDebug(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, BackupStorageClassCfg.BackupName, "")
|
||||
return "Fail to backup workload"
|
||||
})
|
||||
backupNames = append(backupNames, BackupStorageClassCfg.BackupName)
|
||||
|
||||
var BackupCfg BackupConfig
|
||||
BackupCfg.BackupName = backupName
|
||||
@@ -223,6 +228,7 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
RunDebug(context.Background(), OriginVeleroCfg.VeleroCLI, OriginVeleroCfg.VeleroNamespace, BackupCfg.BackupName, "")
|
||||
return "Fail to backup workload"
|
||||
})
|
||||
backupNames = append(backupNames, BackupCfg.BackupName)
|
||||
})
|
||||
|
||||
if useVolumeSnapshots {
|
||||
@@ -283,7 +289,12 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
veleroCfg.UseRestic = false
|
||||
if veleroCfg.SnapshotMoveData {
|
||||
veleroCfg.UseNodeAgent = true
|
||||
// For SnapshotMoveData pipelines, we should use standby clustr setting for Velero installation
|
||||
// In nightly CI, StandbyClusterPlugins is set properly if pipeline is for SnapshotMoveData.
|
||||
veleroCfg.Plugins = veleroCfg.StandbyClusterPlugins
|
||||
veleroCfg.ObjectStoreProvider = veleroCfg.StandbyClusterOjbectStoreProvider
|
||||
}
|
||||
|
||||
Expect(VeleroInstall(context.Background(), &veleroCfg, true)).To(Succeed())
|
||||
})
|
||||
|
||||
@@ -326,6 +337,11 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
Expect(KibishiiVerifyAfterRestore(*veleroCfg.StandbyClient, migrationNamespace,
|
||||
oneHourTimeout, &KibishiiData)).To(Succeed(), "Fail to verify workload after restore")
|
||||
})
|
||||
|
||||
// TODO: delete backup created by case self, not all
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.DefaultClient, backupNames)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package filtering
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -33,6 +32,7 @@ import (
|
||||
. "github.com/vmware-tanzu/velero/test"
|
||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||
. "github.com/vmware-tanzu/velero/test/util/velero"
|
||||
)
|
||||
|
||||
const FileName = "test-data.txt"
|
||||
@@ -110,7 +110,7 @@ func (r *ResourcePoliciesCase) CreateResources() error {
|
||||
r.Ctx, r.CtxCancel = context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
|
||||
By(("Installing storage class..."), func() {
|
||||
Expect(r.installTestStorageClasses(fmt.Sprintf("../testdata/storage-class/%s.yaml", VeleroCfg.CloudProvider))).To(Succeed(), "Failed to install storage class")
|
||||
Expect(InstallTestStorageClasses(fmt.Sprintf("../testdata/storage-class/%s.yaml", VeleroCfg.CloudProvider))).To(Succeed(), "Failed to install storage class")
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create configmap %s in namespaces %s for workload\n", r.cmName, r.VeleroCfg.VeleroNamespace), func() {
|
||||
@@ -188,7 +188,7 @@ func (r *ResourcePoliciesCase) Verify() error {
|
||||
func (r *ResourcePoliciesCase) Clean() error {
|
||||
// If created some resources which is not in current test namespace, we NEED to override the base Clean function
|
||||
if !r.VeleroCfg.Debug {
|
||||
if err := r.deleteTestStorageClassList([]string{"e2e-storage-class", "e2e-storage-class-2"}); err != nil {
|
||||
if err := r.deleteTestStorageClassList([]string{StorageClassName, StorageClassName2}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -207,13 +207,13 @@ func (r *ResourcePoliciesCase) createPVC(index int, namespace string, volList []
|
||||
pvcName := fmt.Sprintf("pvc-%d", i)
|
||||
By(fmt.Sprintf("Creating PVC %s in namespaces ...%s\n", pvcName, namespace))
|
||||
if index%3 == 0 {
|
||||
pvcBuilder := NewPVC(namespace, pvcName).WithStorageClass("e2e-storage-class") // Testing sc should not backup
|
||||
pvcBuilder := NewPVC(namespace, pvcName).WithStorageClass(StorageClassName) // Testing sc should not backup
|
||||
err = CreatePvc(r.Client, pvcBuilder)
|
||||
} else if index%3 == 1 {
|
||||
pvcBuilder := NewPVC(namespace, pvcName).WithStorageClass("e2e-storage-class-2") // Testing sc should backup
|
||||
pvcBuilder := NewPVC(namespace, pvcName).WithStorageClass(StorageClassName2) // Testing sc should backup
|
||||
err = CreatePvc(r.Client, pvcBuilder)
|
||||
} else if index%3 == 2 {
|
||||
pvcBuilder := NewPVC(namespace, pvcName).WithStorageClass("e2e-storage-class-2").WithResourceStorage(resource.MustParse("2Gi")) // Testing capacity should not backup
|
||||
pvcBuilder := NewPVC(namespace, pvcName).WithStorageClass(StorageClassName2).WithResourceStorage(resource.MustParse("2Gi")) // Testing capacity should not backup
|
||||
err = CreatePvc(r.Client, pvcBuilder)
|
||||
}
|
||||
if err != nil {
|
||||
@@ -263,28 +263,3 @@ func (r *ResourcePoliciesCase) deleteTestStorageClassList(scList []string) error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ResourcePoliciesCase) installTestStorageClasses(path string) error {
|
||||
err := InstallStorageClass(r.Ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get %s when install storage class", path)
|
||||
}
|
||||
|
||||
// replace sc to new value
|
||||
newContent := strings.ReplaceAll(string(content), "name: e2e-storage-class", "name: e2e-storage-class-2")
|
||||
|
||||
tmpFile, err := os.CreateTemp("", "sc-file")
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create temp file when install storage class")
|
||||
}
|
||||
|
||||
defer os.Remove(tmpFile.Name())
|
||||
if _, err := tmpFile.WriteString(newContent); err != nil {
|
||||
return errors.Wrapf(err, "failed to write content into temp file %s when install storage class", tmpFile.Name())
|
||||
}
|
||||
return InstallStorageClass(r.Ctx, tmpFile.Name())
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ func (o *OrderedResources) Clean() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *OrderedResources) DeleteBackups() error {
|
||||
func (o *OrderedResources) DeleteAllBackups() error {
|
||||
backupList := new(velerov1api.BackupList)
|
||||
if err := o.Client.Kubebuilder.List(o.Ctx, backupList, &kbclient.ListOptions{Namespace: o.VeleroCfg.VeleroNamespace}); err != nil {
|
||||
return fmt.Errorf("failed to list backup object in %s namespace with err %v", o.VeleroCfg.VeleroNamespace, err)
|
||||
|
||||
@@ -192,7 +192,7 @@ func (t *TestCase) Clean() error {
|
||||
CleanupNamespaces(t.Ctx, t.Client, t.CaseBaseName)
|
||||
})
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(t.Ctx, t.Client)
|
||||
DeleteAllBackups(t.Ctx, t.Client)
|
||||
})
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -87,7 +87,7 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
||||
AfterEach(func() {
|
||||
if !veleroCfg.Debug {
|
||||
By("Clean backups after test", func() {
|
||||
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||
})
|
||||
By(fmt.Sprintf("Delete sample workload namespace %s", upgradeNamespace), func() {
|
||||
DeleteNamespace(context.Background(), *veleroCfg.ClientToInstallVelero, upgradeNamespace, true)
|
||||
@@ -136,6 +136,7 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
||||
version, err := GetVeleroVersion(oneHourTimeout, tmpCfgForOldVeleroInstall.VeleroCLI, true)
|
||||
Expect(err).To(Succeed(), "Fail to get Velero version")
|
||||
tmpCfgForOldVeleroInstall.VeleroVersion = version
|
||||
tmpCfgForOldVeleroInstall.UseVolumeSnapshots = useVolumeSnapshots
|
||||
|
||||
if supportUploaderType {
|
||||
tmpCfgForOldVeleroInstall.UseRestic = false
|
||||
|
||||
Reference in New Issue
Block a user