From 4e481fb7c29fff30cdb856677b8e9a191ee25d04 Mon Sep 17 00:00:00 2001 From: KrishhnaT Date: Sat, 12 Sep 2026 02:51:41 +0530 Subject: [PATCH] test: use the Kind constant instead of the string literal (#10524) * test: use the Kind constant instead of the string literal test/types.go defines `const Kind = "kind"` and most of the suite compares against it, but three sites still use the bare string. deletion.go is inconsistent with itself: the BeforeEach skip uses Kind while the one in runBackupDeletionTests uses "kind", and its skip message hardcodes the provider name where the other formats it. namespace-mapping.go dot-imports test/e2e/test rather than test, so the constant was not in scope there. Import the test package by name, as test/e2e/migration/migration.go already does alongside its framework import, and reference test.Kind. No behavioural change: the constant's value is the string being replaced. Signed-off-by: krishhna24 * Add changelog for #10524 Signed-off-by: krishhna24 --------- Signed-off-by: krishhna24 --- changelogs/unreleased/10524-krishhna24 | 1 + test/e2e/backups/deletion.go | 4 ++-- test/e2e/basic/namespace-mapping.go | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/10524-krishhna24 diff --git a/changelogs/unreleased/10524-krishhna24 b/changelogs/unreleased/10524-krishhna24 new file mode 100644 index 000000000..02943adfa --- /dev/null +++ b/changelogs/unreleased/10524-krishhna24 @@ -0,0 +1 @@ +Use the Kind constant instead of the kind string literal in the e2e tests diff --git a/test/e2e/backups/deletion.go b/test/e2e/backups/deletion.go index a9ee3ce5f..e96433d1a 100644 --- a/test/e2e/backups/deletion.go +++ b/test/e2e/backups/deletion.go @@ -88,8 +88,8 @@ func runBackupDeletionTests(client TestClient, veleroCfg VeleroConfig, backupLoc nsCount := len(workloadNamespaceList) workloadNamespaces := strings.Join(workloadNamespaceList[:], ",") - if useVolumeSnapshots && veleroCfg.CloudProvider == "kind" { - Skip("Volume snapshots not supported on kind") + if useVolumeSnapshots && veleroCfg.CloudProvider == Kind { + Skip(fmt.Sprintf("Volume snapshots not supported on %s", Kind)) } oneHourTimeout, ctxCancel := context.WithTimeout(context.Background(), time.Minute*60) defer ctxCancel() diff --git a/test/e2e/basic/namespace-mapping.go b/test/e2e/basic/namespace-mapping.go index a5a0cc1be..59e3c0939 100644 --- a/test/e2e/basic/namespace-mapping.go +++ b/test/e2e/basic/namespace-mapping.go @@ -8,6 +8,7 @@ import ( . "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/kibishii" @@ -34,7 +35,7 @@ func (n *NamespaceMapping) Init() error { n.VeleroCfg.UseVolumeSnapshots = n.UseVolumeSnapshots n.VeleroCfg.UseNodeAgent = !n.UseVolumeSnapshots n.kibishiiData = &KibishiiData{Levels: 2, DirsPerLevel: 10, FilesPerLevel: 10, FileLength: 1024, BlockSize: 1024, PassNum: 0, ExpectedNodes: 2} - if n.VeleroCfg.CloudProvider == "kind" { + if n.VeleroCfg.CloudProvider == test.Kind { n.kibishiiData = &KibishiiData{Levels: 0, DirsPerLevel: 0, FilesPerLevel: 0, FileLength: 0, BlockSize: 0, PassNum: 0, ExpectedNodes: 2} } backupType := "fs-backup" @@ -70,7 +71,7 @@ func (n *NamespaceMapping) Init() error { "create", "--namespace", n.VeleroCfg.VeleroNamespace, "backup", n.BackupName, "--include-namespaces", strings.Join(*n.NSIncluded, ","), "--wait", } - if n.VeleroCfg.CloudProvider == "kind" { + if n.VeleroCfg.CloudProvider == test.Kind { // don't test volume snapshotter or file system backup on kind n.BackupArgs = append(n.BackupArgs, "--snapshot-volumes=false") n.UseVolumeSnapshots = false