mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 14:34:17 +00:00
@@ -30,6 +30,9 @@ var MultiNamespacesMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestC
|
||||
|
||||
func (n *NamespaceMapping) Init() error {
|
||||
n.TestCase.Init()
|
||||
n.CaseBaseName = "ns-mp-" + n.UUIDgen
|
||||
n.BackupName = "backup-" + n.CaseBaseName
|
||||
n.RestoreName = "restore-" + n.CaseBaseName
|
||||
n.VeleroCfg = VeleroCfg
|
||||
n.Client = *n.VeleroCfg.ClientToInstallVelero
|
||||
n.VeleroCfg.UseVolumeSnapshots = n.UseVolumeSnapshots
|
||||
@@ -39,7 +42,6 @@ func (n *NamespaceMapping) Init() error {
|
||||
if n.UseVolumeSnapshots {
|
||||
backupType = "snapshot"
|
||||
}
|
||||
n.CaseBaseName = "ns-mp-" + n.UUIDgen
|
||||
var mappedNS string
|
||||
var mappedNSList []string
|
||||
n.NSIncluded = &[]string{}
|
||||
@@ -59,9 +61,6 @@ func (n *NamespaceMapping) Init() error {
|
||||
FailedMSG: "Failed to restore with namespace mapping",
|
||||
Text: fmt.Sprintf("should restore namespace %s with namespace mapping by %s", *n.NSIncluded, backupType),
|
||||
}
|
||||
n.BackupName = "backup-" + n.CaseBaseName
|
||||
n.RestoreName = "restore-" + n.CaseBaseName
|
||||
|
||||
n.MappedNamespaceList = mappedNSList
|
||||
fmt.Println(mappedNSList)
|
||||
n.BackupArgs = []string{
|
||||
@@ -83,15 +82,14 @@ func (n *NamespaceMapping) Init() error {
|
||||
}
|
||||
|
||||
func (n *NamespaceMapping) CreateResources() error {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), 60*time.Minute)
|
||||
defer ctxCancel()
|
||||
n.Ctx, n.CtxCancel = context.WithTimeout(context.Background(), 60*time.Minute)
|
||||
for index, ns := range *n.NSIncluded {
|
||||
n.kibishiiData.Levels = len(*n.NSIncluded) + index
|
||||
By(fmt.Sprintf("Creating namespaces ...%s\n", ns), func() {
|
||||
Expect(CreateNamespace(ctx, n.Client, ns)).To(Succeed(), fmt.Sprintf("Failed to create namespace %s", ns))
|
||||
Expect(CreateNamespace(n.Ctx, n.Client, ns)).To(Succeed(), fmt.Sprintf("Failed to create namespace %s", ns))
|
||||
})
|
||||
By("Deploy sample workload of Kibishii", func() {
|
||||
Expect(KibishiiPrepareBeforeBackup(ctx, n.Client, VeleroCfg.CloudProvider,
|
||||
Expect(KibishiiPrepareBeforeBackup(n.Ctx, n.Client, VeleroCfg.CloudProvider,
|
||||
ns, VeleroCfg.RegistryCredentialFile, VeleroCfg.Features,
|
||||
VeleroCfg.KibishiiDirectory, false, n.kibishiiData)).To(Succeed())
|
||||
})
|
||||
@@ -100,18 +98,16 @@ func (n *NamespaceMapping) CreateResources() error {
|
||||
}
|
||||
|
||||
func (n *NamespaceMapping) Verify() error {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), 60*time.Minute)
|
||||
defer ctxCancel()
|
||||
for index, ns := range n.MappedNamespaceList {
|
||||
n.kibishiiData.Levels = len(*n.NSIncluded) + index
|
||||
By(fmt.Sprintf("Verify workload %s after restore ", ns), func() {
|
||||
Expect(KibishiiVerifyAfterRestore(n.Client, ns,
|
||||
ctx, n.kibishiiData)).To(Succeed(), "Fail to verify workload after restore")
|
||||
n.Ctx, n.kibishiiData)).To(Succeed(), "Fail to verify workload after restore")
|
||||
})
|
||||
}
|
||||
for _, ns := range *n.NSIncluded {
|
||||
By(fmt.Sprintf("Verify namespace %s for backup is no longer exist after restore with namespace mapping", ns), func() {
|
||||
Expect(NamespaceShouldNotExist(ctx, n.Client, ns)).To(Succeed())
|
||||
Expect(NamespaceShouldNotExist(n.Ctx, n.Client, ns)).To(Succeed())
|
||||
})
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user