Skip to content

Commit

Permalink
Fix the context choosing error after migration case.
Browse files Browse the repository at this point in the history
Try to use the normal import way in ginkgo tests.
Change the FAIL_FAST default value to false.

Signed-off-by: Xun Jiang <[email protected]>
  • Loading branch information
blackpiglet committed Oct 14, 2024
1 parent ba0dbb9 commit 587634f
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 124 deletions.
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GINKGO_LABELS ?=
# When --fail-fast is set, the entire suite will stop when the first failure occurs.
# Enable --fail-fast by default.
# https://onsi.github.io/ginkgo/#mental-model-how-ginkgo-handles-failure
FAIL_FAST ?= true
FAIL_FAST ?= false
VELERO_CLI ?=$$(pwd)/../_output/bin/$(GOOS)/$(GOARCH)/velero
VELERO_IMAGE ?= velero/velero:main
PLUGINS ?=
Expand Down
234 changes: 117 additions & 117 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/vmware-tanzu/velero/pkg/cmd/cli/install"
. "github.com/vmware-tanzu/velero/test"
Expand Down Expand Up @@ -112,128 +112,128 @@ func init() {
// 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.

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)
var _ = ginkgo.Describe("Velero tests with various CRD API group versions",
ginkgo.Label("APIGroup", "APIVersion", "SKIP_KIND", "LongTime"), APIGroupVersionsTest)
var _ = ginkgo.Describe("CRD of apiextentions v1beta1 should be B/R successfully from cluster(k8s version < 1.22) to cluster(k8s version >= 1.22)",
ginkgo.Label("APIGroup", "APIExtensions", "SKIP_KIND"), APIExtensionsVersionsTest)

// Test backup and restore of Kibishii using restic
var _ = Describe("Velero tests on cluster using the plugin provider for object storage and Restic for volume backups",
Label("Basic", "Restic"), BackupRestoreWithRestic)
var _ = ginkgo.Describe("Velero tests on cluster using the plugin provider for object storage and Restic for volume backups",
ginkgo.Label("Basic", "Restic"), BackupRestoreWithRestic)

var _ = Describe("Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
Label("Basic", "Snapshot", "SkipVanillaZfs"), BackupRestoreWithSnapshots)
var _ = ginkgo.Describe("Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
ginkgo.Label("Basic", "Snapshot", "SkipVanillaZfs"), BackupRestoreWithSnapshots)

var _ = Describe("Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
Label("Basic", "Snapshot", "RetainPV"), BackupRestoreRetainedPVWithSnapshots)
var _ = ginkgo.Describe("Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
ginkgo.Label("Basic", "Snapshot", "RetainPV"), BackupRestoreRetainedPVWithSnapshots)

var _ = Describe("Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
Label("Basic", "Restic", "RetainPV"), BackupRestoreRetainedPVWithRestic)
var _ = ginkgo.Describe("Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
ginkgo.Label("Basic", "Restic", "RetainPV"), BackupRestoreRetainedPVWithRestic)

var _ = Describe("Backup/restore of cluster resources",
Label("Basic", "ClusterResource"), ResourcesCheckTest)
var _ = ginkgo.Describe("Backup/restore of cluster resources",
ginkgo.Label("Basic", "ClusterResource"), ResourcesCheckTest)

var _ = Describe("Service NodePort reservation during restore is configurable",
Label("Basic", "NodePort"), NodePortTest)
var _ = ginkgo.Describe("Service NodePort reservation during restore is configurable",
ginkgo.Label("Basic", "NodePort"), NodePortTest)

var _ = Describe("Storage class of persistent volumes and persistent volume claims can be changed during restores",
Label("Basic", "StorageClass"), StorageClasssChangingTest)
var _ = ginkgo.Describe("Storage class of persistent volumes and persistent volume claims can be changed during restores",
ginkgo.Label("Basic", "StorageClass"), StorageClasssChangingTest)

var _ = Describe("Node selectors of persistent volume claims can be changed during restores",
Label("Basic", "SelectedNode", "SKIP_KIND"), PVCSelectedNodeChangingTest)
var _ = ginkgo.Describe("Node selectors of persistent volume claims can be changed during restores",
ginkgo.Label("Basic", "SelectedNode", "SKIP_KIND"), PVCSelectedNodeChangingTest)

var _ = Describe("Backup/restore of 2500 namespaces",
Label("Scale", "LongTime"), MultiNSBackupRestore)
var _ = ginkgo.Describe("Backup/restore of 2500 namespaces",
ginkgo.Label("Scale", "LongTime"), MultiNSBackupRestore)

