From 980da5312fcec94664c284a4ea08a8d98f308ba0 Mon Sep 17 00:00:00 2001 From: Patrik Segedy Date: Wed, 13 Oct 2021 20:33:59 +0200 Subject: [PATCH] Allow setting iqe requirements in CJI (#120) * Allow setting iqe requirements in CJI Co-authored-by: Brandon Squizzato --- bonfire/bonfire.py | 42 ++++++++++++++++++++++++-- bonfire/processor.py | 6 ++++ bonfire/resources/default-iqe-cji.yaml | 9 ++++++ cicd/cji_smoke_test.sh | 18 ++++++++++- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/bonfire/bonfire.py b/bonfire/bonfire.py index 90cc8816..f85c9cd6 100755 --- a/bonfire/bonfire.py +++ b/bonfire/bonfire.py @@ -500,6 +500,24 @@ def _validate_reservation_duration(ctx, param, value): type=str, default=None, ), + click.option( + "--requirements", + help="iqe --requirements expression", + type=str, + default="", + ), + click.option( + "--requirements-priority", + help="iqe --requirements-priority expression", + type=str, + default="", + ), + click.option( + "--test-importance", + help="iqe --test-importance expression", + type=str, + default="", + ), ] _reservation_process_options = [ @@ -997,11 +1015,31 @@ def _err_handler(err): @main.command("process-iqe-cji") @options(_iqe_cji_process_options) def _cmd_process_iqe_cji( - clowd_app_name, debug, marker, filter, env, image_tag, cji_name, template_file + clowd_app_name, + debug, + marker, + filter, + env, + image_tag, + cji_name, + template_file, + requirements, + requirements_priority, + test_importance, ): """Process IQE ClowdJobInvocation template and print output""" cji_config = process_iqe_cji( - clowd_app_name, debug, marker, filter, env, image_tag, cji_name, template_file + clowd_app_name, + debug, + marker, + filter, + env, + image_tag, + cji_name, + template_file, + requirements, + requirements_priority, + test_importance, ) print(json.dumps(cji_config, indent=2)) diff --git a/bonfire/processor.py b/bonfire/processor.py index 9db547ab..d55b9ba9 100644 --- a/bonfire/processor.py +++ b/bonfire/processor.py @@ -90,6 +90,9 @@ def process_iqe_cji( image_tag="", cji_name=None, template_path=None, + requirements="", + requirements_priority="", + test_importance="", ): log.info("processing IQE ClowdJobInvocation") @@ -109,6 +112,9 @@ def process_iqe_cji( params["IMAGE_TAG"] = image_tag params["NAME"] = cji_name or f"iqe-{str(uuid.uuid4()).split('-')[0]}" params["APP_NAME"] = clowd_app_name + params["REQUIREMENTS"] = requirements + params["REQUIREMENTS_PRIORITY"] = requirements_priority + params["TEST_IMPORTANCE"] = test_importance processed_template = process_template(template_data, params=params) diff --git a/bonfire/resources/default-iqe-cji.yaml b/bonfire/resources/default-iqe-cji.yaml index 3e50210e..3ab2a524 100644 --- a/bonfire/resources/default-iqe-cji.yaml +++ b/bonfire/resources/default-iqe-cji.yaml @@ -17,6 +17,9 @@ objects: marker: ${MARKER} filter: ${FILTER} dynaconfEnvName: ${ENV_NAME} + requirements: ${REQUIREMENTS} + requirementsPriority: ${REQUIREMENTS_PRIORITY} + testImportance: ${TEST_IMPORTANCE} parameters: - name: NAME @@ -34,3 +37,9 @@ parameters: - name: ENV_NAME value: "clowder_smoke" required: true +- name: REQUIREMENTS + value: "" +- name: REQUIREMENTS_PRIORITY + value: "" +- name: TEST_IMPORTANCE + value: "" diff --git a/cicd/cji_smoke_test.sh b/cicd/cji_smoke_test.sh index 6ca47f7e..38e2e621 100644 --- a/cicd/cji_smoke_test.sh +++ b/cicd/cji_smoke_test.sh @@ -5,6 +5,9 @@ #IQE_CJI_TIMEOUT="10m" -- timeout value to pass to 'oc wait', should be slightly higher than expected test run time #IQE_MARKER_EXPRESSION="something AND something_else" -- pytest marker, can be "" if no filter desired #IQE_FILTER_EXPRESSION="something AND something_else" -- pytest filter, can be "" if no filter desired +#IQE_REQUIREMENTS="{'something','something_else'}" -- iqe requirements filter, can be "" if no filter desired +#IQE_REQUIREMENTS_PRIORITY="{'something','something_else'}" -- iqe requirements filter, can be "" if no filter desired +#IQE_TEST_IMPORTANCE="{'something','something_else'}" -- iqe requirements filter, can be "" if no filter desired #NAMESPACE="mynamespace" -- namespace to deploy iqe pod into, usually set by 'deploy_ephemeral_env.sh' # In order for the deploy-iqe-cji to run correctly, we must set the marker and filter to "" if they @@ -13,6 +16,9 @@ : "${IQE_MARKER_EXPRESSION:='""'}" : "${IQE_FILTER_EXPRESSION:='""'}" : "${IQE_IMAGE_TAG:='""'}" +: "${IQE_REQUIREMENTS:='""'}" +: "${IQE_REQUIREMENTS_PRIORITY:='""'}" +: "${IQE_TEST_IMPORTANCE:='""'}" CJI_NAME="$COMPONENT_NAME-smoke-tests" @@ -22,7 +28,17 @@ if [[ -z $IQE_CJI_TIMEOUT ]]; then fi # Invoke the CJI using the options set via env vars -pod=$(bonfire deploy-iqe-cji $COMPONENT_NAME -m "$IQE_MARKER_EXPRESSION" -k "$IQE_FILTER_EXPRESSION" -e "clowder_smoke" --cji-name $CJI_NAME -n $NAMESPACE --image-tag "${IQE_IMAGE_TAG}") +pod=$( + bonfire deploy-iqe-cji $COMPONENT_NAME \ + --marker "$IQE_MARKER_EXPRESSION" \ + --filter "$IQE_FILTER_EXPRESSION" \ + --image-tag "${IQE_IMAGE_TAG}" \ + --requirements "$IQE_REQUIREMENTS" \ + --requirements-priority "$IQE_REQUIREMENTS_PRIORITY" \ + --test-importance "$IQE_TEST_IMPORTANCE" \ + --env "clowder_smoke" \ + --cji-name $CJI_NAME \ + --namespace $NAMESPACE) # Pipe logs to background to keep them rolling in jenkins oc logs -n $NAMESPACE $pod -f &