From 3efaa0c5ee85da1ab24c77945adab773bf17d591 Mon Sep 17 00:00:00 2001 From: KrishhnaT Date: Wed, 28 Oct 2026 00:36:36 +0530 Subject: [PATCH] e2e: finish converting the CSI feature checks to FeatureEnabled (#10678) * e2e: finish converting the CSI feature checks to FeatureEnabled #10661 routed every check for EnableCSI through FeatureEnabled, which splits the comma-separated --features value instead of comparing the whole thing. One site was left on strings.EqualFold, because #10658 introduced it after #10661 had branched and the rebase applied cleanly without noticing. The result is that KibishiiVolumesAreHostPath and the Kind branch of installKibishii, which are inverses of each other and sit twenty-odd lines apart with comments saying so, disagree whenever a second feature is enabled. With --features=EnableCSI,EnableAPIGroupVersions on kind the mapping swaps in the CSI-backed overlay and the predicate still reports the volumes as hostPath, so the five cases install a cluster they can snapshot and then skip. Convert the last site and test the predicate against the list, case and single-feature shapes, which fails on the list cases before the change. The test would not have run in CI either: hack/test.sh listed ./test but not the other unit-testable packages under test/, so the two existing tests in this package and the five in test/pkg/client and test/util/velero were never executed. List all four. The e2e and perf suites stay out, since they call RunSpecs and need a cluster. Signed-off-by: krishhna24 * Add changelog for #10678 Signed-off-by: krishhna24 --------- Signed-off-by: krishhna24 --- changelogs/unreleased/10678-krishhna24 | 1 + hack/test.sh | 9 +++-- test/util/kibishii/kibishii_utils.go | 2 +- test/util/kibishii/kibishii_utils_test.go | 41 ++++++++++++++++++++++- 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/10678-krishhna24 diff --git a/changelogs/unreleased/10678-krishhna24 b/changelogs/unreleased/10678-krishhna24 new file mode 100644 index 000000000..9be6b6855 --- /dev/null +++ b/changelogs/unreleased/10678-krishhna24 @@ -0,0 +1 @@ +Match the last CSI feature check against the comma-separated --features list diff --git a/hack/test.sh b/hack/test.sh index 0ab625ba9..be25765ac 100755 --- a/hack/test.sh +++ b/hack/test.sh @@ -24,10 +24,13 @@ export CGO_ENABLED=0 TARGETS=($(go list ./pkg/... ./internal/...| grep -vE "/pkg/builder|pkg/apis|pkg/test|pkg/generated|pkg/plugin/generated|mocks|internal/restartabletest")) TARGETS+=( ./cmd/... - # The test/ root package only holds the e2e suite's shared types and their - # unit tests. The e2e suites themselves live in subpackages and are not - # listed, since running them needs a cluster. + # The unit-testable packages under test/. The e2e and perf suites are + # deliberately absent: they call RunSpecs and need a cluster, where these + # four hold the suite's shared helpers and test them in isolation. ./test + ./test/pkg/client + ./test/util/kibishii + ./test/util/velero ) if [[ ${#@} -ne 0 ]]; then diff --git a/test/util/kibishii/kibishii_utils.go b/test/util/kibishii/kibishii_utils.go index bf62c06de..1dc230843 100644 --- a/test/util/kibishii/kibishii_utils.go +++ b/test/util/kibishii/kibishii_utils.go @@ -299,7 +299,7 @@ func RunKibishiiTests( // pkg/podvolume/backupper.go matches pv.Spec.HostPath. The kind-csi overlay // produces pv.Spec.CSI instead and neither applies. func KibishiiVolumesAreHostPath(cfg VeleroConfig) bool { - return cfg.CloudProvider == Kind && !strings.EqualFold(cfg.Features, FeatureCSI) + return cfg.CloudProvider == Kind && !FeatureEnabled(cfg.Features, FeatureCSI) } func installKibishii( diff --git a/test/util/kibishii/kibishii_utils_test.go b/test/util/kibishii/kibishii_utils_test.go index 2936560ba..ef94bd94c 100644 --- a/test/util/kibishii/kibishii_utils_test.go +++ b/test/util/kibishii/kibishii_utils_test.go @@ -16,7 +16,46 @@ limitations under the License. package kibishii -import "testing" +import ( + "testing" + + . "github.com/velero-io/velero/test" +) + +// KibishiiVolumesAreHostPath and the Kind branch of installKibishii are +// inverses, so a --features value that one treats as enabling CSI and the +// other does not leaves the suite installing a CSI-backed overlay and then +// skipping the cases that would use it. --features takes a list, which is +// where they drifted apart once. +func TestKibishiiVolumesAreHostPath(t *testing.T) { + tests := []struct { + name string + provider string + features string + want bool + }{ + {"kind without CSI", Kind, "", true}, + {"kind with CSI", Kind, FeatureCSI, false}, + {"kind with CSI in a list", Kind, "EnableCSI,EnableAPIGroupVersions", false}, + {"kind with CSI last in a list", Kind, "EnableAPIGroupVersions,EnableCSI", false}, + {"kind with CSI in a spaced list", Kind, "EnableAPIGroupVersions, EnableCSI", false}, + {"kind with CSI in a different case", Kind, "enablecsi", false}, + {"kind with another feature only", Kind, "EnableAPIGroupVersions", true}, + {"a cloud provider without CSI", AWS, "", false}, + {"a cloud provider with CSI", AWS, FeatureCSI, false}, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + cfg := VeleroConfig{} + cfg.CloudProvider = tc.provider + cfg.Features = tc.features + if got := KibishiiVolumesAreHostPath(cfg); got != tc.want { + t.Errorf("KibishiiVolumesAreHostPath(provider=%q, features=%q) = %v, want %v", + tc.provider, tc.features, got, tc.want) + } + }) + } +} func TestResolveBasePath(t *testing.T) { tests := []struct {