mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-11-08 04:18:06 +00:00
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 <krishhnatupedev@gmail.com> * Add changelog for #10678 Signed-off-by: krishhna24 <krishhnatupedev@gmail.com> --------- Signed-off-by: krishhna24 <krishhnatupedev@gmail.com>
This commit is contained in:
1 parent
fdb626231c
commit
3efaa0c5ee
4 files changed
+48
-5
No files matched your search
@@ -0,0 +1 @@
|
||||
Match the last CSI feature check against the comma-separated --features list
|
||||
+6
-3
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user