Skip to content

Commit

Permalink
Modify upgrade and migration cases.
Browse files Browse the repository at this point in the history
Signed-off-by: Xun Jiang <[email protected]>
  • Loading branch information
blackpiglet committed Nov 13, 2024
1 parent bcb60ed commit bebea4d
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 103 deletions.
8 changes: 4 additions & 4 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ These configuration parameters are expected as values to the following command l
1. `--standby-cluster-object-store-provider`: Object store provider for standby cluster.
1. `--debug-velero-pod-restart`: A switch for debugging velero pod restart.
1. `--fail-fast`: A switch for for failing fast on meeting error.
1. `--disable-vsphere-plugin`: A switch for not install the Velero vSphere plugin when the provider is set to `vsphere`.
1. `--has-vsphere-plugin`: A switch to indicate whether the Velero vSphere plugin is installed for vSphere environment.

These configurations or parameters are used to generate install options for Velero for each test suite.

Expand Down Expand Up @@ -130,7 +130,7 @@ Below is a mapping between `make` variables to E2E configuration flags.
1. `INSTALL_VELERO `: `-install-velero`. Optional.
1. `DEBUG_VELERO_POD_RESTART`: `-debug-velero-pod-restart`. Optional.
1. `FAIL_FAST`: `--fail-fast`. Optional.
1. `DISABLE_VSPHERE_PLUGIN`: `--diable-vsphere-plugin`. Optional.
1. `HAS_VSPHERE_PLUGIN`: `--has-vsphere-plugin`. Optional.



Expand Down Expand Up @@ -338,8 +338,8 @@ BSL_PREFIX=nightly \
ADDITIONAL_BSL_PLUGINS=gcr.io/velero-gcp/velero-plugin-for-aws:main \
ADDITIONAL_OBJECT_STORE_PROVIDER=aws \
ADDITIONAL_BSL_CONFIG=region=us-east-1 \
ADDITIONAL_BSL_BUCKET=nightly-normal-account4-test \
ADDITIONAL_BSL_PREFIX=addition-bsl \
ADDITIONAL_BSL_BUCKET=nightly-restrict-account-test \
ADDITIONAL_BSL_PREFIX=nightly \
ADDITIONAL_CREDS_FILE=$HOME/aws-credential \
VELERO_IMAGE=gcr.io/velero-gcp/velero:main \
RESTORE_HELPER_IMAGE=gcr.io/velero-gcp/velero-restore-helper:main \
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
secretKey,
)).To(Succeed())

bsls := []string{"default", additionalBsl}
BSLs := []string{"default", additionalBsl}

for _, bsl := range bsls {
for _, bsl := range BSLs {
backupName = fmt.Sprintf("backup-%s", bsl)
restoreName = fmt.Sprintf("restore-%s", bsl)
// We limit the length of backup name here to avoid the issue of vsphere plugin https://github.com/vmware-tanzu/velero-plugin-for-vsphere/issues/370
Expand All @@ -209,8 +209,8 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
restoreName = fmt.Sprintf("%s-%s", restoreName, UUIDgen)
}
veleroCfg.ProvideSnapshotsVolumeParam = !provideSnapshotVolumesParmInBackup
workloadNmespace := kibishiiNamespace + bsl
Expect(RunKibishiiTests(veleroCfg, backupName, restoreName, bsl, workloadNmespace, useVolumeSnapshots, !useVolumeSnapshots)).To(Succeed(),
workloadNS := kibishiiNamespace + bsl
Expect(RunKibishiiTests(veleroCfg, backupName, restoreName, bsl, workloadNS, useVolumeSnapshots, !useVolumeSnapshots)).To(Succeed(),
"Failed to successfully backup and restore Kibishii namespace using BSL %s", bsl)
}
})
Expand Down
26 changes: 13 additions & 13 deletions test/e2e/bsl-mgmt/deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
bslDeletionTestNs = "bsl-deletion"
)

// Test backup and restore of Kibishi using restic
// Test backup and restore of Kibishii using restic

