Skip to content

Commit a3f78e7

Browse files
Merge pull request #432 from kstrenkova/tobiko-skip-regex-list
[tobiko] Add new parameter SkipRegexList
2 parents 9a689c2 + 948bd4f commit a3f78e7

6 files changed

Lines changed: 73 additions & 1 deletion

File tree

api/bases/test.openstack.org_tobikoes.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,14 @@ spec:
13781378
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
13791379
type: object
13801380
type: object
1381+
skipRegexList:
1382+
description: |-
1383+
List of test name patterns to skip. It has the same functionality
1384+
as the --skipregex parameter used in PytestAddopts.
1385+
items:
1386+
type: string
1387+
type: array
1388+
x-kubernetes-list-type: atomic
13811389
storageClass:
13821390
default: local-storage
13831391
description: StorageClass used to create any test-operator related
@@ -1617,6 +1625,14 @@ spec:
16171625
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
16181626
type: object
16191627
type: object
1628+
skipRegexList:
1629+
description: |-
1630+
List of test name patterns to skip. It has the same functionality
1631+
as the --skipregex parameter used in PytestAddopts.
1632+
items:
1633+
type: string
1634+
type: array
1635+
x-kubernetes-list-type: atomic
16201636
stepName:
16211637
description: A parameter that contains a definition of a single
16221638
workflow step.

api/v1beta1/tobiko_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ type TobikoSpec struct {
6464
// String including any options to pass to pytest when it runs tobiko tests
6565
PytestAddopts string `json:"pytestAddopts"`
6666

67+
// +kubebuilder:validation:Optional
68+
// +listType=atomic
69+
// +operator-sdk:csv:customresourcedefinitions:type=spec
70+
// List of test name patterns to skip. It has the same functionality
71+
// as the --skipregex parameter used in PytestAddopts.
72+
SkipRegexList []string `json:"skipRegexList,omitempty"`
73+
6774
// +kubebuilder:validation:Optional
6875
// +operator-sdk:csv:customresourcedefinitions:type=spec
6976
// +kubebuilder:default:=false
@@ -151,6 +158,13 @@ type TobikoWorkflowSpec struct {
151158
// String including any options to pass to pytest when it runs tobiko tests
152159
PytestAddopts string `json:"pytestAddopts,omitempty"`
153160

161+
// +kubebuilder:validation:Optional
162+
// +listType=atomic
163+
// +operator-sdk:csv:customresourcedefinitions:type=spec
164+
// List of test name patterns to skip. It has the same functionality
165+
// as the --skipregex parameter used in PytestAddopts.
166+
SkipRegexList []string `json:"skipRegexList,omitempty"`
167+
154168
// +kubebuilder:validation:Optional
155169
// +operator-sdk:csv:customresourcedefinitions:type=spec
156170
// Boolean specifying whether tobiko tests create new resources or re-use those previously created

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/test.openstack.org_tobikoes.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,14 @@ spec:
13781378
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
13791379
type: object
13801380
type: object
1381+
skipRegexList:
1382+
description: |-
1383+
List of test name patterns to skip. It has the same functionality
1384+
as the --skipregex parameter used in PytestAddopts.
1385+
items:
1386+
type: string
1387+
type: array
1388+
x-kubernetes-list-type: atomic
13811389
storageClass:
13821390
default: local-storage
13831391
description: StorageClass used to create any test-operator related
@@ -1617,6 +1625,14 @@ spec:
16171625
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
16181626
type: object
16191627
type: object
1628+
skipRegexList:
1629+
description: |-
1630+
List of test name patterns to skip. It has the same functionality
1631+
as the --skipregex parameter used in PytestAddopts.
1632+
items:
1633+
type: string
1634+
type: array
1635+
x-kubernetes-list-type: atomic
16201636
stepName:
16211637
description: A parameter that contains a definition of a single
16221638
workflow step.

internal/controller/common.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,22 @@ func SetDictEnvVar(envVars map[string]string, fields map[string]string) {
846846
}
847847
}
848848

849+
// PreparePytestAddopts adds skipregex parameter to the PytestAddopts
850+
func PreparePytestAddopts(pytestAddopts string, skipRegexList []string) string {
851+
if len(skipRegexList) == 0 {
852+
return pytestAddopts
853+
}
854+
855+
skipRegex := strings.Join(skipRegexList, "|")
856+
skipOpt := fmt.Sprintf("--skipregex='%s'", skipRegex)
857+
858+
if len(pytestAddopts) == 0 {
859+
return skipOpt
860+
}
861+
862+
return fmt.Sprintf("%s %s", pytestAddopts, skipOpt)
863+
}
864+
849865
// GetStringField returns reflect string field safely
850866
func GetStringField(v reflect.Value, fieldName string) string {
851867
field, err := SafetyCheck(v, fieldName)

internal/controller/tobiko_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (r *TobikoReconciler) PrepareTobikoEnvVars(
237237
"TOBIKO_LOGS_DIR_NAME": r.GetPodName(instance, workflowStepIndex),
238238
"TOBIKO_TESTENV": instance.Spec.Testenv,
239239
"TOBIKO_VERSION": instance.Spec.Version,
240-
"TOBIKO_PYTEST_ADDOPTS": instance.Spec.PytestAddopts,
240+
"TOBIKO_PYTEST_ADDOPTS": PreparePytestAddopts(instance.Spec.PytestAddopts, instance.Spec.SkipRegexList),
241241
"TOBIKO_KEYS_FOLDER": "/etc/test_operator",
242242
})
243243

0 commit comments

Comments
 (0)