mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 22:05:25 +00:00
Modify the StorageClass install and delete code.
* Only install and uninstall SC and VSC once for default cluster. * Install and uninstall SC and VSC for standby cluster on migration case. * Refactor the StorageClass and VolumeSnapshotClass YAMLs. * Prettify the e2e_suite_test.go Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
@@ -83,13 +83,11 @@ func APIExtensionsVersionsTest() {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer ctxCancel()
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
|
||||
veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg)).To(Succeed())
|
||||
Expect(DeleteCRDByName(context.Background(), crdName)).To(Succeed())
|
||||
|
||||
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.StandbyClusterContext)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
|
||||
veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg)).To(Succeed())
|
||||
Expect(DeleteCRDByName(context.Background(), crdName)).To(Succeed())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func APIGroupVersionsTest() {
|
||||
})
|
||||
if InstallVelero {
|
||||
By("Uninstall Velero in api group version case", func() {
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).NotTo(HaveOccurred())
|
||||
Expect(VeleroUninstall(ctx, veleroCfg)).NotTo(HaveOccurred())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||
. "github.com/vmware-tanzu/velero/test/util/common"
|
||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||
. "github.com/vmware-tanzu/velero/test/util/velero"
|
||||
)
|
||||
|
||||
type BackupVolumeInfo struct {
|
||||
@@ -108,9 +107,6 @@ func (v *BackupVolumeInfo) CreateResources() error {
|
||||
return errors.Wrapf(err, "Failed to create namespace %s", createNSName)
|
||||
}
|
||||
|
||||
// Install StorageClass
|
||||
Expect(InstallTestStorageClasses(fmt.Sprintf("../testdata/storage-class/%s-csi.yaml", v.VeleroCfg.CloudProvider))).To(Succeed(), "Failed to install StorageClass")
|
||||
|
||||
// Create deployment
|
||||
fmt.Printf("Creating deployment in namespaces ...%s\n", createNSName)
|
||||
// Make sure PVC count is great than 3 to allow both empty volumes and file populated volumes exist per pod
|
||||
@@ -120,7 +116,7 @@ func (v *BackupVolumeInfo) CreateResources() error {
|
||||
var vols []*v1.Volume
|
||||
for i := 0; i <= pvcCount-1; i++ {
|
||||
pvcName := fmt.Sprintf("volume-info-pvc-%d", i)
|
||||
pvc, err := CreatePVC(v.Client, createNSName, pvcName, CSIStorageClassName, nil)
|
||||
pvc, err := CreatePVC(v.Client, createNSName, pvcName, StorageClassName, nil)
|
||||
Expect(err).To(Succeed())
|
||||
volumeName := fmt.Sprintf("volume-info-pv-%d", i)
|
||||
vols = append(vols, CreateVolumes(pvc.Name, []string{volumeName})...)
|
||||
@@ -159,11 +155,3 @@ func (v *BackupVolumeInfo) Destroy() error {
|
||||
|
||||
return WaitAllSelectedNSDeleted(v.Ctx, v.Client, "ns-test=true")
|
||||
}
|
||||
|
||||
func (v *BackupVolumeInfo) cleanResource() error {
|
||||
if err := DeleteStorageClass(v.Ctx, v.Client, CSIStorageClassName); err != nil {
|
||||
return errors.Wrap(err, "fail to delete the StorageClass")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -61,6 +61,5 @@ func (c *CSIDataMoverVolumeInfo) Verify() error {
|
||||
Expect(len(volumeInfo) > 0).To(BeIdenticalTo(true))
|
||||
Expect(volumeInfo[0].SnapshotDataMovementInfo).NotTo(BeNil())
|
||||
|
||||
// Clean SC and VSC
|
||||
return c.cleanResource()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,5 @@ func (c *CSISnapshotVolumeInfo) Verify() error {
|
||||
Expect(len(volumeInfo) > 0).To(BeIdenticalTo(true))
|
||||
Expect(volumeInfo[0].CSISnapshotInfo).NotTo(BeNil())
|
||||
|
||||
// Clean SC and VSC
|
||||
return c.cleanResource()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,5 @@ func (f *FilesystemUploadVolumeInfo) Verify() error {
|
||||
Expect(len(volumeInfo) > 0).To(BeIdenticalTo(true))
|
||||
Expect(volumeInfo[0].PVBInfo).NotTo(BeNil())
|
||||
|
||||
// Clean SC and VSC
|
||||
return f.cleanResource()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -61,6 +61,5 @@ func (n *NativeSnapshotVolumeInfo) Verify() error {
|
||||
Expect(len(volumeInfo) > 0).To(BeIdenticalTo(true))
|
||||
Expect(volumeInfo[0].NativeSnapshotInfo).NotTo(BeNil())
|
||||
|
||||
// Clean SC and VSC
|
||||
return n.cleanResource()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,5 @@ func (s *SkippedVolumeInfo) Verify() error {
|
||||
Expect(len(volumeInfo) > 0).To(BeIdenticalTo(true))
|
||||
Expect(volumeInfo[0].Skipped).To(BeIdenticalTo(true))
|
||||
|
||||
// Clean SC and VSC
|
||||
return s.cleanResource()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -68,14 +68,6 @@ 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", p.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())
|
||||
|
||||
@@ -18,7 +18,7 @@ type StorageClasssChanging struct {
|
||||
TestCase
|
||||
labels map[string]string
|
||||
data map[string]string
|
||||
configmaptName string
|
||||
cmName string
|
||||
namespace string
|
||||
srcStorageClass string
|
||||
desStorageClass string
|
||||
@@ -51,7 +51,7 @@ func (s *StorageClasssChanging) Init() error {
|
||||
s.labels = map[string]string{"velero.io/change-storage-class": "RestoreItemAction",
|
||||
"velero.io/plugin-config": ""}
|
||||
s.data = map[string]string{s.srcStorageClass: s.desStorageClass}
|
||||
s.configmaptName = "change-storage-class-config"
|
||||
s.cmName = "change-storage-class-config"
|
||||
s.volume = "volume-1"
|
||||
s.pvcName = fmt.Sprintf("pvc-%s", s.volume)
|
||||
s.podName = "pod-1"
|
||||
@@ -72,10 +72,6 @@ func (s *StorageClasssChanging) CreateResources() error {
|
||||
"app": "test",
|
||||
}
|
||||
|
||||
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))
|
||||
@@ -94,8 +90,8 @@ func (s *StorageClasssChanging) CreateResources() error {
|
||||
Expect(err).To(Succeed())
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create ConfigMap %s in namespace %s", s.configmaptName, s.VeleroCfg.VeleroNamespace), func() {
|
||||
_, err := CreateConfigMap(s.Client.ClientGo, s.VeleroCfg.VeleroNamespace, s.configmaptName, s.labels, s.data)
|
||||
By(fmt.Sprintf("Create ConfigMap %s in namespace %s", s.cmName, s.VeleroCfg.VeleroNamespace), func() {
|
||||
_, err := CreateConfigMap(s.Client.ClientGo, s.VeleroCfg.VeleroNamespace, s.cmName, s.labels, s.data)
|
||||
Expect(err).To(Succeed(), fmt.Sprintf("failed to create configmap in the namespace %q", s.VeleroCfg.VeleroNamespace))
|
||||
})
|
||||
return nil
|
||||
@@ -149,8 +145,7 @@ func (s *StorageClasssChanging) Clean() error {
|
||||
Expect(CleanupNamespacesWithPoll(s.Ctx, s.Client, s.CaseBaseName)).To(Succeed(),
|
||||
fmt.Sprintf("Failed to delete namespace %s", s.CaseBaseName))
|
||||
})
|
||||
DeleteConfigmap(s.Client.ClientGo, s.VeleroCfg.VeleroNamespace, s.configmaptName)
|
||||
DeleteStorageClass(s.Ctx, s.Client, s.desStorageClass)
|
||||
DeleteConfigMap(s.Client.ClientGo, s.VeleroCfg.VeleroNamespace, s.cmName)
|
||||
s.TestCase.Clean()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user