diff --git a/.github/actions/integration-tests/prepare-run-file b/.github/actions/integration-tests/prepare-run-file new file mode 100644 index 0000000..2c99009 --- /dev/null +++ b/.github/actions/integration-tests/prepare-run-file @@ -0,0 +1,37 @@ +#!/bin/bash + +# Helper script to prepare run-file json +# Usage: +# source ${SCRIPT_DIR}/prepare-run-file + +function replace_value() { + # Replace a value in the run-file json + # Usage: replace_value remote_host ${remote_host} \ + # '."endpoints"[0]."host" = $remote_host' + # ("host" key will be replaced with the value of $remote_host variable) + # + # --arg is declaring an argument named , + # with a value of in the jq environment + # The is what specifies the location in the JSON + # (the first part) and then the value to set it to (the second part, after the =) + + local json=$1; shift # json file to replace value + local variable=$1; shift # variable to be declared as variable=value in jq's env + local value=$1; shift # value to assign to the variable declaration in jq's env + local query=$1; shift # query to match json's key/val + + if [ -z "$(command -v jq)" ]; then + echo "ERROR running jq to edit the run-file JSON." + exit 1 + fi + + jq --arg ${variable} "${value}" "${query}" ${json} > ${json}.tmp + if [ $? != 0 ]; then + echo "ERROR editing the run-file JSON." + exit 1 + fi + + # Update original run-file json + /bin/mv ${json}.tmp ${json} +} + diff --git a/.github/actions/integration-tests/run-ci-stage1 b/.github/actions/integration-tests/run-ci-stage1 index 39335b8..108b0ef 100755 --- a/.github/actions/integration-tests/run-ci-stage1 +++ b/.github/actions/integration-tests/run-ci-stage1 @@ -396,6 +396,19 @@ for userenv in ${CI_ACTIVE_USERENVS}; do run_cmd "crucible run iperf,uperf --tags run:2${TAGS} --num-samples ${CI_SAMPLES} --test-order r --mv-params ${SCRIPT_DIR}/mv-params/iperf-2.json,${SCRIPT_DIR}/mv-params/uperf-2.json ${ENDPOINT_ARG}" post_run_cmd fi + + # multibench all-in-one json test + RUN_FILE="${SCRIPT_DIR}/run-file/ci-${scenario}-run-file-${CI_ENDPOINT}-${userenv}.json" + if [ -f "${RUN_FILE}" ]; then + source ${SCRIPT_DIR}/prepare-run-file + replace_value ${RUN_FILE} userenv ${userenv} '."endpoints"[0]."userenv" = $userenv' + replace_value ${RUN_FILE} controller_ip ${CONTROLLER_IP} '."endpoints"[0]."controller-ip" = $controller_ip' + replace_value ${RUN_FILE} host ${CI_ENDPOINT_HOST} '."endpoints"[0]."host" = $host' + replace_value ${RUN_FILE} user ${CI_ENDPOINT_USER} '."endpoints"[0]."user" = $user' + run_cmd "crucible run --from-file ${RUN_FILE}" + post_run_cmd + fi + ;; cyclictest) case "${CI_ENDPOINT}" in @@ -436,14 +449,13 @@ for userenv in ${CI_ACTIVE_USERENVS}; do # Only run all-in-one json test if the runfile exists for the endpoint # e.g.: ci-oslat-run-file-k8s-alma8.json - RUN_FILE="${SCRIPT_DIR}/run-file/ci-oslat-run-file-${CI_ENDPOINT}-${userenv}.json" + RUN_FILE="${SCRIPT_DIR}/run-file/ci-${scenario}-run-file-${CI_ENDPOINT}-${userenv}.json" if [ -f "${RUN_FILE}" ]; then - sed -i "s|CI_REPEAT_RUNS|${CI_REPEAT_RUNS}|g" ${RUN_FILE} - sed -i "s|USERENV|${userenv}|g" ${RUN_FILE} - sed -i "s|SCRIPT_DIR|${SCRIPT_DIR}|g" ${RUN_FILE} - sed -i "s|CONTROLLER_IP|${CONTROLLER_IP}|g" ${RUN_FILE} - sed -i "s|CI_ENDPOINT_HOST|${CI_ENDPOINT_HOST}|g" ${RUN_FILE} - sed -i "s|CI_ENDPOINT_USER|${CI_ENDPOINT_USER}|g" ${RUN_FILE} + source ${SCRIPT_DIR}/prepare-run-file + replace_value ${RUN_FILE} userenv ${userenv} '."endpoints"[0]."userenv" = $userenv' + replace_value ${RUN_FILE} controller_ip ${CONTROLLER_IP} '."endpoints"[0]."controller-ip" = $controller_ip' + replace_value ${RUN_FILE} host ${CI_ENDPOINT_HOST} '."endpoints"[0]."host" = $host' + replace_value ${RUN_FILE} user ${CI_ENDPOINT_USER} '."endpoints"[0]."user" = $user' run_cmd "crucible run --from-file ${RUN_FILE}" post_run_cmd fi