func BslDeletionWithSnapshots() {
BslDeletionTest(true)
Expand Down Expand Up @@ -141,10 +141,10 @@ func BslDeletionTest(useVolumeSnapshots bool) {
podName1 := "kibishii-deployment-0"
podName2 := "kibishii-deployment-1"

label_1 := "for=1"
label1 := "for=1"
// TODO remove when issue https://github.com/vmware-tanzu/velero/issues/4724 is fixed
//label_2 := "for!=1"
label_2 := "for=2"
//label2 := "for!=1"
label2 := "for=2"
By("Create namespace for sample workload", func() {
Expect(CreateNamespace(oneHourTimeout, *veleroCfg.ClientToInstallVelero, bslDeletionTestNs)).To(Succeed())
})
Expand All @@ -157,8 +157,8 @@ func BslDeletionTest(useVolumeSnapshots bool) {

// Restic can not backup PV only, so pod need to be labeled also
By("Label all 2 worker-pods of Kibishii", func() {
Expect(AddLabelToPod(context.Background(), podName1, bslDeletionTestNs, label_1)).To(Succeed())
Expect(AddLabelToPod(context.Background(), "kibishii-deployment-1", bslDeletionTestNs, label_2)).To(Succeed())
Expect(AddLabelToPod(context.Background(), podName1, bslDeletionTestNs, label1)).To(Succeed())
Expect(AddLabelToPod(context.Background(), "kibishii-deployment-1", bslDeletionTestNs, label2)).To(Succeed())
})

By("Get all 2 PVCs of Kibishii and label them separately ", func() {
Expand All @@ -172,8 +172,8 @@ func BslDeletionTest(useVolumeSnapshots bool) {
fmt.Println(pvc)
Expect(pvc).To(HaveLen(1))
pvc2 := pvc[0]
Expect(AddLabelToPvc(context.Background(), pvc1, bslDeletionTestNs, label_1)).To(Succeed())
Expect(AddLabelToPvc(context.Background(), pvc2, bslDeletionTestNs, label_2)).To(Succeed())
Expect(AddLabelToPvc(context.Background(), pvc1, bslDeletionTestNs, label1)).To(Succeed())
Expect(AddLabelToPvc(context.Background(), pvc2, bslDeletionTestNs, label2)).To(Succeed())
})

var BackupCfg BackupConfig
Expand All @@ -182,7 +182,7 @@ func BslDeletionTest(useVolumeSnapshots bool) {
BackupCfg.BackupLocation = backupLocation1
BackupCfg.UseVolumeSnapshots = useVolumeSnapshots
BackupCfg.DefaultVolumesToFsBackup = !useVolumeSnapshots
BackupCfg.Selector = label_1
BackupCfg.Selector = label1
By(fmt.Sprintf("Backup one of PV of sample workload by label-1 - Kibishii by the first BSL %s", backupLocation1), func() {
// TODO currently, the upgrade case covers the upgrade path from 1.6 to main and the velero v1.6 doesn't support "debug" command
// TODO move to "runDebug" after we bump up to 1.7 in the upgrade case
Expand All @@ -195,7 +195,7 @@ func BslDeletionTest(useVolumeSnapshots bool) {

BackupCfg.BackupName = backupName2
BackupCfg.BackupLocation = backupLocation2
BackupCfg.Selector = label_2
BackupCfg.Selector = label2
By(fmt.Sprintf("Back up the other one PV of sample workload with label-2 into the additional BSL %s", backupLocation2), func() {
Expect(VeleroBackupNamespace(oneHourTimeout, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace, BackupCfg)).To(Succeed(), func() string {
Expand All @@ -205,8 +205,7 @@ func BslDeletionTest(useVolumeSnapshots bool) {
})

if useVolumeSnapshots {
if veleroCfg.CloudProvider == Vsphere {
// TODO - remove after upload progress monitoring is implemented
if veleroCfg.HasVspherePlugin {
By("Waiting for vSphere uploads to complete", func() {
Expect(WaitForVSphereUploadCompletion(oneHourTimeout, time.Hour,
bslDeletionTestNs, 2)).To(Succeed())
Expand Down Expand Up @@ -324,14 +323,15 @@ func BslDeletionTest(useVolumeSnapshots bool) {
// })

if useVolumeSnapshots {
if veleroCfg.CloudProvider == Vsphere {
if veleroCfg.HasVspherePlugin {
By(fmt.Sprintf("Snapshot in backup %s should still exist, because snapshot CR will be deleted 24 hours later if the status is a success", backupName2), func() {
Expect(SnapshotCRsCountShouldBe(context.Background(), bslDeletionTestNs,
backupName1, 1)).To(Succeed())
Expect(SnapshotCRsCountShouldBe(context.Background(), bslDeletionTestNs,
backupName2, 1)).To(Succeed())
})
}

var snapshotCheckPoint SnapshotCheckPoint
snapshotCheckPoint.NamespaceBackedUp = bslDeletionTestNs
By(fmt.Sprintf("Snapshot should not be deleted in cloud object store after deleting bsl %s", backupLocation1), func() {
Expand Down
39 changes: 6 additions & 33 deletions test/e2e/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/mod/semver"

. "github.com/vmware-tanzu/velero/test"
util "github.com/vmware-tanzu/velero/test/util/csi"
Expand Down Expand Up @@ -142,38 +141,12 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
if veleroCLI2Version.VeleroVersion == "self" {
veleroCLI2Version.VeleroCLI = veleroCfg.VeleroCLI
} else {
fmt.Printf("Using default images address of Velero CLI %s\n", veleroCLI2Version.VeleroVersion)
OriginVeleroCfg.VeleroImage = ""
OriginVeleroCfg.RestoreHelperImage = ""
OriginVeleroCfg.Plugins = ""

versionWithoutPatch := semver.MajorMinor(veleroCLI2Version.VeleroVersion)
// Read migration case needs plugins from the PluginsMatrix map.
migrationNeedPlugins, ok := PluginsMatrix[versionWithoutPatch]
Expect(ok).To(BeTrue())

if OriginVeleroCfg.CloudProvider == Azure {
OriginVeleroCfg.Plugins = migrationNeedPlugins[Azure][0]
}
if OriginVeleroCfg.CloudProvider == AWS {
OriginVeleroCfg.Plugins = migrationNeedPlugins[AWS][0]
}
// If HasVspherePlugin is false, only install the AWS plugin.
// If do nothing here, the default behavior is
// installing both AWS and vSphere plugins.
if OriginVeleroCfg.CloudProvider == Vsphere &&
!OriginVeleroCfg.HasVspherePlugin {
OriginVeleroCfg.Plugins = migrationNeedPlugins[AWS][0]
}
// Because Velero CSI plugin is deprecated in v1.14,
// only need to install it for version lower than v1.14.
if strings.Contains(OriginVeleroCfg.Features, FeatureCSI) &&
semver.Compare(versionWithoutPatch, "v1.14") < 0 {
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + "," + migrationNeedPlugins[CSI][0]
}
if OriginVeleroCfg.SnapshotMoveData && OriginVeleroCfg.CloudProvider == Azure {
OriginVeleroCfg.Plugins = OriginVeleroCfg.Plugins + "," + migrationNeedPlugins[AWS][0]
}
OriginVeleroCfg, err = SetImagesToDefaultValues(
OriginVeleroCfg,
veleroCLI2Version.VeleroVersion,
)
Expect(err).To(Succeed(), "Fail to set images for the migrate-from Velero installation.")

veleroCLI2Version.VeleroCLI, err = InstallVeleroCLI(veleroCLI2Version.VeleroVersion)
Expect(err).To(Succeed())
}
Expand Down
15 changes: 7 additions & 8 deletions test/e2e/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,16 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
veleroCfg.GCFrequency = ""
By(fmt.Sprintf("Install the expected old version Velero (%s) for upgrade",
veleroCLI2Version.VeleroVersion), func() {
//Set VeleroImage and RestoreHelperImage to blank
//VeleroImage and RestoreHelperImage should be the default value in originalCli
tmpCfgForOldVeleroInstall := veleroCfg
tmpCfgForOldVeleroInstall.UpgradeFromVeleroVersion = veleroCLI2Version.VeleroVersion
tmpCfgForOldVeleroInstall.VeleroCLI = veleroCLI2Version.VeleroCLI
tmpCfgForOldVeleroInstall.VeleroImage = ""
tmpCfgForOldVeleroInstall.RestoreHelperImage = ""
tmpCfgForOldVeleroInstall.Plugins = ""

tmpCfgForOldVeleroInstall, err = SetImagesToDefaultValues(
tmpCfgForOldVeleroInstall,
veleroCLI2Version.VeleroVersion,
)
Expect(err).To(Succeed(), "Fail to set the images for upgrade-from Velero installation.")

tmpCfgForOldVeleroInstall.UploaderType = ""
version, err := GetVeleroVersion(oneHourTimeout, tmpCfgForOldVeleroInstall.VeleroCLI, true)
Expect(err).To(Succeed(), "Fail to get Velero version")
Expand All @@ -145,9 +147,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
tmpCfgForOldVeleroInstall.UseRestic = !useVolumeSnapshots
tmpCfgForOldVeleroInstall.UseNodeAgent = false
}
//TODO: Remove this setting when upgrade path is from 1.13 to higher
//TODO: version, or self version 1.12 and older versions have no this parameter.
tmpCfgForOldVeleroInstall.WithoutDisableInformerCacheParam = true

Expect(VeleroInstall(context.Background(), &tmpCfgForOldVeleroInstall, false)).To(Succeed())
Expect(CheckVeleroVersion(context.Background(), tmpCfgForOldVeleroInstall.VeleroCLI,
Expand Down
2 changes: 2 additions & 0 deletions test/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const AWS = "aws"
const GCP = "gcp"
const Vsphere = "vsphere"
const CSI = "csi"
const Velero = "velero"
const VeleroRestoreHelper = "velero-restore-helper"

const UploaderTypeRestic = "restic"

Expand Down
11 changes: 9 additions & 2 deletions test/util/kibishii/kibishii_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ func GetKibishiiPVCNameList(workerCount int) []string {
}

// RunKibishiiTests runs kibishii tests on the provider.
func RunKibishiiTests(veleroCfg VeleroConfig, backupName, restoreName, backupLocation, kibishiiNamespace string,
useVolumeSnapshots, defaultVolumesToFsBackup bool) error {
func RunKibishiiTests(
veleroCfg VeleroConfig,
backupName string,
restoreName string,
backupLocation string,
kibishiiNamespace string,
useVolumeSnapshots bool,
defaultVolumesToFsBackup bool,
) error {
pvCount := len(KibishiiPVCNameList)
client := *veleroCfg.ClientToInstallVelero
oneHourTimeout, ctxCancel := context.WithTimeout(context.Background(), time.Minute*60)
Expand Down
Loading

0 comments on commit bebea4d

Please sign in to comment.