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 {