// Upgrade test by Kibishii using Restic
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)
var _ = ginkgo.Describe("Velero upgrade tests on cluster using the plugin provider for object storage and Restic for volume backups",
ginkgo.Label("Upgrade", "Restic"), BackupUpgradeRestoreWithRestic)
var _ = ginkgo.Describe("Velero upgrade tests on cluster using the plugin provider for object storage and snapshots for volume backups",
ginkgo.Label("Upgrade", "Snapshot", "SkipVanillaZfs"), BackupUpgradeRestoreWithSnapshots)

// test filter objects by namespace, type, or labels when backup or restore.
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)
var _ = ginkgo.Describe("Resources with the label velero.io/exclude-from-backup=true are not included in backup",
ginkgo.Label("ResourceFiltering", "ExcludeFromBackup"), ExcludeFromBackupTest)
var _ = ginkgo.Describe("Velero test on exclude namespace from the cluster backup",
ginkgo.Label("ResourceFiltering", "ExcludeNamespaces", "Backup"), BackupWithExcludeNamespaces)
var _ = ginkgo.Describe("Velero test on exclude namespace from the cluster restore",
ginkgo.Label("ResourceFiltering", "ExcludeNamespaces", "Restore"), RestoreWithExcludeNamespaces)
var _ = ginkgo.Describe("Velero test on exclude resources from the cluster backup",
ginkgo.Label("ResourceFiltering", "ExcludeResources", "Backup"), BackupWithExcludeResources)
var _ = ginkgo.Describe("Velero test on exclude resources from the cluster restore",
ginkgo.Label("ResourceFiltering", "ExcludeResources", "Restore"), RestoreWithExcludeResources)
var _ = ginkgo.Describe("Velero test on include namespace from the cluster backup",
ginkgo.Label("ResourceFiltering", "IncludeNamespaces", "Backup"), BackupWithIncludeNamespaces)
var _ = ginkgo.Describe("Velero test on include namespace from the cluster restore",
ginkgo.Label("ResourceFiltering", "IncludeNamespaces", "Restore"), RestoreWithIncludeNamespaces)
var _ = ginkgo.Describe("Velero test on include resources from the cluster backup",
ginkgo.Label("ResourceFiltering", "IncludeResources", "Backup"), BackupWithIncludeResources)
var _ = ginkgo.Describe("Velero test on include resources from the cluster restore",
ginkgo.Label("ResourceFiltering", "IncludeResources", "Restore"), RestoreWithIncludeResources)
var _ = ginkgo.Describe("Velero test on backup include resources matching the label selector",
ginkgo.Label("ResourceFiltering", "LabelSelector"), BackupWithLabelSelector)
var _ = ginkgo.Describe("Velero test on skip backup of volume by resource policies",
ginkgo.Label("ResourceFiltering", "ResourcePolicies", "Restic"), ResourcePoliciesTest)

// backup VolumeInfo test
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",
Label("Schedule", "BR", "Pause", "LongTime"), ScheduleBackupTest)
var _ = Describe("Backup resources should follow the specific order in schedule",
Label("Schedule", "OrderedResources", "LongTime"), ScheduleOrderedResources)
var _ = Describe("Schedule controller wouldn't create a new backup when it still has pending or InProgress backup",
Label("Schedule", "BackupCreation", "SKIP_KIND", "LongTime"), ScheduleBackupCreationTest)

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("Migrate resources between clusters by Restic",
Label("Migration", "Restic"), MigrationWithRestic)
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)

func GetKubeconfigContext() error {
var _ = ginkgo.Describe("", ginkgo.Label("BackupVolumeInfo", "SkippedVolume"), SkippedVolumeInfoTest)
var _ = ginkgo.Describe("", ginkgo.Label("BackupVolumeInfo", "FilesystemUpload"), FilesystemUploadVolumeInfoTest)
var _ = ginkgo.Describe("", ginkgo.Label("BackupVolumeInfo", "CSIDataMover"), CSIDataMoverVolumeInfoTest)
var _ = ginkgo.Describe("", ginkgo.Label("BackupVolumeInfo", "CSISnapshot"), CSISnapshotVolumeInfoTest)
var _ = ginkgo.Describe("", ginkgo.Label("BackupVolumeInfo", "NativeSnapshot"), NativeSnapshotVolumeInfoTest)

var _ = ginkgo.Describe("Velero test on resource modifiers from the cluster restore",
ginkgo.Label("ResourceModifier", "Restore"), ResourceModifiersTest)

var _ = ginkgo.Describe("Velero tests of Restic backup deletion",
ginkgo.Label("Backups", "Deletion", "Restic"), BackupDeletionWithRestic)
var _ = ginkgo.Describe("Velero tests of snapshot backup deletion",
ginkgo.Label("Backups", "Deletion", "Snapshot", "SkipVanillaZfs"), BackupDeletionWithSnapshots)
var _ = ginkgo.Describe("Local backups and Restic repos will be deleted once the corresponding backup storage location is deleted",
ginkgo.Label("Backups", "TTL", "LongTime", "Snapshot", "SkipVanillaZfs"), TTLTest)
var _ = ginkgo.Describe("Backups in object storage are synced to a new Velero and deleted backups in object storage are synced to be deleted in Velero",
ginkgo.Label("Backups", "BackupsSync"), BackupsSyncTest)

var _ = ginkgo.Describe("Backup will be created periodically by schedule defined by a Cron expression",
ginkgo.Label("Schedule", "BR", "Pause", "LongTime"), ScheduleBackupTest)
var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("Schedule", "OrderedResources", "LongTime"), ScheduleOrderedResources)
var _ = ginkgo.Describe("Schedule controller wouldn't create a new backup when it still has pending or InProgress backup",
ginkgo.Label("Schedule", "BackupCreation", "SKIP_KIND", "LongTime"), ScheduleBackupCreationTest)

