From a3bd26acd930320c013fefd8e85af713a40a7107 Mon Sep 17 00:00:00 2001 From: danfengl Date: Thu, 18 Apr 2024 09:11:58 +0000 Subject: [PATCH] Remove CSI plugin in E2E test Signed-off-by: danfengl --- test/e2e/e2e_suite_test.go | 3 ++- test/util/velero/install.go | 4 +-- test/util/velero/velero_utils.go | 44 ++++++++++++-------------------- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 225f8bf6a7..7fca51363e 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -21,6 +21,7 @@ import ( "errors" "flag" "fmt" + "slices" "testing" "time" @@ -220,7 +221,7 @@ func TestE2e(t *testing.T) { t.Skip("Skipping E2E tests") } - if VeleroCfg.CloudProvider != "kind" { + if !slices.Contains(LocalCloudProviders, VeleroCfg.CloudProvider) { fmt.Println("For cloud platforms, object store plugin provider will be set as cloud provider") // If ObjectStoreProvider is not provided, then using the value same as CloudProvider if VeleroCfg.ObjectStoreProvider == "" { diff --git a/test/util/velero/install.go b/test/util/velero/install.go index ccbb6420c2..09fc7f3f77 100644 --- a/test/util/velero/install.go +++ b/test/util/velero/install.go @@ -387,7 +387,7 @@ func createVelereResources(ctx context.Context, cli, namespace string, args []st return errors.Wrapf(err, "failed to unmarshal the resources: %s", stdout) } - if err = patchResources(ctx, resources, namespace, options); err != nil { + if err = patchResources(resources, namespace, options); err != nil { return errors.Wrapf(err, "failed to patch resources") } @@ -409,7 +409,7 @@ func createVelereResources(ctx context.Context, cli, namespace string, args []st } // patch the velero resources -func patchResources(ctx context.Context, resources *unstructured.UnstructuredList, namespace string, options *installOptions) error { +func patchResources(resources *unstructured.UnstructuredList, namespace string, options *installOptions) error { i := 0 size := 2 var deploy apps.Deployment diff --git a/test/util/velero/velero_utils.go b/test/util/velero/velero_utils.go index 6774a05d87..3976480e7b 100644 --- a/test/util/velero/velero_utils.go +++ b/test/util/velero/velero_utils.go @@ -109,12 +109,11 @@ var pluginsMatrix = map[string]map[string][]string{ "azure": {"velero/velero-plugin-for-microsoft-azure:main"}, "vsphere": {"vsphereveleroplugin/velero-plugin-for-vsphere:v1.5.2"}, "gcp": {"velero/velero-plugin-for-gcp:main"}, - "csi": {"velero/velero-plugin-for-csi:main"}, "datamover": {"velero/velero-plugin-for-aws:main"}, }, } -func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature string, needDataMoverPlugin bool) ([]string, error) { +func getPluginsByVersion(version, cloudProvider, objectStoreProvider string, needDataMoverPlugin bool) ([]string, error) { var cloudMap map[string][]string arr := strings.Split(version, ".") if len(arr) >= 3 { @@ -126,43 +125,33 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st return nil, errors.Errorf("fail to get plugins by version: main") } } - var pluginsForFeature []string + var plugins []string + var ok bool if slices.Contains(LocalCloudProviders, cloudProvider) { - var pluginsCSI []string - plugins, ok := cloudMap[Aws] + plugins, ok = cloudMap[Aws] if !ok { return nil, errors.Errorf("fail to get plugins by version: %s and provider %s", version, cloudProvider) } - if cloudProvider == VanillaZFS { - pluginsCSI, ok = cloudMap["csi"] - if !ok { - return nil, errors.Errorf("fail to get plugins by version: %s and provider %s", version, cloudProvider) - } + } else { + plugins, ok = cloudMap[cloudProvider] + if !ok { + return nil, errors.Errorf("fail to get plugins by version: %s and provider %s", version, cloudProvider) } - return append(plugins, pluginsCSI...), nil - } - - plugins, ok := cloudMap[cloudProvider] - if !ok { - return nil, errors.Errorf("fail to get plugins by version: %s and provider %s", version, cloudProvider) } - + // TODO: Is this section need? if objectStoreProvider != cloudProvider { pluginsForObjectStoreProvider, ok := cloudMap[objectStoreProvider] if !ok { return nil, errors.Errorf("fail to get plugins by version: %s and object store provider %s", version, objectStoreProvider) } - plugins = append(plugins, pluginsForObjectStoreProvider...) - } - - if strings.EqualFold(feature, FeatureCSI) { - pluginsForFeature, ok = cloudMap["csi"] - if !ok { - return nil, errors.Errorf("fail to get CSI plugins by version: %s ", version) + for _, p := range pluginsForObjectStoreProvider { + if !slices.Contains(plugins, p) { + plugins = append(plugins, p) + } } - plugins = append(plugins, pluginsForFeature...) } + if needDataMoverPlugin { pluginsForDatamover, ok := cloudMap["datamover"] if !ok { @@ -647,7 +636,7 @@ func getProviderPlugins(ctx context.Context, veleroCLI string, cloudProvider str return nil, errors.WithMessage(err, "failed to get velero version") } - plugins, err := getPluginsByVersion(version, cloudProvider, cloudProvider, "", false) + plugins, err := getPluginsByVersion(version, cloudProvider, cloudProvider, false) if err != nil { return nil, errors.WithMessagef(err, "Fail to get plugin by provider %s and version %s", cloudProvider, version) } @@ -663,7 +652,6 @@ func getPlugins(ctx context.Context, veleroCfg VeleroConfig) ([]string, error) { cloudProvider := veleroCfg.CloudProvider objectStoreProvider := veleroCfg.ObjectStoreProvider providerPlugins := veleroCfg.Plugins - feature := veleroCfg.Features needDataMoverPlugin := false // Fetch the plugins for the provider before checking for the object store provider below. @@ -691,7 +679,7 @@ func getPlugins(ctx context.Context, veleroCfg VeleroConfig) ([]string, error) { if veleroCfg.SnapshotMoveData && veleroCfg.DataMoverPlugin == "" && !veleroCfg.IsUpgradeTest { needDataMoverPlugin = true } - plugins, err = getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature, needDataMoverPlugin) + plugins, err = getPluginsByVersion(version, cloudProvider, objectStoreProvider, needDataMoverPlugin) if err != nil { return nil, errors.WithMessagef(err, "Fail to get plugin by provider %s and version %s", objectStoreProvider, version) }