Skip to content

Commit b86e9c1

Browse files
Custom Tests with Operator choice using new Python test script.
1 parent facf544 commit b86e9c1

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

tools/testing-toolbox/create_testsuite.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
platform_name = None
1010
k8s_version = None
1111
operator_version = None
12+
test_script_params = None
1213
git_branch = None
1314
beku_suite = None
1415
metadata_annotations = {}
@@ -85,12 +86,14 @@ def read_params():
8586
- GIT_BRANCH
8687
- BEKU_SUITE
8788
- OPERATOR_VERSION
89+
- TEST_SCRIPT_PARAMS
8890
- METADATA_ANNOTATION_xyz
8991
"""
9092
global testsuite_name
9193
global platform_name
9294
global k8s_version
9395
global operator_version
96+
global test_script_params
9497
global git_branch
9598
global beku_suite
9699
global metadata_annotations
@@ -107,6 +110,8 @@ def read_params():
107110
platform_name, k8s_version = read_platform_and_k8s_version()
108111
if 'OPERATOR_VERSION' in os.environ:
109112
operator_version = os.environ["OPERATOR_VERSION"]
113+
if 'TEST_SCRIPT_PARAMS' in os.environ:
114+
test_script_params = os.environ["TEST_SCRIPT_PARAMS"]
110115
if 'GIT_BRANCH' in os.environ:
111116
git_branch = os.environ["GIT_BRANCH"]
112117
if 'BEKU_SUITE' in os.environ:
@@ -219,6 +224,11 @@ def create_testsuite():
219224
cluster_definition['metadata']['annotations'] = {}
220225
for key,value in metadata_annotations.items():
221226
cluster_definition['metadata']['annotations'][key] = value
222-
223227
write_cluster_definition(cluster_definition)
224-
write_test_script(testsuite, testsuite_platform_definition['test_params'] if 'test_params' in testsuite_platform_definition else '')
228+
229+
test_script_params_array = []
230+
if 'test_params' in testsuite_platform_definition:
231+
test_script_params_array.append(testsuite_platform_definition['test_params'])
232+
if test_script_params:
233+
test_script_params_array.append(test_script_params)
234+
write_test_script(testsuite, ' '.join(test_script_params_array))

tools/testing-toolbox/jjb/custom_test_jobs.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
choices:{% for platform in platforms[testsuite.name] %}
3636
- {{ platform.display_name }}, {{ platform.version }} <{{ platform.id }}|{{ platform.version }}>{% endfor %}
3737
description: On which platform should the test run?
38+
- extended-choice:
39+
name: OPERATOR_VERSION
40+
description: Version of the operator (binary) this test should use
41+
property-file: /var/jenkins_home/workspace/Available Versions/versions.properties
42+
property-key: {{ testsuite.name }}
43+
quote-value: false
44+
visible-items: 10
3845
- string:
3946
name: BEKU_SUITE
4047
description: Testsuite which is used (beku feature)
@@ -57,6 +64,7 @@
5764
export PLATFORM_ID=`echo $TEST_PLATFORM | cut -d '<' -f 2 | cut -d '|' -f 1`
5865
export K8S_VERSION=`echo $TEST_PLATFORM | cut -d '<' -f 2 | cut -d '|' -f 2 | cut -d '>' -f 1`
5966
export GIT_BRANCH=`echo $GIT_BRANCH_OR_TAG | sed s#origin/##g`
67+
export TEST_SCRIPT_PARAM_OPERATOR_NAME=`echo {{ testsuite.name }} | sed s#-operator##g`
6068

6169
# We're using Docker from within a Docker container, so we have to make sure to provide
6270
# the Docker daemon with the proper absolute path for volume mounts.
@@ -81,6 +89,7 @@
8189
--env GIT_BRANCH=$GIT_BRANCH \
8290
--env BEKU_SUITE=$BEKU_SUITE \
8391
--env OPERATOR_VERSION=NONE \
92+
--env TEST_SCRIPT_PARAMS="--operator ${TEST_SCRIPT_PARAM_OPERATOR_NAME}=${OPERATOR_VERSION}" \
8493
--env METADATA_ANNOTATION_t2.stackable.tech/jenkins-user="${BUILD_USER}" \
8594
--env METADATA_ANNOTATION_t2.stackable.tech/jenkins-user-id=${BUILD_USER_ID} \
8695
--env METADATA_ANNOTATION_t2.stackable.tech/jenkins-user-email=${BUILD_USER_EMAIL} \

tools/testing-toolbox/templates/test.sh.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ git clone https://github.com/stackabletech/{{ testsuite.git_repo }}.git
2424
export VECTOR_AGGREGATOR=vector-aggregator.t2-cluster-logging.svc.cluster.local:6000
2525

2626
{% if beku_suite %}
27-
(cd {{ testsuite.git_repo }}/ && ./scripts/run_tests.sh --test-suite {{ beku_suite }} {{ test_params }})
27+
(cd {{ testsuite.git_repo }}/ && python ./scripts/run-tests --test-suite {{ beku_suite }} {{ test_params }})
2828
{% else %}
29-
(cd {{ testsuite.git_repo }}/ && ./scripts/run_tests.sh {{ test_params }})
29+
(cd {{ testsuite.git_repo }}/ && python ./scripts/run-tests {{ test_params }})
3030
{% endif %}
3131

3232
exit_code=$?

0 commit comments

Comments
 (0)