Skip to content

Commit

Permalink
Merge pull request #12 from openstack-k8s-operators/lpiwowar/feature/…
Browse files Browse the repository at this point in the history
…tempest-external-params

Add support for external plugins
  • Loading branch information
kopecmartin authored Dec 20, 2023
2 parents 2824bde + 4a98fb2 commit 1e53401
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 3 deletions.
26 changes: 26 additions & 0 deletions api/bases/test.openstack.org_tempests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ spec:
default: ""
description: ExcludeList
type: string
externalPlugin:
description: ExternalPlugin contains information about plugin
that should be installed within the tempest container. If this
option is specified then only tests that are part of the external
plugin can be executed.
items:
properties:
changeRefspec:
default: ""
description: ChangeRefspec specifies which change the remote
repository should be checked out to (ChangeRepository
must be defined as well).
type: string
changeRepository:
default: ""
description: URL that points to a repository that contains
a change that should be applied to the repository defined
by Repository (ChangeRefspec must be defined as well).
type: string
repository:
default: ""
description: URL that points to a git repository containing
the external plugin.
type: string
type: object
type: array
includeList:
default: tempest.api.identity.v3
description: IncludeList
Expand Down
30 changes: 30 additions & 0 deletions api/v1beta1/tempest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ type Hash struct {
Hash string `json:"hash,omitempty"`
}


type ExternalPluginType struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=""
// URL that points to a git repository containing
// the external plugin.
Repository string `json:"repository,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=""
// URL that points to a repository that contains a change
// that should be applied to the repository defined by Repository
// (ChangeRefspec must be defined as well).
ChangeRepository string `json:"changeRepository,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=""
// ChangeRefspec specifies which change the remote repository
// should be checked out to (ChangeRepository must be defined
// as well).
ChangeRefspec string `json:"changeRefspec,omitempty"`
}

// TempestSpec TempestRun parts
type TempestRunSpec struct {
// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -71,6 +94,13 @@ type TempestRunSpec struct {
// +kubebuilder:default:=""
// WorkerFile is the detailed concurrency spec file
WorkerFile string `json:"workerFile,omitempty"`

// +kubebuilder:validation:Optional
// ExternalPlugin contains information about plugin
// that should be installed within the tempest container.
// If this option is specified then only tests that are part of
// the external plugin can be executed.
ExternalPlugin []ExternalPluginType `json:"externalPlugin,omitempty"`
}

// TempestSpec PythonTempestconf parts
Expand Down
22 changes: 21 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions config/crd/bases/test.openstack.org_tempests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ spec:
default: ""
description: ExcludeList
type: string
externalPlugin:
description: ExternalPlugin contains information about plugin
that should be installed within the tempest container. If this
option is specified then only tests that are part of the external
plugin can be executed.
items:
properties:
changeRefspec:
default: ""
description: ChangeRefspec specifies which change the remote
repository should be checked out to (ChangeRepository
must be defined as well).
type: string
changeRepository:
default: ""
description: URL that points to a repository that contains
a change that should be applied to the repository defined
by Repository (ChangeRefspec must be defined as well).
type: string
repository:
default: ""
description: URL that points to a git repository containing
the external plugin.
type: string
type: object
type: array
includeList:
default: tempest.api.identity.v3
description: IncludeList
Expand Down
5 changes: 5 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: quay.io/openstack-k8s-operators/test-operator-index
5 changes: 5 additions & 0 deletions config/samples/test_v1beta1_tempest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ spec:
# smoke: false
# serial: false
# parallel: true
# externalPlugin:
# - repository: "https://opendev.org/openstack/barbican-tempest-plugin.git"
# - repository: "https://opendev.org/openstack/neutron-tempest-plugin.git"
# changeRepository: "https://review.opendev.org/openstack/neutron-tempest-plugin"
# changeRefspec: "refs/changes/97/896397/2"
tempestconfRun:
# NOTE: All parameters have default values (use only when you want to override
# the default behaviour)
Expand Down
19 changes: 17 additions & 2 deletions controllers/tempest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ func getDefaultInt(variable int64) string {

func setTempestConfigVars(envVars map[string]string,
customData map[string]string,
tempestRun *testv1beta1.TempestRunSpec) {
tempestRun *testv1beta1.TempestRunSpec,
ctx context.Context) {

testOperatorDir := "/etc/test_operator/"
if tempestRun == nil {
Expand Down Expand Up @@ -447,6 +448,20 @@ func setTempestConfigVars(envVars map[string]string,

// Int
envVars["TEMPEST_CONCURRENCY"] = getDefaultInt(tempestRun.Concurrency)

// Dictionary
for _, externalPluginDictionary := range tempestRun.ExternalPlugin {
envVars["TEMPEST_EXTERNAL_PLUGIN_GIT_URL"] += externalPluginDictionary.Repository + ","

if len(externalPluginDictionary.ChangeRepository) == 0 || len(externalPluginDictionary.ChangeRefspec) == 0 {
envVars["TEMPEST_EXTERNAL_PLUGIN_CHANGE_URL"] += "-,"
envVars["TEMPEST_EXTERNAL_PLUGIN_REFSPEC"] += "-,"
continue
}

envVars["TEMPEST_EXTERNAL_PLUGIN_CHANGE_URL"] += externalPluginDictionary.ChangeRepository + ","
envVars["TEMPEST_EXTERNAL_PLUGIN_REFSPEC"] += externalPluginDictionary.ChangeRefspec + ","
}
}

func setTempestconfConfigVars(envVars map[string]string,
Expand Down Expand Up @@ -535,7 +550,7 @@ func (r *TempestReconciler) generateServiceConfigMaps(
customData := make(map[string]string)
envVars := make(map[string]string)

setTempestConfigVars(envVars, customData, instance.Spec.TempestRun)
setTempestConfigVars(envVars, customData, instance.Spec.TempestRun, ctx)
setTempestconfConfigVars(envVars, customData, instance.Spec.TempestconfRun)

/* Tempestconf - end */
Expand Down
3 changes: 3 additions & 0 deletions docs/source/samples/tempest-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/neutron-tempest-plugin"
# TEMPEST_EXTERNAL_PLUGIN_REFSPEC: "-,refs/changes/97/896397/2"

# TEMPESTCONF env variables:
# --------------------------
Expand Down

0 comments on commit 1e53401

Please sign in to comment.