var _ = ginkgo.Describe("Velero test on ssr object when controller namespace mix-ups",
ginkgo.Label("PrivilegesMgmt", "SSR"), SSRTest)

var _ = ginkgo.Describe("Local backups will be deleted once the corresponding backup storage location is deleted",
ginkgo.Label("BSL", "Deletion", "Snapshot", "SkipVanillaZfs"), BslDeletionWithSnapshots)
var _ = ginkgo.Describe("Local backups and Restic repos will be deleted once the corresponding backup storage location is deleted",
ginkgo.Label("BSL", "Deletion", "Restic"), BslDeletionWithRestic)

var _ = ginkgo.Describe("Migrate resources between clusters by Restic",
ginkgo.Label("Migration", "Restic"), MigrationWithRestic)
var _ = ginkgo.Describe("Migrate resources between clusters by snapshot",
ginkgo.Label("Migration", "Snapshot", "SkipVanillaZfs"), MigrationWithSnapshots)

var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("NamespaceMapping", "Single", "Restic"), OneNamespaceMappingResticTest)
var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("NamespaceMapping", "Multiple", "Restic"), MultiNamespacesMappingResticTest)
var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("NamespaceMapping", "Single", "Snapshot", "SkipVanillaZfs"), OneNamespaceMappingSnapshotTest)
var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("NamespaceMapping", "Multiple", "Snapshot", "SkipVanillaZfs"), MultiNamespacesMappingSnapshotTest)

var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("PVBackup", "OptIn"), OptInPVBackupTest)
var _ = ginkgo.Describe("Backup resources should follow the specific order in schedule",
ginkgo.Label("PVBackup", "OptOut"), OptOutPVBackupTest)

var _ = ginkgo.Describe("Velero test on parallel files upload",
ginkgo.Label("UploaderConfig", "ParallelFilesUpload"), ParallelFilesUploadTest)
var _ = ginkgo.Describe("Velero test on parallel files download",
ginkgo.Label("UploaderConfig", "ParallelFilesDownload"), ParallelFilesDownloadTest)

func GetKubeConfigContext() error {
var err error
var tcDefault, tcStandby TestClient
tcDefault, err = NewTestClient(VeleroCfg.DefaultClusterContext)
Expand Down Expand Up @@ -287,29 +287,29 @@ func TestE2e(t *testing.T) {
}

var err error
if err = GetKubeconfigContext(); err != nil {
if err = GetKubeConfigContext(); err != nil {
fmt.Println(err)
t.FailNow()
}

RegisterFailHandler(Fail)
testSuitePassed = RunSpecs(t, "E2e Suite")
gomega.RegisterFailHandler(ginkgo.Fail)
testSuitePassed = ginkgo.RunSpecs(t, "E2e Suite")
}

var _ = BeforeSuite(func() {
var _ = ginkgo.BeforeSuite(func() {
if InstallVelero {
By("Install test resources before testing")
Expect(PrepareVelero(context.Background(), "install resource before testing", VeleroCfg)).To(Succeed())
ginkgo.By("Install test resources before testing")
gomega.Expect(PrepareVelero(context.Background(), "install resource before testing", VeleroCfg)).To(gomega.Succeed())
}
})

var _ = AfterSuite(func() {
var _ = ginkgo.AfterSuite(func() {
// 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.
if InstallVelero && (testSuitePassed || !VeleroCfg.FailFast) {
By("release test resources after testing")
ginkgo.By("release test resources after testing")
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
gomega.Expect(VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(gomega.Succeed())
}
})
Loading

0 comments on commit 587634f

Please sign in to comment.