-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Shubham Pampattiwar <[email protected]>
- Loading branch information
1 parent
3f9c2dc
commit 6d9ffb3
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package basic | ||
|
||
import ( | ||
"fmt" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/vmware-tanzu/velero/test" | ||
. "github.com/vmware-tanzu/velero/test/e2e/test" | ||
. "github.com/vmware-tanzu/velero/test/util/k8s" | ||
. "github.com/vmware-tanzu/velero/test/util/velero" | ||
) | ||
|
||
type BackupPVCConfigChange struct { | ||
TestCase | ||
data map[string]string | ||
configmapName string | ||
namespace string | ||
sourcePVCStorageClassName string | ||
backupPVCStorageClassName string | ||
pvcName string | ||
volumeName string | ||
podName string | ||
deploymentName string | ||
} | ||
|
||
var BackupPVCConfigChangeTest = TestFunc(&BackupPVCConfigChange{}) | ||
var configData = map[string]string{ | ||
"backupPVC": ` | ||
{ | ||
"e2e-storage-class": { | ||
"storageClass": "e2e-storage-class-2", | ||
"readOnly": true | ||
}, | ||
}`, | ||
} | ||
|
||
func (b *BackupPVCConfigChange) Init() error { | ||
b.TestCase.Init() | ||
b.configmapName = "node-agent-configmap" | ||
b.VeleroCfg.Options.NodeAgentConfigMap = b.configmapName | ||
b.CaseBaseName = "BackupPVCConfigChange" + b.UUIDgen | ||
b.namespace = b.CaseBaseName | ||
b.BackupName = "backup-" + b.CaseBaseName | ||
b.RestoreName = "restore-" + b.CaseBaseName | ||
b.sourcePVCStorageClassName = StorageClassName | ||
b.backupPVCStorageClassName = StorageClassName2 | ||
b.data = configData | ||
b.volumeName = "volume-1" | ||
b.pvcName = fmt.Sprintf("pvc-%s", b.volumeName) | ||
b.podName = "pod-1" | ||
b.BackupArgs = []string{ | ||
"create", "--namespace", b.VeleroCfg.VeleroNamespace, "pvc", b.pvcName, "backup", b.BackupName, | ||
"--include-namespaces", b.namespace, | ||
"--snapshot-move-data=true", "--wait", | ||
} | ||
return nil | ||
} | ||
|
||
func (b *BackupPVCConfigChange) CreateResources() error { | ||
label := map[string]string{ | ||
"app": "test", | ||
} | ||
|
||
By(fmt.Sprintf("Installing Storage Class %s"), func() { | ||
Expect(InstallTestStorageClasses(fmt.Sprintf("../testdata/storage-class/%s.yaml", b.VeleroCfg.CloudProvider))).To(Succeed(), "Failed to install Storage Class") | ||
}) | ||
|
||
By(fmt.Sprintf("Creating namespace %s", b.namespace), func() { | ||
Expect(CreateNamespace(b.Ctx, b.Client, b.namespace)).To(Succeed(), "Failed to create namespace %s", b.namespace) | ||
}) | ||
|
||
By(fmt.Sprintf("Creating test app deployment in namespace %s", b.namespace), func() { | ||
pvc, err := CreatePVC(b.Client, b.namespace, b.pvcName, b.sourcePVCStorageClassName, nil) | ||
Expect(err).To(Succeed(), "Failed to create pvc in namespace %s", b.namespace) | ||
|
||
vols := CreateVolumes(pvc.Name, []string{b.volumeName}) | ||
|
||
deployment := NewDeployment(b.CaseBaseName, b.namespace, 1, label, nil).WithVolume(vols).Result() | ||
deployment, err = CreateDeployment(b.Client.ClientGo, b.namespace, deployment) | ||
Expect(err).To(Succeed(), "Failed to create deployment in namespace %s", b.namespace) | ||
b.deploymentName = deployment.Name | ||
err = WaitForReadyDeployment(b.Client.ClientGo, b.namespace, b.deploymentName) | ||
Expect(err).To(Succeed(), "Deployment %s in namespace %s should be ready", b.deploymentName, b.namespace) | ||
}) | ||
|
||
By(fmt.Sprintf("Creating Node Agent Config Map %s in namespace %s", b.configmapName, b.namespace), func() { | ||
_, err := CreateConfigMap(b.Client.ClientGo, b.VeleroCfg.Namespace, b.configmapName, nil, b.data) | ||
Expect(err).To(Succeed(), "Failed to create configmap in namespace %s", b.namespace) | ||
}) | ||
|
||
return nil | ||
} | ||
|
||
func (b *BackupPVCConfigChange) Clean() error { | ||
if !b.VeleroCfg.Debug { | ||
By(fmt.Sprintf("Start to destroy namespace %s", b.CaseBaseName), func() { | ||
Expect(CleanupNamespacesWithPoll(b.Ctx, b.Client, b.CaseBaseName)).To(Succeed(), "Failed to destroy namespace %s", b.CaseBaseName) | ||
}) | ||
DeleteConfigmap(b.Client.ClientGo, b.VeleroCfg.Namespace, b.configmapName) | ||
DeleteStorageClass(b.Ctx, b.Client, b.sourcePVCStorageClassName) | ||
DeleteStorageClass(b.Ctx, b.Client, b.backupPVCStorageClassName) | ||
b.TestCase.Clean() | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters