From b4929d827c61b7029cdf6f5786635784fcacf213 Mon Sep 17 00:00:00 2001 From: Rafael Folco Date: Mon, 2 Oct 2023 15:07:26 -0300 Subject: [PATCH] Add multi bench hook for the run-file json Add the multibench hook for 'multi' scenario and update both the single and multi bench cases to use the jq replacements with a reusable function to process a json file. --- .github/actions/common-code/common-code.sh | 12 +++++++ .../actions/integration-tests/run-ci-stage1 | 32 +++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/actions/common-code/common-code.sh b/.github/actions/common-code/common-code.sh index e8885fd..2a1665d 100644 --- a/.github/actions/common-code/common-code.sh +++ b/.github/actions/common-code/common-code.sh @@ -1,6 +1,18 @@ # -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4 -*- # vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash +function process_json() { + local json=$1; shift + + jq "$@" "${json}" > "${json}.tmp" + if [ $? == 0 ]; then + /bin/mv "${json}.tmp" "${json}" + return 0 + else + return 1 + fi +} + function start_github_group { local header header="$@" diff --git a/.github/actions/integration-tests/run-ci-stage1 b/.github/actions/integration-tests/run-ci-stage1 index 39335b8..5420f5b 100755 --- a/.github/actions/integration-tests/run-ci-stage1 +++ b/.github/actions/integration-tests/run-ci-stage1 @@ -396,6 +396,22 @@ 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 + count=$(process_json ${RUN_FILE} '.endpoints | length') + idx=0 + while [ $idx -lt $count ]; do + process_json ${RUN_FILE} --argjson idx $idx --arg param "host" --arg host "${CI_ENDPOINT_HOST}" '."endpoints"[$idx] += { ($param): $host }' + process_json ${RUN_FILE} --argjson idx $idx --arg param "user" --arg user "${CI_ENDPOINT_USER}" '."endpoints"[$idx] += { ($param): $user }' + process_json ${RUN_FILE} --argjson idx $idx --arg param "userenv" --arg userenv "${userenv}" '."endpoints"[$idx] += { ($param): $userenv }' + let idx++ + done + run_cmd "crucible run --from-file ${RUN_FILE}" + post_run_cmd + fi + ;; cyclictest) case "${CI_ENDPOINT}" in @@ -436,14 +452,16 @@ 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} + count=$(process_json ${RUN_FILE} '.endpoints | length') + idx=0 + while [ $idx -lt $count ]; do + process_json ${RUN_FILE} --argjson idx $idx --arg param "host" --arg host "${CI_ENDPOINT_HOST}" '."endpoints"[$idx] += { ($param): $host }' + process_json ${RUN_FILE} --argjson idx $idx --arg param "user" --arg user "${CI_ENDPOINT_USER}" '."endpoints"[$idx] += { ($param): $user }' + process_json ${RUN_FILE} --argjson idx $idx --arg param "userenv" --arg userenv "${userenv}" '."endpoints"[$idx] += { ($param): $userenv }' + let idx++ + done run_cmd "crucible run --from-file ${RUN_FILE}" post_run_cmd fi