From 2bd86a4346e6e06f50d55503448553d0ce4c9f82 Mon Sep 17 00:00:00 2001 From: Lukas Piwowarski Date: Wed, 22 Nov 2023 17:57:42 +0200 Subject: [PATCH] Add support for external plugins This patch ensures that the test operator takes advantage of the new parameters of the tempest container: - TEMPEST_EXTERNAL_PLUGIN_GIT_URL - TEMPEST_EXTERNAL_PLUGIN_CHANGE_URL - TEMPEST_EXTERNAL_PLUGIN_REFSPEC The user can use this parameters by specifying the following values for the Tempest CR: - externalPluginGitURL - externalPluginChangeURL - externalPluginRefspec --- api/bases/test.openstack.org_tempests.yaml | 24 +++++++++++++++++++ api/v1beta1/tempest_types.go | 21 ++++++++++++++++ api/v1beta1/zz_generated.deepcopy.go | 17 ++++++++++++- .../bases/test.openstack.org_tempests.yaml | 24 +++++++++++++++++++ config/samples/test_v1beta1_tempest.yaml | 9 +++++++ controllers/tempest_controller.go | 13 ++++++++++ docs/source/samples/tempest-config.yaml | 3 +++ 7 files changed, 110 insertions(+), 1 deletion(-) diff --git a/api/bases/test.openstack.org_tempests.yaml b/api/bases/test.openstack.org_tempests.yaml index 191dddb5..47656d7e 100644 --- a/api/bases/test.openstack.org_tempests.yaml +++ b/api/bases/test.openstack.org_tempests.yaml @@ -121,6 +121,30 @@ spec: default: "" description: ExcludeList type: string + externalPluginChangeURL: + description: ExternalPluginsChangeURL should be used together + with ExternalPluginsRefspec. These two variables specify which + changes should be download from gerrit/github for each downloaded + plugin (see ExternalPluginGitURL). Both variables are arrays. + items: + type: string + type: array + externalPluginRefspec: + description: ExternalPluginsChangeURL should be used together + with ExternalPluginsRefspecs. These two variables specify which + changes should be download from gerrit/github for each downloaded + plugin (see ExternalPluginGitURL). Both variables are arrays. + items: + type: string + type: array + externalPluginURL: + description: ExternalPluginsURL is an array of URLs that point + to git repositories containing tempest plugins that should be + installed within the tempest container. If this option is specified + then only tests from the external plugins are executed. + items: + type: string + type: array includeList: default: tempest.api.identity.v3 description: IncludeList diff --git a/api/v1beta1/tempest_types.go b/api/v1beta1/tempest_types.go index e8bbcee7..6a1ca3f8 100644 --- a/api/v1beta1/tempest_types.go +++ b/api/v1beta1/tempest_types.go @@ -71,6 +71,27 @@ type TempestRunSpec struct { // +kubebuilder:default:="" // WorkerFile is the detailed concurrency spec file WorkerFile string `json:"workerFile,omitempty"` + + // +kubebuilder:validation:Optional + // ExternalPluginsURL is an array of URLs that point + // to git repositories containing tempest plugins that should be + // installed within the tempest container. If this option is + // specified then only tests from the external plugins are executed. + ExternalPluginGitURL []string `json:"externalPluginURL,omitempty"` + + // +kubebuilder:validation:Optional + // ExternalPluginsChangeURL should be used together with + // ExternalPluginsRefspec. These two variables specify which changes + // should be download from gerrit/github for each downloaded plugin + // (see ExternalPluginGitURL). Both variables are arrays. + ExternalPluginChangeURL []string `json:"externalPluginChangeURL,omitempty"` + + // +kubebuilder:validation:Optional + // ExternalPluginsChangeURL should be used together with + // ExternalPluginsRefspecs. These two variables specify which changes + // should be download from gerrit/github for each downloaded plugin + // (see ExternalPluginGitURL). Both variables are arrays. + ExternalPluginRefspec []string `json:"externalPluginRefspec,omitempty"` } // TempestSpec PythonTempestconf parts diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index ad5c474a..28f56dd4 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -123,6 +123,21 @@ func (in *TempestList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TempestRunSpec) DeepCopyInto(out *TempestRunSpec) { *out = *in + if in.ExternalPluginGitURL != nil { + in, out := &in.ExternalPluginGitURL, &out.ExternalPluginGitURL + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExternalPluginChangeURL != nil { + in, out := &in.ExternalPluginChangeURL, &out.ExternalPluginChangeURL + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExternalPluginRefspec != nil { + in, out := &in.ExternalPluginRefspec, &out.ExternalPluginRefspec + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TempestRunSpec. @@ -165,7 +180,7 @@ func (in *TempestSpec) DeepCopyInto(out *TempestSpec) { if in.TempestRun != nil { in, out := &in.TempestRun, &out.TempestRun *out = new(TempestRunSpec) - **out = **in + (*in).DeepCopyInto(*out) } if in.TempestconfRun != nil { in, out := &in.TempestconfRun, &out.TempestconfRun diff --git a/config/crd/bases/test.openstack.org_tempests.yaml b/config/crd/bases/test.openstack.org_tempests.yaml index 191dddb5..47656d7e 100644 --- a/config/crd/bases/test.openstack.org_tempests.yaml +++ b/config/crd/bases/test.openstack.org_tempests.yaml @@ -121,6 +121,30 @@ spec: default: "" description: ExcludeList type: string + externalPluginChangeURL: + description: ExternalPluginsChangeURL should be used together + with ExternalPluginsRefspec. These two variables specify which + changes should be download from gerrit/github for each downloaded + plugin (see ExternalPluginGitURL). Both variables are arrays. + items: + type: string + type: array + externalPluginRefspec: + description: ExternalPluginsChangeURL should be used together + with ExternalPluginsRefspecs. These two variables specify which + changes should be download from gerrit/github for each downloaded + plugin (see ExternalPluginGitURL). Both variables are arrays. + items: + type: string + type: array + externalPluginURL: + description: ExternalPluginsURL is an array of URLs that point + to git repositories containing tempest plugins that should be + installed within the tempest container. If this option is specified + then only tests from the external plugins are executed. + items: + type: string + type: array includeList: default: tempest.api.identity.v3 description: IncludeList diff --git a/config/samples/test_v1beta1_tempest.yaml b/config/samples/test_v1beta1_tempest.yaml index de773703..947438eb 100644 --- a/config/samples/test_v1beta1_tempest.yaml +++ b/config/samples/test_v1beta1_tempest.yaml @@ -23,6 +23,15 @@ spec: # smoke: false # serial: false # parallel: true + # externalPluginURL: + # - "https://opendev.org/openstack/barbican-tempest-plugin.git" + # - "https://opendev.org/openstack/neutron-tempest-plugin.git" + # externalPluginChangeURL: + # - "https://review.opendev.org/openstack/barbican-tempest-plugin" + # - "https://review.opendev.org/openstack/neutron-tempest-plugin" + # externalPluginRefspec: + # - "refs/changes/79/897279/8" + # - "refs/changes/97/896397/2" tempestconfRun: # NOTE: All parameters have default values (use only when you want to override # the default behaviour) diff --git a/controllers/tempest_controller.go b/controllers/tempest_controller.go index 82bff502..6b6298bc 100644 --- a/controllers/tempest_controller.go +++ b/controllers/tempest_controller.go @@ -436,6 +436,19 @@ func setTempestConfigVars(envVars map[string]string, // Int envVars["TEMPEST_CONCURRENCY"] = getDefaultInt(tempestRun.Concurrency) + + // Arrays + for _, value := range tempestRun.ExternalPluginGitURL { + envVars["TEMPEST_EXTERNAL_PLUGIN_GIT_URL"] += value + } + + for _, value := range tempestRun.ExternalPluginChangeURL { + envVars["TEMPEST_EXTERNAL_PLUGIN_CHANGE_URL"] = value + } + + for _, value := range tempestRun.ExternalPluginRefspec { + envVars["TEMPEST_EXTERNAL_PLUGIN_REFSPEC"] = value + } } func setTempestconfConfigVars(envVars map[string]string, diff --git a/docs/source/samples/tempest-config.yaml b/docs/source/samples/tempest-config.yaml index 6a46d373..8adccb9d 100644 --- a/docs/source/samples/tempest-config.yaml +++ b/docs/source/samples/tempest-config.yaml @@ -25,6 +25,9 @@ data: # TEMPEST_SMOKE: true # TEMPEST_PARALLEL: true # TEMPEST_SERIAL: true + # TEMPEST_EXTERNAL_PLUGIN_GIT_URL: "https://opendev.org/openstack/barbican-tempest-plugin.git,https://opendev.org/openstack/neutron-tempest-plugin.git" + # TEMPEST_EXTERNAL_PLUGIN_CHANGE_URL: "https://review.opendev.org/openstack/barbican-tempest-plugin,https://review.opendev.org/openstack/neutron-tempest-plugin" + # TEMPEST_EXTERNAL_PLUGIN_REFSPEC: "refs/changes/79/897279/8,refs/changes/97/896397/2" # TEMPESTCONF env variables: # --------------------------