Skip to content

Commit

Permalink
Allow setting iqe requirements in CJI (#120)
Browse files Browse the repository at this point in the history
* Allow setting iqe requirements in CJI

Co-authored-by: Brandon Squizzato <[email protected]>
  • Loading branch information
psegedy and bsquizz authored Oct 13, 2021
1 parent ccc4813 commit 980da53
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
42 changes: 40 additions & 2 deletions bonfire/bonfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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))

Expand Down
6 changes: 6 additions & 0 deletions bonfire/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)

Expand Down
9 changes: 9 additions & 0 deletions bonfire/resources/default-iqe-cji.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ objects:
marker: ${MARKER}
filter: ${FILTER}
dynaconfEnvName: ${ENV_NAME}
requirements: ${REQUIREMENTS}
requirementsPriority: ${REQUIREMENTS_PRIORITY}
testImportance: ${TEST_IMPORTANCE}

parameters:
- name: NAME
Expand All @@ -34,3 +37,9 @@ parameters:
- name: ENV_NAME
value: "clowder_smoke"
required: true
- name: REQUIREMENTS
value: ""
- name: REQUIREMENTS_PRIORITY
value: ""
- name: TEST_IMPORTANCE
value: ""
18 changes: 17 additions & 1 deletion cicd/cji_smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand All @@ -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 &
Expand Down

0 comments on commit 980da53

Please sign in to comment.