Fix wrong usage of global varaible VeleroCfg

Signed-off-by: danfengl <danfengl@vmware.com>
This commit is contained in:
danfengl
2024-02-07 02:32:20 +00:00
parent 3b8370e13c
commit b0956322b9
30 changed files with 168 additions and 182 deletions
@@ -69,7 +69,7 @@ func APIExtensionsVersionsTest() {
AfterEach(func() {
if !veleroCfg.Debug {
By("Clean backups after test", func() {
DeleteAllBackups(context.Background(), *veleroCfg.DefaultClient)
DeleteAllBackups(context.Background(), &veleroCfg)
})
if InstallVelero {
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() {
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() {
@@ -94,7 +94,7 @@ func APIGropuVersionsTest() {
}
By("Clean backups after test", func() {
DeleteAllBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
DeleteAllBackups(context.Background(), &veleroCfg)
})
if InstallVelero {
By("Uninstall Velero in api group version case", func() {
+1 -1
View File
@@ -70,7 +70,7 @@ func (n *NamespaceMapping) Init() error {
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName,
"--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
n.BackupArgs = append(n.BackupArgs, "--snapshot-volumes=false")
n.UseVolumeSnapshots = false
+2 -3
View File
@@ -12,7 +12,6 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
. "github.com/vmware-tanzu/velero/test"
. "github.com/vmware-tanzu/velero/test/e2e/test"
. "github.com/vmware-tanzu/velero/test/util/k8s"
@@ -55,11 +54,11 @@ func (n *NodePort) Init() error {
}
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",
}
n.RestoreArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore",
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "restore",
"--from-backup", n.BackupName,
"--wait",
}
+3 -4
View File
@@ -9,7 +9,6 @@ import (
. "github.com/onsi/gomega"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
. "github.com/vmware-tanzu/velero/test"
. "github.com/vmware-tanzu/velero/test/e2e/test"
. "github.com/vmware-tanzu/velero/test/util/k8s"
@@ -55,12 +54,12 @@ func (p *PVCSelectedNodeChanging) Init() error {
p.pvcName = "pvc-1"
p.ann = "volume.kubernetes.io/selected-node"
p.BackupArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", p.BackupName,
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "backup", p.BackupName,
"--include-namespaces", p.namespace,
"--snapshot-volumes=false", "--wait",
}
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",
}
return nil
@@ -78,7 +77,7 @@ func (p *PVCSelectedNodeChanging) CreateResources() error {
})
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() {
@@ -53,13 +53,13 @@ func (n *NSAnnotationCase) Init() error {
FailedMSG: "Failed to successfully backup and restore multiple namespaces",
}
n.BackupArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", n.BackupName,
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName,
"--include-namespaces", strings.Join(*n.NSIncluded, ","),
"--default-volumes-to-fs-backup", "--wait",
}
n.RestoreArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", n.RestoreName,
"create", "--namespace", n.VeleroCfg.VeleroNamespace, "restore", n.RestoreName,
"--from-backup", n.BackupName, "--wait",
}
return nil
+6 -5
View File
@@ -56,6 +56,9 @@ func (r *RBACCase) Init() error {
r.RestoreName = "restore-" + r.CaseBaseName
r.NamespacesTotal = 1
r.NSIncluded = &[]string{}
r.VeleroCfg = VeleroCfg
r.Client = *r.VeleroCfg.ClientToInstallVelero
for nsNum := 0; nsNum < r.NamespacesTotal; nsNum++ {
createNSName := fmt.Sprintf("%s-%00000d", r.CaseBaseName, nsNum)
*r.NSIncluded = append(*r.NSIncluded, createNSName)
@@ -66,17 +69,15 @@ func (r *RBACCase) Init() error {
FailedMSG: "Failed to successfully backup and restore RBAC",
}
r.BackupArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", r.BackupName,
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "backup", r.BackupName,
"--include-namespaces", strings.Join(*r.NSIncluded, ","),
"--default-volumes-to-fs-backup", "--wait",
}
r.RestoreArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
"create", "--namespace", r.VeleroCfg.VeleroNamespace, "restore", r.RestoreName,
"--from-backup", r.BackupName, "--wait",
}
r.VeleroCfg = VeleroCfg
r.Client = *r.VeleroCfg.ClientToInstallVelero
return nil
}
+2 -3
View File
@@ -9,7 +9,6 @@ import (
. "github.com/onsi/gomega"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
. "github.com/vmware-tanzu/velero/test"
. "github.com/vmware-tanzu/velero/test/e2e/test"
. "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.podName = "pod-1"
s.BackupArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", s.BackupName,
"create", "--namespace", s.VeleroCfg.VeleroNamespace, "backup", s.BackupName,
"--include-namespaces", s.namespace,
"--snapshot-volumes=false", "--wait",
}
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",
}
return nil