Fix wrong usage of global varaible VeleroCfg
Signed-off-by: danfengl <danfengl@vmware.com>pull/7392/head
parent
3b8370e13c
commit
b0956322b9
|
@ -99,7 +99,7 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if !veleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
if backupRestoreTestConfig.isRetainPVTest {
|
if backupRestoreTestConfig.isRetainPVTest {
|
||||||
CleanAllRetainedPV(context.Background(), *veleroCfg.ClientToInstallVelero)
|
CleanAllRetainedPV(context.Background(), *veleroCfg.ClientToInstallVelero)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ func backup_deletion_test(useVolumeSnapshots bool) {
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if !veleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -157,7 +157,7 @@ func runBackupDeletionTests(client TestClient, veleroCfg VeleroConfig, backupNam
|
||||||
return errors.Wrap(err, "exceed waiting for snapshot created in cloud")
|
return errors.Wrap(err, "exceed waiting for snapshot created in cloud")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = DeleteBackupResource(context.Background(), veleroCLI, backupName)
|
err = DeleteBackupResource(context.Background(), backupName, &veleroCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ func runBackupDeletionTests(client TestClient, veleroCfg VeleroConfig, backupNam
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = DeleteBackupResource(context.Background(), veleroCLI, backupName)
|
err = DeleteBackupResource(context.Background(), backupName, &veleroCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "|| UNEXPECTED || - Failed to delete backup %q", backupName)
|
return errors.Wrapf(err, "|| UNEXPECTED || - Failed to delete backup %q", backupName)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -53,25 +53,24 @@ func BackupsSyncTest() {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
veleroCfg := VeleroCfg
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if InstallVelero {
|
if InstallVelero {
|
||||||
veleroCfg := VeleroCfg
|
|
||||||
veleroCfg.UseVolumeSnapshots = false
|
veleroCfg.UseVolumeSnapshots = false
|
||||||
Expect(VeleroInstall(context.Background(), &VeleroCfg, false)).To(Succeed())
|
Expect(VeleroInstall(context.Background(), &veleroCfg, false)).To(Succeed())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if !VeleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *VeleroCfg.ClientToInstallVelero)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
if InstallVelero {
|
if InstallVelero {
|
||||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||||
defer ctxCancel()
|
defer ctxCancel()
|
||||||
Expect(VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
|
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +81,11 @@ func BackupsSyncTest() {
|
||||||
ctx, ctxCancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
ctx, ctxCancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
||||||
defer ctxCancel()
|
defer ctxCancel()
|
||||||
By(fmt.Sprintf("Prepare workload as target to backup by creating namespace %s namespace", test.testNS))
|
By(fmt.Sprintf("Prepare workload as target to backup by creating namespace %s namespace", test.testNS))
|
||||||
Expect(CreateNamespace(ctx, *VeleroCfg.ClientToInstallVelero, test.testNS)).To(Succeed(),
|
Expect(CreateNamespace(ctx, *veleroCfg.ClientToInstallVelero, test.testNS)).To(Succeed(),
|
||||||
fmt.Sprintf("Failed to create %s namespace", test.testNS))
|
fmt.Sprintf("Failed to create %s namespace", test.testNS))
|
||||||
if !VeleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
defer func() {
|
defer func() {
|
||||||
Expect(DeleteNamespace(ctx, *VeleroCfg.ClientToInstallVelero, test.testNS, false)).To(Succeed(), fmt.Sprintf("Failed to delete the namespace %s", test.testNS))
|
Expect(DeleteNamespace(ctx, *veleroCfg.ClientToInstallVelero, test.testNS, false)).To(Succeed(), fmt.Sprintf("Failed to delete the namespace %s", test.testNS))
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,25 +96,25 @@ func BackupsSyncTest() {
|
||||||
BackupCfg.UseVolumeSnapshots = false
|
BackupCfg.UseVolumeSnapshots = false
|
||||||
BackupCfg.Selector = ""
|
BackupCfg.Selector = ""
|
||||||
By(fmt.Sprintf("Backup the workload in %s namespace", test.testNS), func() {
|
By(fmt.Sprintf("Backup the workload in %s namespace", test.testNS), func() {
|
||||||
Expect(VeleroBackupNamespace(ctx, VeleroCfg.VeleroCLI,
|
Expect(VeleroBackupNamespace(ctx, veleroCfg.VeleroCLI,
|
||||||
VeleroCfg.VeleroNamespace, BackupCfg)).To(Succeed(), func() string {
|
veleroCfg.VeleroNamespace, BackupCfg)).To(Succeed(), func() string {
|
||||||
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, test.backupName, "")
|
RunDebug(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, test.backupName, "")
|
||||||
return "Fail to backup workload"
|
return "Fail to backup workload"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Uninstall velero", func() {
|
By("Uninstall velero", func() {
|
||||||
Expect(VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
|
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Install velero", func() {
|
By("Install velero", func() {
|
||||||
veleroCfg := VeleroCfg
|
veleroCfg := VeleroCfg
|
||||||
veleroCfg.UseVolumeSnapshots = false
|
veleroCfg.UseVolumeSnapshots = false
|
||||||
Expect(VeleroInstall(ctx, &VeleroCfg, false)).To(Succeed())
|
Expect(VeleroInstall(ctx, &veleroCfg, false)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Check all backups in object storage are synced to Velero", func() {
|
By("Check all backups in object storage are synced to Velero", func() {
|
||||||
Expect(test.IsBackupsSynced(ctx, ctxCancel)).To(Succeed(), fmt.Sprintf("Failed to sync backup %s from object storage", test.backupName))
|
Expect(test.IsBackupsSynced(ctx, &veleroCfg, ctxCancel)).To(Succeed(), fmt.Sprintf("Failed to sync backup %s from object storage", test.backupName))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -124,12 +123,12 @@ func BackupsSyncTest() {
|
||||||
ctx, ctxCancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
ctx, ctxCancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
||||||
defer ctxCancel()
|
defer ctxCancel()
|
||||||
By(fmt.Sprintf("Prepare workload as target to backup by creating namespace in %s namespace", test.testNS), func() {
|
By(fmt.Sprintf("Prepare workload as target to backup by creating namespace in %s namespace", test.testNS), func() {
|
||||||
Expect(CreateNamespace(ctx, *VeleroCfg.ClientToInstallVelero, test.testNS)).To(Succeed(),
|
Expect(CreateNamespace(ctx, *veleroCfg.ClientToInstallVelero, test.testNS)).To(Succeed(),
|
||||||
fmt.Sprintf("Failed to create %s namespace", test.testNS))
|
fmt.Sprintf("Failed to create %s namespace", test.testNS))
|
||||||
})
|
})
|
||||||
if !VeleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
defer func() {
|
defer func() {
|
||||||
Expect(DeleteNamespace(ctx, *VeleroCfg.ClientToInstallVelero, test.testNS, false)).To(Succeed(),
|
Expect(DeleteNamespace(ctx, *veleroCfg.ClientToInstallVelero, test.testNS, false)).To(Succeed(),
|
||||||
fmt.Sprintf("Failed to delete the namespace %s", test.testNS))
|
fmt.Sprintf("Failed to delete the namespace %s", test.testNS))
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -140,32 +139,32 @@ func BackupsSyncTest() {
|
||||||
BackupCfg.UseVolumeSnapshots = false
|
BackupCfg.UseVolumeSnapshots = false
|
||||||
BackupCfg.Selector = ""
|
BackupCfg.Selector = ""
|
||||||
By(fmt.Sprintf("Backup the workload in %s namespace", test.testNS), func() {
|
By(fmt.Sprintf("Backup the workload in %s namespace", test.testNS), func() {
|
||||||
Expect(VeleroBackupNamespace(ctx, VeleroCfg.VeleroCLI,
|
Expect(VeleroBackupNamespace(ctx, veleroCfg.VeleroCLI,
|
||||||
VeleroCfg.VeleroNamespace, BackupCfg)).To(Succeed(), func() string {
|
veleroCfg.VeleroNamespace, BackupCfg)).To(Succeed(), func() string {
|
||||||
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, test.backupName, "")
|
RunDebug(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, test.backupName, "")
|
||||||
return "Fail to backup workload"
|
return "Fail to backup workload"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Delete %s backup files in object store", test.backupName), func() {
|
By(fmt.Sprintf("Delete %s backup files in object store", test.backupName), func() {
|
||||||
err = DeleteObjectsInBucket(VeleroCfg.ObjectStoreProvider, VeleroCfg.CloudCredentialsFile, VeleroCfg.BSLBucket,
|
err = DeleteObjectsInBucket(veleroCfg.ObjectStoreProvider, veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket,
|
||||||
VeleroCfg.BSLPrefix, VeleroCfg.BSLConfig, test.backupName, BackupObjectsPrefix)
|
veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.backupName, BackupObjectsPrefix)
|
||||||
Expect(err).To(Succeed(), fmt.Sprintf("Failed to delete object in bucket %s with err %v", test.backupName, err))
|
Expect(err).To(Succeed(), fmt.Sprintf("Failed to delete object in bucket %s with err %v", test.backupName, err))
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Check %s backup files in object store is deleted", test.backupName), func() {
|
By(fmt.Sprintf("Check %s backup files in object store is deleted", test.backupName), func() {
|
||||||
err = ObjectsShouldNotBeInBucket(VeleroCfg.ObjectStoreProvider, VeleroCfg.CloudCredentialsFile, VeleroCfg.BSLBucket,
|
err = ObjectsShouldNotBeInBucket(veleroCfg.ObjectStoreProvider, veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket,
|
||||||
VeleroCfg.BSLPrefix, VeleroCfg.BSLConfig, test.backupName, BackupObjectsPrefix, 1)
|
veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.backupName, BackupObjectsPrefix, 1)
|
||||||
Expect(err).To(Succeed(), fmt.Sprintf("Failed to delete object in bucket %s with err %v", test.backupName, err))
|
Expect(err).To(Succeed(), fmt.Sprintf("Failed to delete object in bucket %s with err %v", test.backupName, err))
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Check if backups are deleted as a result of sync from BSL", func() {
|
By("Check if backups are deleted as a result of sync from BSL", func() {
|
||||||
Expect(WaitBackupDeleted(ctx, VeleroCfg.VeleroCLI, test.backupName, time.Minute*10)).To(Succeed(), fmt.Sprintf("Failed to check backup %s deleted", test.backupName))
|
Expect(WaitBackupDeleted(ctx, test.backupName, time.Minute*10, &veleroCfg)).To(Succeed(), fmt.Sprintf("Failed to check backup %s deleted", test.backupName))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *SyncBackups) IsBackupsSynced(ctx context.Context, ctxCancel context.CancelFunc) error {
|
func (b *SyncBackups) IsBackupsSynced(ctx context.Context, veleroCfg *VeleroConfig, ctxCancel context.CancelFunc) error {
|
||||||
defer ctxCancel()
|
defer ctxCancel()
|
||||||
return WaitForBackupToBeCreated(ctx, VeleroCfg.VeleroCLI, b.backupName, 10*time.Minute)
|
return WaitForBackupToBeCreated(ctx, b.backupName, 10*time.Minute, veleroCfg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ func TTLTest() {
|
||||||
veleroCfg.GCFrequency = ""
|
veleroCfg.GCFrequency = ""
|
||||||
if !veleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||||
defer ctxCancel()
|
defer ctxCancel()
|
||||||
|
@ -175,7 +175,7 @@ func TTLTest() {
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Check if backups are deleted by GC", func() {
|
By("Check if backups are deleted by GC", func() {
|
||||||
Expect(WaitBackupDeleted(ctx, veleroCfg.VeleroCLI, test.backupName, time.Minute*10)).To(Succeed(), fmt.Sprintf("Backup %s was not deleted by GC", test.backupName))
|
Expect(WaitBackupDeleted(ctx, test.backupName, time.Minute*10, &veleroCfg)).To(Succeed(), fmt.Sprintf("Backup %s was not deleted by GC", test.backupName))
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Backup file from cloud object storage should be deleted", func() {
|
By("Backup file from cloud object storage should be deleted", func() {
|
||||||
|
|
|
@ -69,7 +69,7 @@ func APIExtensionsVersionsTest() {
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if !veleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.DefaultClient)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
if InstallVelero {
|
if InstallVelero {
|
||||||
By("Uninstall Velero and delete CRD ", func() {
|
By("Uninstall Velero and delete CRD ", func() {
|
||||||
|
@ -135,7 +135,7 @@ func APIExtensionsVersionsTest() {
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Waiting for backups sync to Velero in cluster-B (%s)", veleroCfg.StandbyClusterContext), func() {
|
By(fmt.Sprintf("Waiting for backups sync to Velero in cluster-B (%s)", veleroCfg.StandbyClusterContext), func() {
|
||||||
Expect(WaitForBackupToBeCreated(context.Background(), veleroCfg.VeleroCLI, backupName, 5*time.Minute)).To(Succeed())
|
Expect(WaitForBackupToBeCreated(context.Background(), backupName, 5*time.Minute, &veleroCfg)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("CRD %s should not exist in cluster-B (%s)", crdName, veleroCfg.StandbyClusterContext), func() {
|
By(fmt.Sprintf("CRD %s should not exist in cluster-B (%s)", crdName, veleroCfg.StandbyClusterContext), func() {
|
||||||
|
|
|
@ -94,7 +94,7 @@ func APIGropuVersionsTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
if InstallVelero {
|
if InstallVelero {
|
||||||
By("Uninstall Velero in api group version case", func() {
|
By("Uninstall Velero in api group version case", func() {
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (n *NamespaceMapping) Init() error {
|
||||||
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName,
|
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName,
|
||||||
"--include-namespaces", strings.Join(*n.NSIncluded, ","), "--wait",
|
"--include-namespaces", strings.Join(*n.NSIncluded, ","), "--wait",
|
||||||
}
|
}
|
||||||
if VeleroCfg.CloudProvider == "kind" {
|
if n.VeleroCfg.CloudProvider == "kind" {
|
||||||
// don't test volume snapshotter or file system backup on kind
|
// don't test volume snapshotter or file system backup on kind
|
||||||
n.BackupArgs = append(n.BackupArgs, "--snapshot-volumes=false")
|
n.BackupArgs = append(n.BackupArgs, "--snapshot-volumes=false")
|
||||||
n.UseVolumeSnapshots = false
|
n.UseVolumeSnapshots = false
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
|
||||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
. "github.com/vmware-tanzu/velero/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
|
@ -55,11 +54,11 @@ func (n *NodePort) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
n.BackupArgs = []string{
|
n.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", n.BackupName,
|
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName,
|
||||||
"--include-namespaces", strings.Join(*n.NSIncluded, ","), "--wait",
|
"--include-namespaces", strings.Join(*n.NSIncluded, ","), "--wait",
|
||||||
}
|
}
|
||||||
n.RestoreArgs = []string{
|
n.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore",
|
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "restore",
|
||||||
"--from-backup", n.BackupName,
|
"--from-backup", n.BackupName,
|
||||||
"--wait",
|
"--wait",
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
. "github.com/vmware-tanzu/velero/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
|
@ -55,12 +54,12 @@ func (p *PVCSelectedNodeChanging) Init() error {
|
||||||
p.pvcName = "pvc-1"
|
p.pvcName = "pvc-1"
|
||||||
p.ann = "volume.kubernetes.io/selected-node"
|
p.ann = "volume.kubernetes.io/selected-node"
|
||||||
p.BackupArgs = []string{
|
p.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", p.BackupName,
|
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "backup", p.BackupName,
|
||||||
"--include-namespaces", p.namespace,
|
"--include-namespaces", p.namespace,
|
||||||
"--snapshot-volumes=false", "--wait",
|
"--snapshot-volumes=false", "--wait",
|
||||||
}
|
}
|
||||||
p.RestoreArgs = []string{
|
p.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", p.RestoreName,
|
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "restore", p.RestoreName,
|
||||||
"--from-backup", p.BackupName, "--namespace-mappings", fmt.Sprintf("%s:%s", p.namespace, p.mappedNS), "--wait",
|
"--from-backup", p.BackupName, "--namespace-mappings", fmt.Sprintf("%s:%s", p.namespace, p.mappedNS), "--wait",
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -78,7 +77,7 @@ func (p *PVCSelectedNodeChanging) CreateResources() error {
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Create a storage class %s.", StorageClassName), func() {
|
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")
|
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() {
|
By(fmt.Sprintf("Create pod %s in namespace %s", p.podName, p.namespace), func() {
|
||||||
|
|
|
@ -53,13 +53,13 @@ func (n *NSAnnotationCase) Init() error {
|
||||||
FailedMSG: "Failed to successfully backup and restore multiple namespaces",
|
FailedMSG: "Failed to successfully backup and restore multiple namespaces",
|
||||||
}
|
}
|
||||||
n.BackupArgs = []string{
|
n.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", n.BackupName,
|
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName,
|
||||||
"--include-namespaces", strings.Join(*n.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*n.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
n.RestoreArgs = []string{
|
n.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", n.RestoreName,
|
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "restore", n.RestoreName,
|
||||||
"--from-backup", n.BackupName, "--wait",
|
"--from-backup", n.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -56,6 +56,9 @@ func (r *RBACCase) Init() error {
|
||||||
r.RestoreName = "restore-" + r.CaseBaseName
|
r.RestoreName = "restore-" + r.CaseBaseName
|
||||||
r.NamespacesTotal = 1
|
r.NamespacesTotal = 1
|
||||||
r.NSIncluded = &[]string{}
|
r.NSIncluded = &[]string{}
|
||||||
|
r.VeleroCfg = VeleroCfg
|
||||||
|
r.Client = *r.VeleroCfg.ClientToInstallVelero
|
||||||
|
|
||||||
for nsNum := 0; nsNum < r.NamespacesTotal; nsNum++ {
|
for nsNum := 0; nsNum < r.NamespacesTotal; nsNum++ {
|
||||||
createNSName := fmt.Sprintf("%s-%00000d", r.CaseBaseName, nsNum)
|
createNSName := fmt.Sprintf("%s-%00000d", r.CaseBaseName, nsNum)
|
||||||
*r.NSIncluded = append(*r.NSIncluded, createNSName)
|
*r.NSIncluded = append(*r.NSIncluded, createNSName)
|
||||||
|
@ -66,17 +69,15 @@ func (r *RBACCase) Init() error {
|
||||||
FailedMSG: "Failed to successfully backup and restore RBAC",
|
FailedMSG: "Failed to successfully backup and restore RBAC",
|
||||||
}
|
}
|
||||||
r.BackupArgs = []string{
|
r.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", r.BackupName,
|
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "backup", r.BackupName,
|
||||||
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
r.RestoreArgs = []string{
|
r.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
|
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
|
||||||
"--from-backup", r.BackupName, "--wait",
|
"--from-backup", r.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
r.VeleroCfg = VeleroCfg
|
|
||||||
r.Client = *r.VeleroCfg.ClientToInstallVelero
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
. "github.com/vmware-tanzu/velero/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
|
@ -60,12 +59,12 @@ func (s *StorageClasssChanging) Init() error {
|
||||||
s.pvcName = fmt.Sprintf("pvc-%s", s.volume)
|
s.pvcName = fmt.Sprintf("pvc-%s", s.volume)
|
||||||
s.podName = "pod-1"
|
s.podName = "pod-1"
|
||||||
s.BackupArgs = []string{
|
s.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", s.BackupName,
|
"create", "--namespace", s.VeleroCfg.VeleroNamespace, "backup", s.BackupName,
|
||||||
"--include-namespaces", s.namespace,
|
"--include-namespaces", s.namespace,
|
||||||
"--snapshot-volumes=false", "--wait",
|
"--snapshot-volumes=false", "--wait",
|
||||||
}
|
}
|
||||||
s.RestoreArgs = []string{
|
s.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", s.RestoreName,
|
"create", "--namespace", s.VeleroCfg.VeleroNamespace, "restore", s.RestoreName,
|
||||||
"--from-backup", s.BackupName, "--namespace-mappings", fmt.Sprintf("%s:%s", s.namespace, s.mappedNS), "--wait",
|
"--from-backup", s.BackupName, "--namespace-mappings", fmt.Sprintf("%s:%s", s.namespace, s.mappedNS), "--wait",
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -76,7 +76,8 @@ func BslDeletionTest(useVolumeSnapshots bool) {
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if !veleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.DefaultClient)
|
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
|
||||||
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
By(fmt.Sprintf("Delete sample workload namespace %s", bslDeletionTestNs), func() {
|
By(fmt.Sprintf("Delete sample workload namespace %s", bslDeletionTestNs), func() {
|
||||||
Expect(DeleteNamespace(context.Background(), *veleroCfg.ClientToInstallVelero, bslDeletionTestNs,
|
Expect(DeleteNamespace(context.Background(), *veleroCfg.ClientToInstallVelero, bslDeletionTestNs,
|
||||||
|
@ -255,13 +256,13 @@ func BslDeletionTest(useVolumeSnapshots bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
By(fmt.Sprintf("Backup 1 %s should be created.", backupName_1), func() {
|
By(fmt.Sprintf("Backup 1 %s should be created.", backupName_1), func() {
|
||||||
Expect(WaitForBackupToBeCreated(context.Background(), veleroCfg.VeleroCLI,
|
Expect(WaitForBackupToBeCreated(context.Background(),
|
||||||
backupName_1, 10*time.Minute)).To(Succeed())
|
backupName_1, 10*time.Minute, &veleroCfg)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Backup 2 %s should be created.", backupName_2), func() {
|
By(fmt.Sprintf("Backup 2 %s should be created.", backupName_2), func() {
|
||||||
Expect(WaitForBackupToBeCreated(context.Background(), veleroCfg.VeleroCLI,
|
Expect(WaitForBackupToBeCreated(context.Background(),
|
||||||
backupName_2, 10*time.Minute)).To(Succeed())
|
backupName_2, 10*time.Minute, &veleroCfg)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
backupsInBSL1, err := GetBackupsFromBsl(context.Background(), veleroCfg.VeleroCLI, backupLocation_1)
|
backupsInBSL1, err := GetBackupsFromBsl(context.Background(), veleroCfg.VeleroCLI, backupLocation_1)
|
||||||
|
@ -283,7 +284,7 @@ func BslDeletionTest(useVolumeSnapshots bool) {
|
||||||
|
|
||||||
By(fmt.Sprintf("Delete one of backup locations - %s", backupLocation_1), func() {
|
By(fmt.Sprintf("Delete one of backup locations - %s", backupLocation_1), func() {
|
||||||
Expect(DeleteBslResource(context.Background(), veleroCfg.VeleroCLI, backupLocation_1)).To(Succeed())
|
Expect(DeleteBslResource(context.Background(), veleroCfg.VeleroCLI, backupLocation_1)).To(Succeed())
|
||||||
Expect(WaitForBackupsToBeDeleted(context.Background(), veleroCfg.VeleroCLI, backupsInBSL1, 10*time.Minute)).To(Succeed())
|
Expect(WaitForBackupsToBeDeleted(context.Background(), backupsInBSL1, 10*time.Minute, &veleroCfg)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
By("Get all backups from 2 BSLs after deleting one of them", func() {
|
By("Get all backups from 2 BSLs after deleting one of them", func() {
|
||||||
|
|
|
@ -305,8 +305,8 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Waiting for backups sync to Velero in cluster-B (%s)", veleroCfg.StandbyClusterContext), func() {
|
By(fmt.Sprintf("Waiting for backups sync to Velero in cluster-B (%s)", veleroCfg.StandbyClusterContext), func() {
|
||||||
Expect(WaitForBackupToBeCreated(context.Background(), veleroCfg.VeleroCLI, backupName, 5*time.Minute)).To(Succeed())
|
Expect(WaitForBackupToBeCreated(context.Background(), backupName, 5*time.Minute, &veleroCfg)).To(Succeed())
|
||||||
Expect(WaitForBackupToBeCreated(context.Background(), veleroCfg.VeleroCLI, backupScName, 5*time.Minute)).To(Succeed())
|
Expect(WaitForBackupToBeCreated(context.Background(), backupScName, 5*time.Minute, &veleroCfg)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Restore %s", migrationNamespace), func() {
|
By(fmt.Sprintf("Restore %s", migrationNamespace), func() {
|
||||||
|
@ -346,7 +346,8 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||||
|
|
||||||
// TODO: delete backup created by case self, not all
|
// TODO: delete backup created by case self, not all
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteBackups(context.Background(), *veleroCfg.DefaultClient, backupNames)
|
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
|
||||||
|
DeleteBackups(context.Background(), backupNames, &veleroCfg)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (p *PVBackupFiltering) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
p.BackupArgs = []string{
|
p.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", p.BackupName,
|
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "backup", p.BackupName,
|
||||||
"--include-namespaces", strings.Join(*p.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*p.NSIncluded, ","),
|
||||||
"--snapshot-volumes=false", "--wait",
|
"--snapshot-volumes=false", "--wait",
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func (p *PVBackupFiltering) Init() error {
|
||||||
|
|
||||||
}
|
}
|
||||||
p.RestoreArgs = []string{
|
p.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", p.RestoreName,
|
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "restore", p.RestoreName,
|
||||||
"--from-backup", p.BackupName, "--wait",
|
"--from-backup", p.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -67,7 +67,7 @@ func (p *PVBackupFiltering) Init() error {
|
||||||
|
|
||||||
func (p *PVBackupFiltering) CreateResources() error {
|
func (p *PVBackupFiltering) CreateResources() error {
|
||||||
p.Ctx, p.CtxCancel = context.WithTimeout(context.Background(), 30*time.Minute)
|
p.Ctx, p.CtxCancel = context.WithTimeout(context.Background(), 30*time.Minute)
|
||||||
err := InstallStorageClass(p.Ctx, fmt.Sprintf("../testdata/storage-class/%s.yaml", VeleroCfg.CloudProvider))
|
err := InstallStorageClass(p.Ctx, fmt.Sprintf("../testdata/storage-class/%s.yaml", p.VeleroCfg.CloudProvider))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to install storage class for pv backup filtering test")
|
return errors.Wrapf(err, "failed to install storage class for pv backup filtering test")
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,12 @@ func (f *FilteringCase) Init() error {
|
||||||
f.Client = *f.VeleroCfg.ClientToInstallVelero
|
f.Client = *f.VeleroCfg.ClientToInstallVelero
|
||||||
f.NamespacesTotal = 3
|
f.NamespacesTotal = 3
|
||||||
f.BackupArgs = []string{
|
f.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", f.BackupName,
|
"create", "--namespace", f.VeleroCfg.VeleroNamespace, "backup", f.BackupName,
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
f.RestoreArgs = []string{
|
f.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", f.RestoreName,
|
"create", "--namespace", f.VeleroCfg.VeleroNamespace, "restore", f.RestoreName,
|
||||||
"--from-backup", f.BackupName, "--wait",
|
"--from-backup", f.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,9 @@ import (
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/pkg/errors"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
)
|
)
|
||||||
|
@ -64,13 +62,13 @@ func (e *ExcludeFromBackup) Init() error {
|
||||||
e.labelSelector = "velero.io/exclude-from-backup"
|
e.labelSelector = "velero.io/exclude-from-backup"
|
||||||
|
|
||||||
e.BackupArgs = []string{
|
e.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
||||||
"--include-namespaces", e.CaseBaseName,
|
"--include-namespaces", e.CaseBaseName,
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
e.RestoreArgs = []string{
|
e.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||||
"--from-backup", e.BackupName, "--wait",
|
"--from-backup", e.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
)
|
)
|
||||||
|
@ -81,27 +80,27 @@ func (e *ExcludeNamespaces) Init() error {
|
||||||
}
|
}
|
||||||
if e.IsTestInBackup {
|
if e.IsTestInBackup {
|
||||||
e.BackupArgs = []string{
|
e.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
||||||
"--exclude-namespaces", strings.Join(*e.nsExcluded, ","),
|
"--exclude-namespaces", strings.Join(*e.nsExcluded, ","),
|
||||||
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
e.RestoreArgs = []string{
|
e.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||||
"--from-backup", e.BackupName, "--wait",
|
"--from-backup", e.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*e.NSIncluded = append(*e.NSIncluded, *e.nsExcluded...)
|
*e.NSIncluded = append(*e.NSIncluded, *e.nsExcluded...)
|
||||||
e.BackupArgs = []string{
|
e.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
||||||
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
e.RestoreArgs = []string{
|
e.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||||
"--exclude-namespaces", strings.Join(*e.nsExcluded, ","),
|
"--exclude-namespaces", strings.Join(*e.nsExcluded, ","),
|
||||||
"--from-backup", e.BackupName, "--wait",
|
"--from-backup", e.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,14 +62,14 @@ func (e *ExcludeResources) Init() error {
|
||||||
e.BackupName = "backup-" + e.CaseBaseName
|
e.BackupName = "backup-" + e.CaseBaseName
|
||||||
e.RestoreName = "restore-" + UUIDgen.String()
|
e.RestoreName = "restore-" + UUIDgen.String()
|
||||||
e.BackupArgs = []string{
|
e.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
||||||
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
||||||
"--exclude-resources", "secrets",
|
"--exclude-resources", "secrets",
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
e.RestoreArgs = []string{
|
e.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||||
"--from-backup", e.BackupName, "--wait",
|
"--from-backup", e.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
} else { // testing case restore with exclude-resources option
|
} else { // testing case restore with exclude-resources option
|
||||||
|
@ -81,12 +81,12 @@ func (e *ExcludeResources) Init() error {
|
||||||
FailedMSG: "Failed to restore with resource exclude",
|
FailedMSG: "Failed to restore with resource exclude",
|
||||||
}
|
}
|
||||||
e.BackupArgs = []string{
|
e.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "backup", e.BackupName,
|
||||||
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*e.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
e.RestoreArgs = []string{
|
e.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||||
"--exclude-resources", "secrets",
|
"--exclude-resources", "secrets",
|
||||||
"--from-backup", e.BackupName, "--wait",
|
"--from-backup", e.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
)
|
)
|
||||||
|
@ -71,13 +70,13 @@ func (i *IncludeNamespaces) Init() error {
|
||||||
Text: fmt.Sprintf("should backup %d namespaces of %d", i.namespacesIncluded, i.NamespacesTotal),
|
Text: fmt.Sprintf("should backup %d namespaces of %d", i.namespacesIncluded, i.NamespacesTotal),
|
||||||
}
|
}
|
||||||
i.BackupArgs = []string{
|
i.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
||||||
"--include-namespaces", strings.Join(*i.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*i.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
i.RestoreArgs = []string{
|
i.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
||||||
"--from-backup", i.BackupName, "--wait",
|
"--from-backup", i.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +89,13 @@ func (i *IncludeNamespaces) Init() error {
|
||||||
Text: fmt.Sprintf("should restore %d namespaces of %d", i.namespacesIncluded, i.NamespacesTotal),
|
Text: fmt.Sprintf("should restore %d namespaces of %d", i.namespacesIncluded, i.NamespacesTotal),
|
||||||
}
|
}
|
||||||
i.BackupArgs = []string{
|
i.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
||||||
"--include-namespaces", strings.Join(*i.allTestNamespaces, ","),
|
"--include-namespaces", strings.Join(*i.allTestNamespaces, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
i.RestoreArgs = []string{
|
i.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
||||||
"--include-namespaces", strings.Join(*i.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*i.NSIncluded, ","),
|
||||||
"--from-backup", i.BackupName, "--wait",
|
"--from-backup", i.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
)
|
)
|
||||||
|
@ -60,13 +59,13 @@ func (i *IncludeResources) Init() error {
|
||||||
i.BackupName = "backup-" + i.CaseBaseName
|
i.BackupName = "backup-" + i.CaseBaseName
|
||||||
i.RestoreName = "restore-" + i.UUIDgen
|
i.RestoreName = "restore-" + i.UUIDgen
|
||||||
i.BackupArgs = []string{
|
i.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
||||||
"--include-resources", "deployments,configmaps",
|
"--include-resources", "deployments,configmaps",
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
i.RestoreArgs = []string{
|
i.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
||||||
"--from-backup", i.BackupName, "--wait",
|
"--from-backup", i.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
} else { // testing case restore with include-resources option
|
} else { // testing case restore with include-resources option
|
||||||
|
@ -78,12 +77,12 @@ func (i *IncludeResources) Init() error {
|
||||||
i.BackupName = "backup-" + i.UUIDgen
|
i.BackupName = "backup-" + i.UUIDgen
|
||||||
i.RestoreName = "restore-" + i.CaseBaseName
|
i.RestoreName = "restore-" + i.CaseBaseName
|
||||||
i.BackupArgs = []string{
|
i.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "backup", i.BackupName,
|
||||||
"--include-namespaces", strings.Join(*i.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*i.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
i.RestoreArgs = []string{
|
i.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
||||||
"--include-resources", "deployments,configmaps",
|
"--include-resources", "deployments,configmaps",
|
||||||
"--from-backup", i.BackupName, "--wait",
|
"--from-backup", i.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import (
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
|
||||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||||
)
|
)
|
||||||
|
@ -62,14 +61,14 @@ func (l *LabelSelector) Init() error {
|
||||||
}
|
}
|
||||||
l.labelSelector = "resourcefiltering"
|
l.labelSelector = "resourcefiltering"
|
||||||
l.BackupArgs = []string{
|
l.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", l.BackupName,
|
"create", "--namespace", l.VeleroCfg.VeleroNamespace, "backup", l.BackupName,
|
||||||
"--selector", "resourcefiltering=true",
|
"--selector", "resourcefiltering=true",
|
||||||
"--include-namespaces", strings.Join(*l.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*l.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup", "--wait",
|
"--default-volumes-to-fs-backup", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
l.RestoreArgs = []string{
|
l.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", l.RestoreName,
|
"create", "--namespace", l.VeleroCfg.VeleroNamespace, "restore", l.RestoreName,
|
||||||
"--from-backup", l.BackupName, "--wait",
|
"--from-backup", l.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
. "github.com/vmware-tanzu/velero/test"
|
. "github.com/vmware-tanzu/velero/test"
|
||||||
|
@ -80,13 +79,13 @@ func (r *ResourceModifiersCase) Init() error {
|
||||||
r.VeleroCfg.UseNodeAgent = false
|
r.VeleroCfg.UseNodeAgent = false
|
||||||
|
|
||||||
r.BackupArgs = []string{
|
r.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", r.BackupName,
|
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "backup", r.BackupName,
|
||||||
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
|
||||||
"--snapshot-volumes=false", "--wait",
|
"--snapshot-volumes=false", "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
r.RestoreArgs = []string{
|
r.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
|
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
|
||||||
"--resource-modifier-configmap", r.cmName,
|
"--resource-modifier-configmap", r.cmName,
|
||||||
"--from-backup", r.BackupName, "--wait",
|
"--from-backup", r.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (r *ResourcePoliciesCase) Init() error {
|
||||||
|
|
||||||
// NEED explicitly specify the value of the variables for snapshot-volumes or default-volumes-to-fs-backup
|
// NEED explicitly specify the value of the variables for snapshot-volumes or default-volumes-to-fs-backup
|
||||||
r.BackupArgs = []string{
|
r.BackupArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", r.BackupName,
|
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "backup", r.BackupName,
|
||||||
"--resource-policies-configmap", r.cmName,
|
"--resource-policies-configmap", r.cmName,
|
||||||
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
|
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
|
||||||
"--default-volumes-to-fs-backup",
|
"--default-volumes-to-fs-backup",
|
||||||
|
@ -91,7 +91,7 @@ func (r *ResourcePoliciesCase) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
r.RestoreArgs = []string{
|
r.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
|
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
|
||||||
"--from-backup", r.BackupName, "--wait",
|
"--from-backup", r.BackupName, "--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ func (r *ResourcePoliciesCase) CreateResources() error {
|
||||||
r.Ctx, r.CtxCancel = context.WithTimeout(context.Background(), 10*time.Minute)
|
r.Ctx, r.CtxCancel = context.WithTimeout(context.Background(), 10*time.Minute)
|
||||||
|
|
||||||
By(("Installing storage class..."), func() {
|
By(("Installing storage class..."), func() {
|
||||||
Expect(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", r.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() {
|
By(fmt.Sprintf("Create configmap %s in namespaces %s for workload\n", r.cmName, r.VeleroCfg.VeleroNamespace), func() {
|
||||||
|
|
|
@ -91,8 +91,8 @@ func (n *ScheduleBackupCreation) Backup() error {
|
||||||
now := time.Now().Minute()
|
now := time.Now().Minute()
|
||||||
triggerNow := now % n.Period
|
triggerNow := now % n.Period
|
||||||
if triggerNow == 0 {
|
if triggerNow == 0 {
|
||||||
Expect(VeleroScheduleCreate(n.Ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, n.ScheduleName, n.ScheduleArgs)).To(Succeed(), func() string {
|
Expect(VeleroScheduleCreate(n.Ctx, n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, n.ScheduleName, n.ScheduleArgs)).To(Succeed(), func() string {
|
||||||
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, "", "")
|
RunDebug(context.Background(), n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, "", "")
|
||||||
return "Fail to create schedule"
|
return "Fail to create schedule"
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -110,7 +110,7 @@ func (n *ScheduleBackupCreation) Backup() error {
|
||||||
mi, _ := time.ParseDuration("60s")
|
mi, _ := time.ParseDuration("60s")
|
||||||
time.Sleep(n.podSleepDuration + mi)
|
time.Sleep(n.podSleepDuration + mi)
|
||||||
bMap := make(map[string]string)
|
bMap := make(map[string]string)
|
||||||
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, n.VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
||||||
Expect(err).To(Succeed())
|
Expect(err).To(Succeed())
|
||||||
Expect(len(backupsInfo) == i).To(Equal(true))
|
Expect(len(backupsInfo) == i).To(Equal(true))
|
||||||
for index, bi := range backupsInfo {
|
for index, bi := range backupsInfo {
|
||||||
|
|
|
@ -77,8 +77,8 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
now := time.Now().Minute()
|
now := time.Now().Minute()
|
||||||
triggerNow := now % n.Period
|
triggerNow := now % n.Period
|
||||||
if triggerNow == 0 {
|
if triggerNow == 0 {
|
||||||
Expect(VeleroScheduleCreate(n.Ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, n.ScheduleName, n.ScheduleArgs)).To(Succeed(), func() string {
|
Expect(VeleroScheduleCreate(n.Ctx, n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, n.ScheduleName, n.ScheduleArgs)).To(Succeed(), func() string {
|
||||||
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, "", "")
|
RunDebug(context.Background(), n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, "", "")
|
||||||
return "Fail to create schedule"
|
return "Fail to create schedule"
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -87,7 +87,7 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Schedule %s is created without any delay\n", n.ScheduleName), func() {
|
By(fmt.Sprintf("Schedule %s is created without any delay\n", n.ScheduleName), func() {
|
||||||
creationTimestamp, err := GetSchedule(n.Ctx, VeleroCfg.VeleroNamespace, n.ScheduleName)
|
creationTimestamp, err := GetSchedule(n.Ctx, n.VeleroCfg.VeleroNamespace, n.ScheduleName)
|
||||||
Expect(err).To(Succeed())
|
Expect(err).To(Succeed())
|
||||||
|
|
||||||
creationTime, err := time.Parse(time.RFC3339, strings.Replace(creationTimestamp, "'", "", -1))
|
creationTime, err := time.Parse(time.RFC3339, strings.Replace(creationTimestamp, "'", "", -1))
|
||||||
|
@ -105,7 +105,7 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
fmt.Printf("Get backup for #%d time at %v\n", i, now)
|
fmt.Printf("Get backup for #%d time at %v\n", i, now)
|
||||||
//Ignore the last minute in the period avoiding met the 1st backup by schedule
|
//Ignore the last minute in the period avoiding met the 1st backup by schedule
|
||||||
if i != n.Period-1 {
|
if i != n.Period-1 {
|
||||||
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, n.VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
||||||
Expect(err).To(Succeed())
|
Expect(err).To(Succeed())
|
||||||
Expect(len(backupsInfo) == 0).To(Equal(true))
|
Expect(len(backupsInfo) == 0).To(Equal(true))
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
fmt.Printf("Start to sleep %d minute #%d time...\n", n.Period, i+1)
|
fmt.Printf("Start to sleep %d minute #%d time...\n", n.Period, i+1)
|
||||||
time.Sleep(time.Duration(n.Period) * time.Minute)
|
time.Sleep(time.Duration(n.Period) * time.Minute)
|
||||||
bMap := make(map[string]string)
|
bMap := make(map[string]string)
|
||||||
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, n.VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
||||||
Expect(err).To(Succeed())
|
Expect(err).To(Succeed())
|
||||||
Expect(len(backupsInfo) == i+2).To(Equal(true))
|
Expect(len(backupsInfo) == i+2).To(Equal(true))
|
||||||
for index, bi := range backupsInfo {
|
for index, bi := range backupsInfo {
|
||||||
|
@ -141,19 +141,19 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
n.BackupName = strings.Replace(n.randBackupName, " ", "", -1)
|
n.BackupName = strings.Replace(n.randBackupName, " ", "", -1)
|
||||||
|
|
||||||
n.RestoreArgs = []string{
|
n.RestoreArgs = []string{
|
||||||
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", n.RestoreName,
|
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "restore", n.RestoreName,
|
||||||
"--from-backup", n.BackupName,
|
"--from-backup", n.BackupName,
|
||||||
"--wait",
|
"--wait",
|
||||||
}
|
}
|
||||||
|
|
||||||
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
backupsInfo, err := GetScheduledBackupsCreationTime(n.Ctx, n.VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
||||||
Expect(err).To(Succeed(), fmt.Sprintf("Fail to get backups from schedule %s", n.ScheduleName))
|
Expect(err).To(Succeed(), fmt.Sprintf("Fail to get backups from schedule %s", n.ScheduleName))
|
||||||
fmt.Println(backupsInfo)
|
fmt.Println(backupsInfo)
|
||||||
backupCount := len(backupsInfo)
|
backupCount := len(backupsInfo)
|
||||||
|
|
||||||
By(fmt.Sprintf("Pause schedule %s ......\n", n.ScheduleName), func() {
|
By(fmt.Sprintf("Pause schedule %s ......\n", n.ScheduleName), func() {
|
||||||
Expect(VeleroSchedulePause(n.Ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, n.ScheduleName)).To(Succeed(), func() string {
|
Expect(VeleroSchedulePause(n.Ctx, n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, n.ScheduleName)).To(Succeed(), func() string {
|
||||||
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, "", "")
|
RunDebug(context.Background(), n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, "", "")
|
||||||
return "Fail to pause schedule"
|
return "Fail to pause schedule"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -164,7 +164,7 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
time.Sleep(sleepDuration)
|
time.Sleep(sleepDuration)
|
||||||
})
|
})
|
||||||
|
|
||||||
backupsInfo, err = GetScheduledBackupsCreationTime(n.Ctx, VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
backupsInfo, err = GetScheduledBackupsCreationTime(n.Ctx, n.VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
||||||
Expect(err).To(Succeed(), fmt.Sprintf("Fail to get backups from schedule %s", n.ScheduleName))
|
Expect(err).To(Succeed(), fmt.Sprintf("Fail to get backups from schedule %s", n.ScheduleName))
|
||||||
|
|
||||||
backupCountPostPause := len(backupsInfo)
|
backupCountPostPause := len(backupsInfo)
|
||||||
|
@ -175,8 +175,8 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
})
|
})
|
||||||
|
|
||||||
By(fmt.Sprintf("Unpause schedule %s ......\n", n.ScheduleName), func() {
|
By(fmt.Sprintf("Unpause schedule %s ......\n", n.ScheduleName), func() {
|
||||||
Expect(VeleroScheduleUnpause(n.Ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, n.ScheduleName)).To(Succeed(), func() string {
|
Expect(VeleroScheduleUnpause(n.Ctx, n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, n.ScheduleName)).To(Succeed(), func() string {
|
||||||
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, "", "")
|
RunDebug(context.Background(), n.VeleroCfg.VeleroCLI, n.VeleroCfg.VeleroNamespace, "", "")
|
||||||
return "Fail to unpause schedule"
|
return "Fail to unpause schedule"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -185,7 +185,7 @@ func (n *ScheduleBackup) Backup() error {
|
||||||
time.Sleep(sleepDuration)
|
time.Sleep(sleepDuration)
|
||||||
})
|
})
|
||||||
|
|
||||||
backupsInfo, err = GetScheduledBackupsCreationTime(n.Ctx, VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
backupsInfo, err = GetScheduledBackupsCreationTime(n.Ctx, n.VeleroCfg.VeleroCLI, "default", n.ScheduleName)
|
||||||
Expect(err).To(Succeed(), fmt.Sprintf("Fail to get backups from schedule %s", n.ScheduleName))
|
Expect(err).To(Succeed(), fmt.Sprintf("Fail to get backups from schedule %s", n.ScheduleName))
|
||||||
fmt.Println(backupsInfo)
|
fmt.Println(backupsInfo)
|
||||||
backupCountPostUnpause := len(backupsInfo)
|
backupCountPostUnpause := len(backupsInfo)
|
||||||
|
|
|
@ -190,7 +190,8 @@ func (t *TestCase) Clean() error {
|
||||||
CleanupNamespaces(t.Ctx, t.Client, t.CaseBaseName)
|
CleanupNamespaces(t.Ctx, t.Client, t.CaseBaseName)
|
||||||
})
|
})
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(t.Ctx, t.Client)
|
veleroCfg.ClientToInstallVelero = &t.Client
|
||||||
|
DeleteAllBackups(t.Ctx, &veleroCfg)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -87,7 +87,7 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if !veleroCfg.Debug {
|
if !veleroCfg.Debug {
|
||||||
By("Clean backups after test", func() {
|
By("Clean backups after test", func() {
|
||||||
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
|
DeleteAllBackups(context.Background(), &veleroCfg)
|
||||||
})
|
})
|
||||||
By(fmt.Sprintf("Delete sample workload namespace %s", upgradeNamespace), func() {
|
By(fmt.Sprintf("Delete sample workload namespace %s", upgradeNamespace), func() {
|
||||||
DeleteNamespace(context.Background(), *veleroCfg.ClientToInstallVelero, upgradeNamespace, true)
|
DeleteNamespace(context.Background(), *veleroCfg.ClientToInstallVelero, upgradeNamespace, true)
|
||||||
|
|
|
@ -105,7 +105,7 @@ func VeleroInstall(ctx context.Context, veleroCfg *VeleroConfig, isStandbyCluste
|
||||||
if veleroCfg.ObjectStoreProvider == "" {
|
if veleroCfg.ObjectStoreProvider == "" {
|
||||||
veleroCfg.ObjectStoreProvider = "aws"
|
veleroCfg.ObjectStoreProvider = "aws"
|
||||||
}
|
}
|
||||||
if err := configvSpherePlugin(*veleroCfg.ClientToInstallVelero); err != nil {
|
if err := configvSpherePlugin(veleroCfg); err != nil {
|
||||||
return errors.WithMessagef(err, "Failed to config vsphere plugin")
|
return errors.WithMessagef(err, "Failed to config vsphere plugin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,34 +162,35 @@ func VeleroInstall(ctx context.Context, veleroCfg *VeleroConfig, isStandbyCluste
|
||||||
}
|
}
|
||||||
|
|
||||||
// configvSpherePlugin refers to https://github.com/vmware-tanzu/velero-plugin-for-vsphere/blob/v1.3.0/docs/vanilla.md
|
// configvSpherePlugin refers to https://github.com/vmware-tanzu/velero-plugin-for-vsphere/blob/v1.3.0/docs/vanilla.md
|
||||||
func configvSpherePlugin(cli TestClient) error {
|
func configvSpherePlugin(veleroCfg *VeleroConfig) error {
|
||||||
|
cli := veleroCfg.ClientToInstallVelero
|
||||||
var err error
|
var err error
|
||||||
vsphereSecret := "velero-vsphere-config-secret"
|
vsphereSecret := "velero-vsphere-config-secret"
|
||||||
configmaptName := "velero-vsphere-plugin-config"
|
configmaptName := "velero-vsphere-plugin-config"
|
||||||
if err := clearupvSpherePluginConfig(cli.ClientGo, VeleroCfg.VeleroNamespace, vsphereSecret, configmaptName); err != nil {
|
if err := clearupvSpherePluginConfig(cli.ClientGo, veleroCfg.VeleroNamespace, vsphereSecret, configmaptName); err != nil {
|
||||||
return errors.WithMessagef(err, "Failed to clear up vsphere plugin config %s namespace", VeleroCfg.VeleroNamespace)
|
return errors.WithMessagef(err, "Failed to clear up vsphere plugin config %s namespace", veleroCfg.VeleroNamespace)
|
||||||
}
|
}
|
||||||
if err := CreateNamespace(context.Background(), cli, VeleroCfg.VeleroNamespace); err != nil {
|
if err := CreateNamespace(context.Background(), *cli, veleroCfg.VeleroNamespace); err != nil {
|
||||||
return errors.WithMessagef(err, "Failed to create Velero %s namespace", VeleroCfg.VeleroNamespace)
|
return errors.WithMessagef(err, "Failed to create Velero %s namespace", veleroCfg.VeleroNamespace)
|
||||||
}
|
}
|
||||||
if err := createVCCredentialSecret(cli.ClientGo, VeleroCfg.VeleroNamespace); err != nil {
|
if err := createVCCredentialSecret(cli.ClientGo, veleroCfg.VeleroNamespace); err != nil {
|
||||||
return errors.WithMessagef(err, "Failed to create virtual center credential secret in %s namespace", VeleroCfg.VeleroNamespace)
|
return errors.WithMessagef(err, "Failed to create virtual center credential secret in %s namespace", veleroCfg.VeleroNamespace)
|
||||||
}
|
}
|
||||||
if err := WaitForSecretsComplete(cli.ClientGo, VeleroCfg.VeleroNamespace, vsphereSecret); err != nil {
|
if err := WaitForSecretsComplete(cli.ClientGo, veleroCfg.VeleroNamespace, vsphereSecret); err != nil {
|
||||||
return errors.Wrap(err, "Failed to ensure velero-vsphere-config-secret secret completion in namespace kube-system")
|
return errors.Wrap(err, "Failed to ensure velero-vsphere-config-secret secret completion in namespace kube-system")
|
||||||
}
|
}
|
||||||
_, err = CreateConfigMap(cli.ClientGo, VeleroCfg.VeleroNamespace, configmaptName, map[string]string{
|
_, err = CreateConfigMap(cli.ClientGo, veleroCfg.VeleroNamespace, configmaptName, map[string]string{
|
||||||
"cluster_flavor": "VANILLA",
|
"cluster_flavor": "VANILLA",
|
||||||
"vsphere_secret_name": vsphereSecret,
|
"vsphere_secret_name": vsphereSecret,
|
||||||
"vsphere_secret_namespace": VeleroCfg.VeleroNamespace,
|
"vsphere_secret_namespace": veleroCfg.VeleroNamespace,
|
||||||
}, nil)
|
}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "Failed to create velero-vsphere-plugin-config configmap in %s namespace", VeleroCfg.VeleroNamespace)
|
return errors.WithMessagef(err, "Failed to create velero-vsphere-plugin-config configmap in %s namespace", veleroCfg.VeleroNamespace)
|
||||||
}
|
}
|
||||||
fmt.Println("configvSpherePlugin: WaitForConfigMapComplete")
|
|
||||||
err = WaitForConfigMapComplete(cli.ClientGo, VeleroCfg.VeleroNamespace, configmaptName)
|
err = WaitForConfigMapComplete(cli.ClientGo, veleroCfg.VeleroNamespace, configmaptName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, fmt.Sprintf("Failed to ensure configmap %s completion in namespace: %s", configmaptName, VeleroCfg.VeleroNamespace))
|
return errors.Wrap(err, fmt.Sprintf("Failed to ensure configmap %s completion in namespace: %s", configmaptName, veleroCfg.VeleroNamespace))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -559,7 +560,9 @@ func waitVeleroReady(ctx context.Context, namespace string, useNodeAgent bool) e
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsVeleroReady(ctx context.Context, namespace string, useNodeAgent bool) (bool, error) {
|
func IsVeleroReady(ctx context.Context, veleroCfg *VeleroConfig) (bool, error) {
|
||||||
|
namespace := veleroCfg.VeleroNamespace
|
||||||
|
useNodeAgent := veleroCfg.UseNodeAgent
|
||||||
if useNodeAgent {
|
if useNodeAgent {
|
||||||
stdout, stderr, err := velerexec.RunCommand(exec.CommandContext(ctx, "kubectl", "get", "daemonset/node-agent",
|
stdout, stderr, err := velerexec.RunCommand(exec.CommandContext(ctx, "kubectl", "get", "daemonset/node-agent",
|
||||||
"-o", "json", "-n", namespace))
|
"-o", "json", "-n", namespace))
|
||||||
|
@ -594,14 +597,14 @@ func IsVeleroReady(ctx context.Context, namespace string, useNodeAgent bool) (bo
|
||||||
stdout, stderr, err = velerexec.RunCommand(exec.CommandContext(ctx, "kubectl", "get", "bsl", "default",
|
stdout, stderr, err = velerexec.RunCommand(exec.CommandContext(ctx, "kubectl", "get", "bsl", "default",
|
||||||
"-o", "json", "-n", namespace))
|
"-o", "json", "-n", namespace))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrapf(err, "failed to get bsl %s stdout=%s, stderr=%s", VeleroCfg.BSLBucket, stdout, stderr)
|
return false, errors.Wrapf(err, "failed to get bsl %s stdout=%s, stderr=%s", veleroCfg.BSLBucket, stdout, stderr)
|
||||||
} else {
|
} else {
|
||||||
bsl := &velerov1api.BackupStorageLocation{}
|
bsl := &velerov1api.BackupStorageLocation{}
|
||||||
if err = json.Unmarshal([]byte(stdout), bsl); err != nil {
|
if err = json.Unmarshal([]byte(stdout), bsl); err != nil {
|
||||||
return false, errors.Wrapf(err, "failed to unmarshal the velero bsl")
|
return false, errors.Wrapf(err, "failed to unmarshal the velero bsl")
|
||||||
}
|
}
|
||||||
if bsl.Status.Phase != velerov1api.BackupStorageLocationPhaseAvailable {
|
if bsl.Status.Phase != velerov1api.BackupStorageLocationPhaseAvailable {
|
||||||
return false, fmt.Errorf("current bsl %s is not available", VeleroCfg.BSLBucket)
|
return false, fmt.Errorf("current bsl %s is not available", veleroCfg.BSLBucket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +612,7 @@ func IsVeleroReady(ctx context.Context, namespace string, useNodeAgent bool) (bo
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrepareVelero(ctx context.Context, caseName string, veleroCfg VeleroConfig) error {
|
func PrepareVelero(ctx context.Context, caseName string, veleroCfg VeleroConfig) error {
|
||||||
ready, err := IsVeleroReady(context.Background(), veleroCfg.VeleroNamespace, veleroCfg.UseNodeAgent)
|
ready, err := IsVeleroReady(context.Background(), &veleroCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error in checking velero status with %v", err)
|
fmt.Printf("error in checking velero status with %v", err)
|
||||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||||
|
|
|
@ -935,8 +935,9 @@ func getVeleroCliTarball(cliTarballUrl string) (*os.File, error) {
|
||||||
return tmpfile, nil
|
return tmpfile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteBackupResource(ctx context.Context, veleroCLI string, backupName string) error {
|
func DeleteBackupResource(ctx context.Context, backupName string, velerocfg *VeleroConfig) error {
|
||||||
args := []string{"--namespace", VeleroCfg.VeleroNamespace, "backup", "delete", backupName, "--confirm"}
|
veleroCLI := velerocfg.VeleroCLI
|
||||||
|
args := []string{"--namespace", velerocfg.VeleroNamespace, "backup", "delete", backupName, "--confirm"}
|
||||||
|
|
||||||
cmd := exec.CommandContext(ctx, veleroCLI, args...)
|
cmd := exec.CommandContext(ctx, veleroCLI, args...)
|
||||||
fmt.Println("Delete backup Command:" + cmd.String())
|
fmt.Println("Delete backup Command:" + cmd.String())
|
||||||
|
@ -948,7 +949,7 @@ func DeleteBackupResource(ctx context.Context, veleroCLI string, backupName stri
|
||||||
output := strings.Replace(stdout, "\n", " ", -1)
|
output := strings.Replace(stdout, "\n", " ", -1)
|
||||||
fmt.Println("Backup delete command output:" + output)
|
fmt.Println("Backup delete command output:" + output)
|
||||||
|
|
||||||
args = []string{"--namespace", VeleroCfg.VeleroNamespace, "backup", "get", backupName}
|
args = []string{"--namespace", velerocfg.VeleroNamespace, "backup", "get", backupName}
|
||||||
|
|
||||||
retryTimes := 5
|
retryTimes := 5
|
||||||
for i := 1; i < retryTimes+1; i++ {
|
for i := 1; i < retryTimes+1; i++ {
|
||||||
|
@ -967,14 +968,15 @@ func DeleteBackupResource(ctx context.Context, veleroCLI string, backupName stri
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBackup(ctx context.Context, veleroCLI, backupName string) (string, string, error) {
|
func GetBackup(ctx context.Context, backupName string, veleroCfg *VeleroConfig) (string, string, error) {
|
||||||
args := []string{"--namespace", VeleroCfg.VeleroNamespace, "backup", "get", backupName}
|
veleroCLI := veleroCfg.VeleroCLI
|
||||||
|
args := []string{"--namespace", veleroCfg.VeleroNamespace, "backup", "get", backupName}
|
||||||
cmd := exec.CommandContext(ctx, veleroCLI, args...)
|
cmd := exec.CommandContext(ctx, veleroCLI, args...)
|
||||||
return veleroexec.RunCommand(cmd)
|
return veleroexec.RunCommand(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsBackupExist(ctx context.Context, veleroCLI, backupName string) (bool, error) {
|
func IsBackupExist(ctx context.Context, backupName string, veleroCfg *VeleroConfig) (bool, error) {
|
||||||
out, outerr, err := GetBackup(ctx, veleroCLI, backupName)
|
out, outerr, err := GetBackup(ctx, backupName, veleroCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(outerr, "not found") {
|
if strings.Contains(outerr, "not found") {
|
||||||
fmt.Printf("Backup CR %s was not found\n", backupName)
|
fmt.Printf("Backup CR %s was not found\n", backupName)
|
||||||
|
@ -986,9 +988,9 @@ func IsBackupExist(ctx context.Context, veleroCLI, backupName string) (bool, err
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitBackupDeleted(ctx context.Context, veleroCLI, backupName string, timeout time.Duration) error {
|
func WaitBackupDeleted(ctx context.Context, backupName string, timeout time.Duration, veleroCfg *VeleroConfig) error {
|
||||||
return wait.PollImmediate(10*time.Second, timeout, func() (bool, error) {
|
return wait.PollImmediate(10*time.Second, timeout, func() (bool, error) {
|
||||||
if exist, err := IsBackupExist(ctx, veleroCLI, backupName); err != nil {
|
if exist, err := IsBackupExist(ctx, backupName, veleroCfg); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else {
|
} else {
|
||||||
if exist {
|
if exist {
|
||||||
|
@ -1001,10 +1003,10 @@ func WaitBackupDeleted(ctx context.Context, veleroCLI, backupName string, timeou
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitForExpectedStateOfBackup(ctx context.Context, veleroCLI, backupName string,
|
func WaitForExpectedStateOfBackup(ctx context.Context, backupName string,
|
||||||
timeout time.Duration, existing bool) error {
|
timeout time.Duration, existing bool, veleroCfg *VeleroConfig) error {
|
||||||
return wait.PollImmediate(10*time.Second, timeout, func() (bool, error) {
|
return wait.PollImmediate(10*time.Second, timeout, func() (bool, error) {
|
||||||
if exist, err := IsBackupExist(ctx, veleroCLI, backupName); err != nil {
|
if exist, err := IsBackupExist(ctx, backupName, veleroCfg); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else {
|
} else {
|
||||||
msg := "does not exist as expect"
|
msg := "does not exist as expect"
|
||||||
|
@ -1022,19 +1024,19 @@ func WaitForExpectedStateOfBackup(ctx context.Context, veleroCLI, backupName str
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitForBackupToBeCreated(ctx context.Context, veleroCLI, backupName string, timeout time.Duration) error {
|
func WaitForBackupToBeCreated(ctx context.Context, backupName string, timeout time.Duration, veleroCfg *VeleroConfig) error {
|
||||||
return WaitForExpectedStateOfBackup(ctx, veleroCLI, backupName, timeout, true)
|
return WaitForExpectedStateOfBackup(ctx, backupName, timeout, true, veleroCfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitForBackupToBeDeleted(ctx context.Context, veleroCLI string, backupName string, timeout time.Duration) error {
|
func WaitForBackupToBeDeleted(ctx context.Context, backupName string, timeout time.Duration, veleroCfg *VeleroConfig) error {
|
||||||
return WaitForExpectedStateOfBackup(ctx, veleroCLI, backupName, timeout, false)
|
return WaitForExpectedStateOfBackup(ctx, backupName, timeout, false, veleroCfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitForBackupsToBeDeleted(ctx context.Context, veleroCLI string, backups []string, timeout time.Duration) error {
|
func WaitForBackupsToBeDeleted(ctx context.Context, backups []string, timeout time.Duration, veleroCfg *VeleroConfig) error {
|
||||||
var err error
|
var err error
|
||||||
for _, backupName := range backups {
|
for _, backupName := range backups {
|
||||||
fmt.Println("Waiting for deletion of backup <" + backupName + ">")
|
fmt.Println("Waiting for deletion of backup <" + backupName + ">")
|
||||||
err = WaitForExpectedStateOfBackup(ctx, veleroCLI, backupName, timeout, false)
|
err = WaitForExpectedStateOfBackup(ctx, backupName, timeout, false, veleroCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1236,17 +1238,17 @@ func GetRepositories(ctx context.Context, veleroNamespace, targetNamespace strin
|
||||||
return common.GetListByCmdPipes(ctx, cmds)
|
return common.GetListByCmdPipes(ctx, cmds)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSnapshotCheckPoint(client TestClient, VeleroCfg VeleroConfig, expectCount int, namespaceBackedUp, backupName string, KibishiiPVCNameList []string) (SnapshotCheckPoint, error) {
|
func GetSnapshotCheckPoint(client TestClient, veleroCfg VeleroConfig, expectCount int, namespaceBackedUp, backupName string, KibishiiPVCNameList []string) (SnapshotCheckPoint, error) {
|
||||||
var snapshotCheckPoint SnapshotCheckPoint
|
var snapshotCheckPoint SnapshotCheckPoint
|
||||||
|
|
||||||
snapshotCheckPoint.ExpectCount = expectCount
|
snapshotCheckPoint.ExpectCount = expectCount
|
||||||
snapshotCheckPoint.NamespaceBackedUp = namespaceBackedUp
|
snapshotCheckPoint.NamespaceBackedUp = namespaceBackedUp
|
||||||
snapshotCheckPoint.PodName = KibishiiPVCNameList
|
snapshotCheckPoint.PodName = KibishiiPVCNameList
|
||||||
if (VeleroCfg.CloudProvider == "azure" || VeleroCfg.CloudProvider == "aws") && strings.EqualFold(VeleroCfg.Features, FeatureCSI) {
|
if (veleroCfg.CloudProvider == "azure" || veleroCfg.CloudProvider == "aws") && strings.EqualFold(veleroCfg.Features, FeatureCSI) {
|
||||||
snapshotCheckPoint.EnableCSI = true
|
snapshotCheckPoint.EnableCSI = true
|
||||||
resourceName := "snapshot.storage.k8s.io"
|
resourceName := "snapshot.storage.k8s.io"
|
||||||
|
|
||||||
srcVersions, err := GetAPIVersions(VeleroCfg.DefaultClient, resourceName)
|
srcVersions, err := GetAPIVersions(veleroCfg.DefaultClient, resourceName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return snapshotCheckPoint, err
|
return snapshotCheckPoint, err
|
||||||
|
@ -1292,30 +1294,32 @@ func GetVersionList(veleroCli, veleroVersion string) []VeleroCLI2Version {
|
||||||
}
|
}
|
||||||
return veleroCLI2VersionList
|
return veleroCLI2VersionList
|
||||||
}
|
}
|
||||||
func DeleteAllBackups(ctx context.Context, client TestClient) error {
|
func DeleteAllBackups(ctx context.Context, veleroCfg *VeleroConfig) error {
|
||||||
|
client := veleroCfg.ClientToInstallVelero
|
||||||
backupList := new(velerov1api.BackupList)
|
backupList := new(velerov1api.BackupList)
|
||||||
if err := client.Kubebuilder.List(ctx, backupList, &kbclient.ListOptions{Namespace: VeleroCfg.VeleroNamespace}); err != nil {
|
if err := client.Kubebuilder.List(ctx, backupList, &kbclient.ListOptions{Namespace: veleroCfg.VeleroNamespace}); err != nil {
|
||||||
return fmt.Errorf("failed to list backup object in %s namespace with err %v", VeleroCfg.VeleroNamespace, err)
|
return fmt.Errorf("failed to list backup object in %s namespace with err %v", veleroCfg.VeleroNamespace, err)
|
||||||
}
|
}
|
||||||
for _, backup := range backupList.Items {
|
for _, backup := range backupList.Items {
|
||||||
fmt.Printf("Backup %s is going to be deleted...\n", backup.Name)
|
fmt.Printf("Backup %s is going to be deleted...\n", backup.Name)
|
||||||
if err := VeleroBackupDelete(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, backup.Name); err != nil {
|
if err := VeleroBackupDelete(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, backup.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteBackups(ctx context.Context, client TestClient, backupNames []string) error {
|
func DeleteBackups(ctx context.Context, backupNames []string, veleroCfg *VeleroConfig) error {
|
||||||
|
client := veleroCfg.ClientToInstallVelero
|
||||||
backupList := new(velerov1api.BackupList)
|
backupList := new(velerov1api.BackupList)
|
||||||
if err := client.Kubebuilder.List(ctx, backupList, &kbclient.ListOptions{Namespace: VeleroCfg.VeleroNamespace}); err != nil {
|
if err := client.Kubebuilder.List(ctx, backupList, &kbclient.ListOptions{Namespace: veleroCfg.VeleroNamespace}); err != nil {
|
||||||
return fmt.Errorf("failed to list backup object in %s namespace with err %v", VeleroCfg.VeleroNamespace, err)
|
return fmt.Errorf("failed to list backup object in %s namespace with err %v", veleroCfg.VeleroNamespace, err)
|
||||||
}
|
}
|
||||||
for _, backup := range backupList.Items {
|
for _, backup := range backupList.Items {
|
||||||
for _, bn := range backupNames {
|
for _, bn := range backupNames {
|
||||||
if backup.Name == bn {
|
if backup.Name == bn {
|
||||||
fmt.Printf("Backup %s is going to be deleted...\n", backup.Name)
|
fmt.Printf("Backup %s is going to be deleted...\n", backup.Name)
|
||||||
if err := VeleroBackupDelete(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, backup.Name); err != nil {
|
if err := VeleroBackupDelete(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, backup.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1324,20 +1328,6 @@ func DeleteBackups(ctx context.Context, client TestClient, backupNames []string)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteRestores(ctx context.Context, client TestClient) error {
|
|
||||||
restoreList := new(velerov1api.RestoreList)
|
|
||||||
if err := client.Kubebuilder.List(ctx, restoreList, &kbclient.ListOptions{Namespace: VeleroCfg.VeleroNamespace}); err != nil {
|
|
||||||
return fmt.Errorf("failed to list restore object in %s namespace with err %v", VeleroCfg.VeleroNamespace, err)
|
|
||||||
}
|
|
||||||
for _, restore := range restoreList.Items {
|
|
||||||
fmt.Printf("Restore %s is going to be deleted...\n", restore.Name)
|
|
||||||
if err := VeleroRestoreDelete(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, restore.Name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSchedule(ctx context.Context, veleroNamespace, scheduleName string) (string, error) {
|
func GetSchedule(ctx context.Context, veleroNamespace, scheduleName string) (string, error) {
|
||||||
checkSnapshotCmd := exec.CommandContext(ctx, "kubectl",
|
checkSnapshotCmd := exec.CommandContext(ctx, "kubectl",
|
||||||
"get", "schedule", "-n", veleroNamespace, scheduleName, "-o=jsonpath='{.metadata.creationTimestamp}'")
|
"get", "schedule", "-n", veleroNamespace, scheduleName, "-o=jsonpath='{.metadata.creationTimestamp}'")
|
||||||
|
|
Loading…
Reference in New Issue