Skip to content

Commit

Permalink
Add additional parameters for HorizonTest
Browse files Browse the repository at this point in the history
This PR adds additional paramaters to horizontest CR in order to modify
the pytest command and projectname xpath based on upstream and
downstream dashboard theme
  • Loading branch information
ashu-011 committed Feb 4, 2025
1 parent be35b07 commit d21d668
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/bases/test.openstack.org_horizontests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ spec:
(stuck in "Running" phase) or until the corresponding HorizonTest CR is deleted.
This allows the user to debug any potential troubles with `oc rsh`.
type: boolean
extraFlag:
description: An extra flag that can be set to modify pytest command to
exclude or include particular test(s)
type: string
extraConfigmapsMounts:
description: Extra configmaps for mounting inside the pod
items:
Expand Down Expand Up @@ -171,6 +175,10 @@ spec:
description: ProjectName is the name of the OpenStack project for
Horizon tests.
type: string
projectNameXpath:
description: ProjectNameXpath is the xpath to select project name
on the horizon dashboard based on the u/s or d/s theme
type: string
repoUrl:
default: https://review.opendev.org/openstack/horizon
description: RepoUrl is the URL of the Horizon repository.
Expand Down
12 changes: 12 additions & 0 deletions api/v1beta1/horizontest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ type HorizonTestSpec struct {
// This allows the user to debug any potential troubles with `oc rsh`.
Debug bool `json:"debug"`

// ExtraFlag is an extra flag that can be set to modify pytest command to
// exclude or include particular test(s)
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
ExtraFlag string `json:"extraFlag"`

// ProjectNameXpath is the xpath to select project name
// on the horizon dashboard based on the u/s or d/s theme
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
ProjectNameXpath string `json:"projectNameXpath"`

// AdminUsername is the username for the OpenStack admin user.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/test.openstack.org_horizontests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ spec:
- subPath
type: object
type: array
extraFlag:
description: |-
ExtraFlag is an extra flag that can be set to modify pytest command to
exclude or include particular test(s)
type: string
flavorName:
default: m1.tiny
description: FlavorName is the name of the OpenStack flavor to create
Expand Down Expand Up @@ -171,6 +176,11 @@ spec:
description: ProjectName is the name of the OpenStack project for
Horizon tests.
type: string
projectNameXpath:
description: |-
ProjectNameXpath is the xpath to select project name
on the horizon dashboard based on the u/s or d/s theme
type: string
repoUrl:
default: https://review.opendev.org/openstack/horizon
description: RepoUrl is the URL of the Horizon repository.
Expand Down
6 changes: 6 additions & 0 deletions config/samples/test_v1beta1_horizontest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ spec:
# The maximum number of retry executions (optional)
backoffLimit: 0

# The extra flag to modify pyTest commmand (optional)
extraFlag: "not pagination"

# ProjectNameXpath is the xpath to select project name on dashboard (optional)
projectNameXpath: "//span[@class='rcueicon rcueicon-folder-open']/ancestor::li"

# Privileged
# ----------
#
Expand Down
2 changes: 2 additions & 0 deletions controllers/horizontest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ func (r *HorizonTestReconciler) PrepareHorizonTestEnvVars(
envVars["FLAVOR_NAME"] = env.SetValue("m1.tiny")
envVars["HORIZON_KEYS_FOLDER"] = env.SetValue("/etc/test_operator")
envVars["HORIZONTEST_DEBUG_MODE"] = env.SetValue(r.GetDefaultBool(instance.Spec.Debug))
envVars["EXTRA_FLAG"] = env.SetValue(instance.Spec.ExtraFlag)
envVars["ProjectNameXpath"] = env.SetValue(instance.Spec.ProjectNameXpath)

return envVars
}

0 comments on commit d21d668

Please sign in to comment.