2021-04-28 16:54:17 +00:00
/ *
Copyright the Velero contributors .
2021-06-09 14:07:56 +00:00
2021-04-28 16:54:17 +00:00
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
2021-06-09 14:07:56 +00:00
2021-04-28 16:54:17 +00:00
http : //www.apache.org/licenses/LICENSE-2.0
2021-06-09 14:07:56 +00:00
2021-04-28 16:54:17 +00:00
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
2024-11-14 03:07:05 +00:00
package e2e
2020-11-24 19:12:52 +00:00
import (
2022-07-05 12:37:14 +00:00
"context"
"errors"
2020-11-24 19:12:52 +00:00
"flag"
2022-07-05 12:37:14 +00:00
"fmt"
2024-04-18 09:11:58 +00:00
"slices"
2024-11-14 03:07:05 +00:00
"strings"
2020-11-24 19:12:52 +00:00
"testing"
2023-07-27 08:04:07 +00:00
"time"
2020-11-24 19:12:52 +00:00
2024-07-12 09:10:13 +00:00
. "github.com/onsi/ginkgo/v2"
2020-11-24 19:12:52 +00:00
. "github.com/onsi/gomega"
2023-11-07 06:25:13 +00:00
"github.com/vmware-tanzu/velero/pkg/cmd/cli/install"
2024-11-14 03:07:05 +00:00
"github.com/vmware-tanzu/velero/test"
2021-11-22 07:34:48 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/backup"
2021-11-26 10:29:53 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/backups"
2021-11-22 07:34:48 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/basic"
2023-04-24 21:38:30 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/basic/api-group"
2023-12-12 01:50:55 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/basic/backup-volume-info"
2021-12-16 06:17:42 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/basic/resources-check"
2022-03-01 01:47:15 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/bsl-mgmt"
2022-11-22 09:38:41 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/migration"
2024-04-17 03:32:03 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/parallelfilesdownload"
. "github.com/vmware-tanzu/velero/test/e2e/parallelfilesupload"
2022-01-12 08:57:03 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/privilegesmgmt"
2022-09-13 04:42:06 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/pv-backup"
2021-11-26 07:27:55 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/resource-filtering"
2023-08-16 03:09:59 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/resourcemodifiers"
2023-04-11 08:27:43 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/resourcepolicies"
2021-11-22 07:34:48 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/scale"
2022-11-22 09:38:41 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/schedule"
2021-11-22 07:34:48 +00:00
. "github.com/vmware-tanzu/velero/test/e2e/upgrade"
2024-11-14 03:07:05 +00:00
"github.com/vmware-tanzu/velero/test/util/k8s"
veleroutil "github.com/vmware-tanzu/velero/test/util/velero"
2020-11-24 19:12:52 +00:00
)
func init ( ) {
2024-11-14 03:07:05 +00:00
test . VeleroCfg . Options = install . Options { }
flag . StringVar (
& test . VeleroCfg . CloudProvider ,
"cloud-provider" ,
"" ,
"cloud that Velero will be installed into. Required." ,
)
flag . StringVar (
& test . VeleroCfg . ObjectStoreProvider ,
"object-store-provider" ,
"" ,
"provider of object store plugin. Required if cloud-provider is kind, otherwise ignored." ,
)
flag . StringVar (
& test . VeleroCfg . BSLBucket ,
"bucket" ,
"" ,
"name of the object storage bucket where backups from e2e tests should be stored. Required." ,
)
flag . StringVar (
& test . VeleroCfg . CloudCredentialsFile ,
"credentials-file" ,
"" ,
"file containing credentials for backup and volume provider. Required." ,
)
flag . StringVar (
& test . VeleroCfg . VeleroCLI ,
"velerocli" ,
"velero" ,
"path to the velero application to use." ,
)
flag . StringVar (
& test . VeleroCfg . VeleroImage ,
"velero-image" ,
"velero/velero:main" ,
"image for the velero server to be tested." ,
)
flag . StringVar (
& test . VeleroCfg . Plugins ,
"plugins" ,
"" ,
"provider plugins to be tested." ,
)
flag . StringVar (
& test . VeleroCfg . AddBSLPlugins ,
"additional-bsl-plugins" ,
"" ,
"additional plugins to be tested." ,
)
flag . StringVar (
& test . VeleroCfg . VeleroVersion ,
"velero-version" ,
"main" ,
"image version for the velero server to be tested with." ,
)
flag . StringVar (
& test . VeleroCfg . RestoreHelperImage ,
"restore-helper-image" ,
"" ,
"image for the velero restore helper to be tested." ,
)
flag . StringVar (
& test . VeleroCfg . UpgradeFromVeleroCLI ,
"upgrade-from-velero-cli" ,
"" ,
"comma-separated list of velero application for the pre-upgrade velero server." ,
)
flag . StringVar (
& test . VeleroCfg . UpgradeFromVeleroVersion ,
"upgrade-from-velero-version" ,
"v1.7.1" ,
"comma-separated list of Velero version to be tested with for the pre-upgrade velero server." ,
)
flag . StringVar (
& test . VeleroCfg . MigrateFromVeleroCLI ,
"migrate-from-velero-cli" ,
"" ,
"comma-separated list of velero application on source cluster." ,
)
flag . StringVar (
& test . VeleroCfg . MigrateFromVeleroVersion ,
"migrate-from-velero-version" ,
"self" ,
"comma-separated list of Velero version to be tested with on source cluster." ,
)
flag . StringVar (
& test . VeleroCfg . BSLConfig ,
"bsl-config" ,
"" , "configuration to use for the backup storage location. Format is key1=value1,key2=value2" )
flag . StringVar (
& test . VeleroCfg . BSLPrefix ,
"prefix" ,
"" ,
"prefix under which all Velero data should be stored within the bucket. Optional." ,
)
flag . StringVar (
& test . VeleroCfg . VSLConfig ,
"vsl-config" ,
"" ,
"configuration to use for the volume snapshot location. Format is key1=value1,key2=value2" ,
)
flag . StringVar (
& test . VeleroCfg . VeleroNamespace ,
"velero-namespace" ,
"velero" ,
"namespace to install Velero into" ,
)
flag . BoolVar (
& test . InstallVelero ,
"install-velero" ,
true ,
"install/uninstall velero during the test. Optional." ,
)
flag . BoolVar (
& test . VeleroCfg . UseNodeAgent ,
"use-node-agent" ,
true ,
"whether deploy node agent daemonset velero during the test. Optional." ,
)
flag . BoolVar (
& test . VeleroCfg . UseVolumeSnapshots ,
"use-volume-snapshots" ,
true ,
"whether or not to create snapshot location automatically. Set to false if you do not plan to create volume snapshots via a storage provider." ,
)
flag . StringVar (
& test . VeleroCfg . RegistryCredentialFile ,
"registry-credential-file" ,
"" ,
"file containing credential for the image registry, follows the same format rules as the ~/.docker/config.json file. Optional." ,
)
flag . StringVar (
& test . VeleroCfg . KibishiiDirectory ,
"kibishii-directory" ,
"github.com/vmware-tanzu-experiments/distributed-data-generator/kubernetes/yaml/" ,
"file directory or URL path to install Kibishii. Optional." ,
)
2021-03-04 18:19:42 +00:00
// Flags to create an additional BSL for multiple credentials test
2024-11-14 03:07:05 +00:00
flag . StringVar (
& test . VeleroCfg . AdditionalBSLProvider ,
"additional-bsl-object-store-provider" ,
"" ,
"provider of object store plugin for additional backup storage location. Required if testing multiple credentials support." ,
)
flag . StringVar (
& test . VeleroCfg . AdditionalBSLBucket ,
"additional-bsl-bucket" ,
"" ,
"name of the object storage bucket for additional backup storage location. Required if testing multiple credentials support." ,
)
flag . StringVar (
& test . VeleroCfg . AdditionalBSLPrefix ,
"additional-bsl-prefix" ,
"" ,
"prefix under which all Velero data should be stored within the bucket for additional backup storage location. Optional." ,
)
flag . StringVar (
& test . VeleroCfg . AdditionalBSLConfig ,
"additional-bsl-config" ,
"" ,
"configuration to use for the additional backup storage location. Format is key1=value1,key2=value2" ,
)
flag . StringVar (
& test . VeleroCfg . AdditionalBSLCredentials ,
"additional-bsl-credentials-file" ,
"" ,
"file containing credentials for additional backup storage location provider. Required if testing multiple credentials support." ,
)
flag . StringVar (
& test . VeleroCfg . Features ,
"features" ,
"" ,
"comma-separated list of features to enable for this Velero process." ,
)
flag . StringVar (
& test . VeleroCfg . GCFrequency ,
"garbage-collection-frequency" ,
"" ,
"frequency of garbage collection." ,
)
flag . StringVar (
& test . VeleroCfg . DefaultClusterContext ,
"default-cluster-context" ,
"" ,
"default cluster's kube config context, it's for migration test." ,
)
flag . StringVar (
& test . VeleroCfg . StandbyClusterContext ,
"standby-cluster-context" ,
"" ,
"standby cluster's kube config context, it's for migration test." ,
)
flag . StringVar (
& test . VeleroCfg . UploaderType ,
"uploader-type" ,
"" ,
"type of uploader for persistent volume backup." ,
)
flag . BoolVar (
& test . VeleroCfg . VeleroServerDebugMode ,
"velero-server-debug-mode" ,
false ,
"a switch for enable or disable having debug log of Velero server." ,
)
flag . BoolVar (
& test . VeleroCfg . SnapshotMoveData ,
"snapshot-move-data" ,
false ,
"a Switch for taking backup with Velero's data mover, if data-mover-plugin is not provided, using built-in plugin" ,
)
flag . StringVar (
& test . VeleroCfg . DataMoverPlugin ,
"data-mover-plugin" ,
"" ,
"customized plugin for data mover." ,
)
flag . StringVar (
& test . VeleroCfg . StandbyClusterCloudProvider ,
"standby-cluster-cloud-provider" ,
"" ,
"cloud provider for standby cluster." ,
)
flag . StringVar (
& test . VeleroCfg . StandbyClusterPlugins ,
"standby-cluster-plugins" ,
"" ,
"plugins provider for standby cluster." ,
)
flag . StringVar (
& test . VeleroCfg . StandbyClusterObjectStoreProvider ,
"standby-cluster-object-store-provider" ,
"" ,
"object store provider for standby cluster." ,
)
flag . BoolVar (
& test . VeleroCfg . DebugVeleroPodRestart ,
"debug-velero-pod-restart" ,
false ,
"a switch for debugging velero pod restart." ,
)
flag . BoolVar (
& test . VeleroCfg . DisableInformerCache ,
"disable-informer-cache" ,
false ,
"a switch for disable informer cache." ,
)
flag . StringVar (
& test . VeleroCfg . DefaultClusterName ,
"default-cluster-name" ,
"" ,
"default cluster's name in kube config file, it's for EKS IRSA test." ,
)
flag . StringVar (
& test . VeleroCfg . StandbyClusterName ,
"standby-cluster-name" ,
"" ,
"standby cluster's name in kube config file, it's for EKS IRSA test." ,
)
flag . StringVar (
& test . VeleroCfg . EKSPolicyARN ,
"eks-policy-arn" ,
"" ,
"EKS plicy ARN for creating AWS IAM service account." ,
)
flag . StringVar (
& test . VeleroCfg . DefaultCLSServiceAccountName ,
"default-cls-service-account-name" ,
"" ,
"default cluster service account name." ,
)
flag . StringVar (
& test . VeleroCfg . StandbyCLSServiceAccountName ,
"standby-cls-service-account-name" ,
"" ,
"standby cluster service account name." ,
)
flag . BoolVar (
& test . VeleroCfg . FailFast ,
"fail-fast" ,
true ,
"a switch for failing fast on meeting error." ,
)
flag . BoolVar (
& test . VeleroCfg . HasVspherePlugin ,
"has-vsphere-plugin" ,
false ,
"a switch for installing vSphere plugin." ,
)
2020-11-24 19:12:52 +00:00
}
2024-02-01 09:19:08 +00:00
// Add label [SkipVanillaZfs]:
// We found issue - https://github.com/openebs/zfs-localpv/issues/123 when using OpenEBS ZFS CSI Driver
// When PVC using storage class with reclaim policy as 'Delete', once PVC is deleted, snapshot associated will be deleted
// along with PVC deletion, after restoring workload, restored PVC is in pending status, due to failure of provision PV
// caused by no expected snapshot found. If we use retain as reclaim policy, then this label can be ignored, all test
// cases can be executed as expected successful result.
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Velero tests with various CRD API group versions" ,
Label ( "APIGroup" , "APIVersion" , "SKIP_KIND" , "LongTime" ) ,
APIGroupVersionsTest ,
)
var _ = Describe (
"CRD of apiextentions v1beta1 should be B/R successfully from cluster(k8s version < 1.22) to cluster(k8s version >= 1.22)" ,
Label ( "APIGroup" , "APIExtensions" , "SKIP_KIND" ) ,
APIExtensionsVersionsTest ,
)
2021-11-22 07:34:48 +00:00
2024-07-23 06:39:01 +00:00
// Test backup and restore of Kibishii using restic
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Velero tests on cluster using the plugin provider for object storage and Restic for volume backups" ,
Label ( "Basic" , "Restic" ) ,
BackupRestoreWithRestic ,
)
2021-11-22 07:34:48 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups" ,
Label ( "Basic" , "Snapshot" , "SkipVanillaZfs" ) ,
BackupRestoreWithSnapshots ,
)
2021-11-22 07:34:48 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups" ,
Label ( "Basic" , "Snapshot" , "RetainPV" ) ,
BackupRestoreRetainedPVWithSnapshots ,
)
2023-11-13 12:47:38 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups" ,
Label ( "Basic" , "Restic" , "RetainPV" ) ,
BackupRestoreRetainedPVWithRestic ,
)
2023-11-13 12:47:38 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Backup/restore of cluster resources" ,
Label ( "Basic" , "ClusterResource" ) ,
ResourcesCheckTest ,
)
2021-11-22 07:34:48 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Service NodePort reservation during restore is configurable" ,
Label ( "Basic" , "NodePort" ) ,
NodePortTest ,
)
2021-11-22 07:34:48 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Storage class of persistent volumes and persistent volume claims can be changed during restores" ,
Label ( "Basic" , "StorageClass" ) ,
StorageClasssChangingTest ,
)
2021-11-22 07:34:48 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Node selectors of persistent volume claims can be changed during restores" ,
Label ( "Basic" , "SelectedNode" , "SKIP_KIND" ) ,
PVCSelectedNodeChangingTest ,
)
2022-04-10 10:20:16 +00:00
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Backup/restore of 2500 namespaces" ,
Label ( "Scale" , "LongTime" ) ,
MultiNSBackupRestore ,
)
2022-05-09 06:51:18 +00:00
2024-07-23 06:39:01 +00:00
// Upgrade test by Kibishii using Restic
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Velero upgrade tests on cluster using the plugin provider for object storage and Restic for volume backups" ,
Label ( "Upgrade" , "Restic" ) ,
BackupUpgradeRestoreWithRestic ,
)
var _ = Describe (
"Velero upgrade tests on cluster using the plugin provider for object storage and snapshots for volume backups" ,
Label ( "Upgrade" , "Snapshot" , "SkipVanillaZfs" ) ,
BackupUpgradeRestoreWithSnapshots ,
)
2021-11-26 07:27:55 +00:00
2024-07-23 06:39:01 +00:00
// test filter objects by namespace, type, or labels when backup or restore.
2024-11-14 03:07:05 +00:00
var _ = Describe (
"Resources with the label velero.io/exclude-from-backup=true are not included in backup" ,
Label ( "ResourceFiltering" , "ExcludeFromBackup" ) ,
ExcludeFromBackupTest ,
)
var _ = Describe (
"Velero test on exclude namespace from the cluster backup" ,
Label ( "ResourceFiltering" , "ExcludeNamespaces" , "Backup" ) ,
BackupWithExcludeNamespaces ,
)
var _ = Describe (
"Velero test on exclude namespace from the cluster restore" ,
Label ( "ResourceFiltering" , "ExcludeNamespaces" , "Restore" ) ,
RestoreWithExcludeNamespaces ,
)
var _ = Describe (
"Velero test on exclude resources from the cluster backup" ,
Label ( "ResourceFiltering" , "ExcludeResources" , "Backup" ) ,
BackupWithExcludeResources ,
)
var _ = Describe (
"Velero test on exclude resources from the cluster restore" ,
Label ( "ResourceFiltering" , "ExcludeResources" , "Restore" ) ,
RestoreWithExcludeResources ,
)
var _ = Describe (
"Velero test on include namespace from the cluster backup" ,
Label ( "ResourceFiltering" , "IncludeNamespaces" , "Backup" ) ,
BackupWithIncludeNamespaces ,
)
var _ = Describe (
"Velero test on include namespace from the cluster restore" ,
Label ( "ResourceFiltering" , "IncludeNamespaces" , "Restore" ) ,
RestoreWithIncludeNamespaces ,
)
var _ = Describe (
"Velero test on include resources from the cluster backup" ,
Label ( "ResourceFiltering" , "IncludeResources" , "Backup" ) ,
BackupWithIncludeResources ,
)
var _ = Describe (
"Velero test on include resources from the cluster restore" ,
Label ( "ResourceFiltering" , "IncludeResources" , "Restore" ) ,
RestoreWithIncludeResources ,
)
var _ = Describe (
"Velero test on backup include resources matching the label selector" ,
Label ( "ResourceFiltering" , "LabelSelector" ) ,
BackupWithLabelSelector ,
)
var _ = Describe (
"Velero test on skip backup of volume by resource policies" ,
Label ( "ResourceFiltering" , "ResourcePolicies" , "Restic" ) ,
ResourcePoliciesTest ,
)
2023-01-30 03:58:41 +00:00
2024-07-23 06:39:01 +00:00
// backup VolumeInfo test
2024-11-14 03:07:05 +00:00
var _ = Describe (
"" ,
Label ( "BackupVolumeInfo" , "SkippedVolume" ) ,
SkippedVolumeInfoTest ,
)
var _ = Describe (
"" ,
Label ( "BackupVolumeInfo" , "FilesystemUpload" ) ,
FilesystemUploadVolumeInfoTest ,
)
var _ = Describe (
"" ,
Label ( "BackupVolumeInfo" , "CSIDataMover" ) ,
CSIDataMoverVolumeInfoTest ,
)
var _ = Describe (
"" ,
Label ( "BackupVolumeInfo" , "CSISnapshot" ) ,
CSISnapshotVolumeInfoTest ,
)
var _ = Describe (
"" ,
Label ( "BackupVolumeInfo" , "NativeSnapshot" ) ,
NativeSnapshotVolumeInfoTest ,
)
var _ = Describe (
"Velero test on resource modifiers from the cluster restore" ,
Label ( "ResourceModifier" , "Restore" ) ,
ResourceModifiersTest ,
)
var _ = Describe (
"Velero tests of Restic backup deletion" ,
Label ( "Backups" , "Deletion" , "Restic" ) ,
BackupDeletionWithRestic ,
)
var _ = Describe (
"Velero tests of snapshot backup deletion" ,
Label ( "Backups" , "Deletion" , "Snapshot" , "SkipVanillaZfs" ) ,
BackupDeletionWithSnapshots ,
)
var _ = Describe (
"Local backups and Restic repos will be deleted once the corresponding backup storage location is deleted" ,
Label ( "Backups" , "TTL" , "LongTime" , "Snapshot" , "SkipVanillaZfs" ) ,
TTLTest ,
)
var _ = Describe (
"Backups in object storage are synced to a new Velero and deleted backups in object storage are synced to be deleted in Velero" ,
Label ( "Backups" , "BackupsSync" ) ,
BackupsSyncTest ,
)
var _ = Describe (
"Backup will be created periodically by schedule defined by a Cron expression" ,
2024-11-19 07:07:06 +00:00
Label ( "Schedule" , "Periodical" , "Pause" , "LongTime" ) ,
SchedulePeriodicalTest ,
2024-11-14 03:07:05 +00:00
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
2024-11-19 07:07:06 +00:00
Label ( "Schedule" , "OrderedResources" ) ,
2024-11-14 03:07:05 +00:00
ScheduleOrderedResources ,
)
var _ = Describe (
"Schedule controller wouldn't create a new backup when it still has pending or InProgress backup" ,
2024-11-19 07:07:06 +00:00
Label ( "Schedule" , "InProgress" , "SKIP_KIND" , "LongTime" ) ,
ScheduleInProgressTest ,
2024-11-14 03:07:05 +00:00
)
var _ = Describe (
"Velero test on ssr object when controller namespace mix-ups" ,
Label ( "PrivilegesMgmt" , "SSR" ) ,
SSRTest ,
)
var _ = Describe (
"Local backups will be deleted once the corresponding backup storage location is deleted" ,
Label ( "BSL" , "Deletion" , "Snapshot" , "SkipVanillaZfs" ) ,
BslDeletionWithSnapshots ,
)
var _ = Describe (
"Local backups and Restic repos will be deleted once the corresponding backup storage location is deleted" ,
Label ( "BSL" , "Deletion" , "Restic" ) ,
BslDeletionWithRestic ,
)
var _ = Describe (
2024-11-21 14:33:53 +00:00
"Migrate resources between clusters by FileSystem backup" ,
Label ( "Migration" , "FSB" ) ,
MigrationWithFS ,
2024-11-14 03:07:05 +00:00
)
var _ = Describe (
"Migrate resources between clusters by snapshot" ,
Label ( "Migration" , "Snapshot" , "SkipVanillaZfs" ) ,
MigrationWithSnapshots ,
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
Label ( "NamespaceMapping" , "Single" , "Restic" ) ,
OneNamespaceMappingResticTest ,
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
Label ( "NamespaceMapping" , "Multiple" , "Restic" ) ,
MultiNamespacesMappingResticTest ,
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
Label ( "NamespaceMapping" , "Single" , "Snapshot" , "SkipVanillaZfs" ) ,
OneNamespaceMappingSnapshotTest ,
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
Label ( "NamespaceMapping" , "Multiple" , "Snapshot" , "SkipVanillaZfs" ) ,
MultiNamespacesMappingSnapshotTest ,
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
Label ( "PVBackup" , "OptIn" ) ,
OptInPVBackupTest ,
)
var _ = Describe (
"Backup resources should follow the specific order in schedule" ,
Label ( "PVBackup" , "OptOut" ) ,
OptOutPVBackupTest ,
)
var _ = Describe (
"Velero test on parallel files upload" ,
Label ( "UploaderConfig" , "ParallelFilesUpload" ) ,
ParallelFilesUploadTest ,
)
var _ = Describe (
"Velero test on parallel files download" ,
Label ( "UploaderConfig" , "ParallelFilesDownload" ) ,
ParallelFilesDownloadTest ,
)
2024-04-17 03:32:03 +00:00
2024-10-13 15:55:53 +00:00
func GetKubeConfigContext ( ) error {
2022-07-05 12:37:14 +00:00
var err error
2024-11-14 03:07:05 +00:00
var tcDefault , tcStandby k8s . TestClient
tcDefault , err = k8s . NewTestClient ( test . VeleroCfg . DefaultClusterContext )
test . VeleroCfg . DefaultClient = & tcDefault
test . VeleroCfg . ClientToInstallVelero = test . VeleroCfg . DefaultClient
test . VeleroCfg . ClusterToInstallVelero = test . VeleroCfg . DefaultClusterName
test . VeleroCfg . ServiceAccountNameToInstall = test . VeleroCfg . DefaultCLSServiceAccountName
2022-07-05 12:37:14 +00:00
if err != nil {
return err
}
2024-11-14 03:07:05 +00:00
if test . VeleroCfg . DefaultClusterContext != "" {
err = k8s . KubectlConfigUseContext ( context . Background ( ) , test . VeleroCfg . DefaultClusterContext )
2022-07-05 12:37:14 +00:00
if err != nil {
return err
}
2024-11-14 03:07:05 +00:00
if test . VeleroCfg . StandbyClusterContext != "" {
tcStandby , err = k8s . NewTestClient ( test . VeleroCfg . StandbyClusterContext )
test . VeleroCfg . StandbyClient = & tcStandby
2022-07-05 12:37:14 +00:00
if err != nil {
return err
}
} else {
return errors . New ( "migration test needs 2 clusters to run" )
}
}
return nil
}
2024-09-13 06:32:08 +00:00
var testSuitePassed bool
2020-11-24 19:12:52 +00:00
func TestE2e ( t * testing . T ) {
2020-12-10 00:26:05 +00:00
// Skip running E2E tests when running only "short" tests because:
// 1. E2E tests are long running tests involving installation of Velero and performing backup and restore operations.
2023-07-21 21:25:24 +00:00
// 2. E2E tests require a Kubernetes cluster to install and run velero which further requires more configuration. See above referenced command line flags.
2020-12-10 00:26:05 +00:00
if testing . Short ( ) {
t . Skip ( "Skipping E2E tests" )
}
2024-11-14 03:07:05 +00:00
if ! slices . Contains ( test . LocalCloudProviders , test . VeleroCfg . CloudProvider ) {
2024-01-24 19:28:58 +00:00
fmt . Println ( "For cloud platforms, object store plugin provider will be set as cloud provider" )
// If ObjectStoreProvider is not provided, then using the value same as CloudProvider
2024-11-14 03:07:05 +00:00
if test . VeleroCfg . ObjectStoreProvider == "" {
test . VeleroCfg . ObjectStoreProvider = test . VeleroCfg . CloudProvider
2024-01-24 19:28:58 +00:00
}
} else {
2024-11-14 03:07:05 +00:00
if test . VeleroCfg . ObjectStoreProvider == "" {
2024-01-24 19:28:58 +00:00
t . Error ( errors . New ( "No object store provider specified - must be specified when using kind as the cloud provider" ) ) // Must have an object store provider
}
}
2022-07-05 12:37:14 +00:00
var err error
2024-10-13 15:55:53 +00:00
if err = GetKubeConfigContext ( ) ; err != nil {
2022-07-05 12:37:14 +00:00
fmt . Println ( err )
t . FailNow ( )
}
2020-11-24 19:12:52 +00:00
RegisterFailHandler ( Fail )
2024-09-13 06:32:08 +00:00
testSuitePassed = RunSpecs ( t , "E2e Suite" )
2020-11-24 19:12:52 +00:00
}
2023-06-01 06:59:23 +00:00
var _ = BeforeSuite ( func ( ) {
2024-11-14 03:07:05 +00:00
By ( "Install StorageClass for E2E." )
Expect ( veleroutil . InstallStorageClasses ( test . VeleroCfg . CloudProvider ) ) . To ( Succeed ( ) )
if strings . EqualFold ( test . VeleroCfg . Features , test . FeatureCSI ) &&
test . VeleroCfg . UseVolumeSnapshots {
By ( "Install VolumeSnapshotClass for E2E." )
Expect (
k8s . KubectlApplyByFile (
context . Background ( ) ,
fmt . Sprintf ( "../testdata/volume-snapshot-class/%s.yaml" , test . VeleroCfg . CloudProvider ) ,
) ,
) . To ( Succeed ( ) )
}
if test . InstallVelero {
2023-06-01 06:59:23 +00:00
By ( "Install test resources before testing" )
2024-11-14 03:07:05 +00:00
Expect (
veleroutil . PrepareVelero (
context . Background ( ) ,
"install resource before testing" ,
test . VeleroCfg ,
) ,
) . To ( Succeed ( ) )
2023-06-01 06:59:23 +00:00
}
} )
var _ = AfterSuite ( func ( ) {
2024-11-14 03:07:05 +00:00
ctx , ctxCancel := context . WithTimeout ( context . Background ( ) , time . Minute * 5 )
defer ctxCancel ( )
By ( "Delete StorageClasses created by E2E" )
Expect (
k8s . DeleteStorageClass (
ctx ,
* test . VeleroCfg . ClientToInstallVelero ,
test . StorageClassName ,
) ,
) . To ( Succeed ( ) )
Expect (
k8s . DeleteStorageClass (
ctx ,
* test . VeleroCfg . ClientToInstallVelero ,
test . StorageClassName2 ,
) ,
) . To ( Succeed ( ) )
if strings . EqualFold ( test . VeleroCfg . Features , test . FeatureCSI ) &&
test . VeleroCfg . UseVolumeSnapshots {
By ( "Delete VolumeSnapshotClass created by E2E" )
Expect (
k8s . KubectlDeleteByFile (
ctx ,
fmt . Sprintf ( "../testdata/volume-snapshot-class/%s.yaml" , test . VeleroCfg . CloudProvider ) ,
) ,
) . To ( Succeed ( ) )
}
2024-09-13 06:32:08 +00:00
// If the Velero is installed during test, and the FailFast is not enabled,
// uninstall Velero. If not, either Velero is not installed, or kept it for debug on failure.
2024-11-14 03:07:05 +00:00
if test . InstallVelero && ( testSuitePassed || ! test . VeleroCfg . FailFast ) {
2023-06-01 06:59:23 +00:00
By ( "release test resources after testing" )
2024-11-14 03:07:05 +00:00
Expect ( veleroutil . VeleroUninstall ( ctx , test . VeleroCfg ) ) . To ( Succeed ( ) )
2023-06-01 06:59:23 +00:00
}
} )