From 75a0a5a3dbfeda678ec396427b82cab3c5d481b5 Mon Sep 17 00:00:00 2001 From: Ximon Eighteen <3304436+ximon18@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:45:18 +0200 Subject: [PATCH] Add a +benchmark mode to act-wrapper. Simplifies making a resource usage graph while loading and signing a specified zone using a specified policy. --- act-wrapper | 62 ++++++++++++++---- integration-tests/benchmark-test.yml | 95 ++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 integration-tests/benchmark-test.yml diff --git a/act-wrapper b/act-wrapper index 78a487f3..578e29bd 100755 --- a/act-wrapper +++ b/act-wrapper @@ -2,6 +2,9 @@ set -e +WORKFLOW_PATH="integration-tests/system-tests.yml" +ACT_EXTRA_ARGS= + function usage { echo "The act wrapper script." echo @@ -9,25 +12,34 @@ function usage { echo "with a freshly compiled Cascade, before executing act with" echo "the provided arguments." echo - echo "If you want to skip the build step and run act with the latest" - echo "available version of the cascade test runner image you can use:" + echo "- If you want to skip the build step and run act with the latest" + echo " available version of the cascade test runner image you can use:" + echo + echo " '$0 +nobuild '" + echo + echo "- If you want to build cascade within the container build, use:" + echo + echo " '$0 +build-inside '" + echo + echo "- If you want to run a benchmark test use:" echo - echo "'$0 +nobuild '" + echo " '$0 +benchmark '" echo - echo "If you want to build cascade within the container build, use:" + echo " This will enable the +stats-graph option and invoke the" + echo " integration-tests/benchmark-test.yml workflow using the supplied inputs" + echo " with info level logging and a release mode build of Cascade." echo - echo "'$0 +build-inside '" + echo "- If you want to produce a report of approximate CPU and memory usage" + echo " over time use:" echo - echo "If you want to produce a report of approximate CPU and memory usage" - echo "over time use:" + echo " '$0 +stats-report '" echo - echo "'$0 +stats-report '" + echo "- To create a PNG graph of the usage use: (requires gnuplot)" echo - echo "To create a PNG graph of the usage use: (requires gnuplot)" - echo "Note: If +stats-report is not used, a temporary file will be used" - echo "to capture resource usage in CSV format." + echo " '$0 +stats-graph '" echo - echo "'$0 +stats-graph '" + echo " If +stats-report is not used, a temporary file will be used" + echo " to capture resource usage in CSV format." echo echo "NOTE: '+XXX' arguments must be the first arguments to act-wrapper, and can be combined." echo @@ -84,6 +96,28 @@ while [[ "$1" =~ ^\+ ]]; do shift docker_stats_graph_path="$1" ;; + +benchmark) + if [ $# -ne 5 ]; then + echo >&2 "ERROR: Incorrect number of arguments for +benchmark." + echo >&2 + usage + exit 1 + fi + shift; ZONE_NAME="$1" + shift; ZONE_PATH="$1" + shift; POLICY_PATH="$1" + shift; TIMEOUT_SECS="$1" + POLICY_NAME=$(basename -- "${POLICY_PATH}") + POLICY_NAME="${POLICY_NAME%.*}" + NOW=$(date +"%Y%m%d_%H%M%S") + WORKFLOW_PATH="integration-tests/benchmark-test.yml" + ACT_EXTRA_ARGS="--rm --input log-level=info --input zone-name=${ZONE_NAME} --input policy-name=${POLICY_NAME} --input timeout-seconds=${TIMEOUT_SECS}" + docker_stats_graph=true + docker_stats_graph_path="benchmark-${NOW}.png" + mkdir "integration-tests/benchmark" + cp "${ZONE_PATH}" "integration-tests/benchmark/${ZONE_NAME}" + cp "${POLICY_PATH}" "integration-tests/benchmark/" + ;; *) echo >&2 "ERROR: Unrecognized + argument: $1" usage @@ -160,7 +194,7 @@ if [[ "$docker_stats" == true ]]; then fi echo "Running tests" -act "${act_args[@]}" --log-prefix-job-id --pull=false -P "ubuntu-latest=nlnetlabs/cascade-tests-runner" -W integration-tests/system-tests.yml "$@" && ACT_EXIT_CODE=$? || ACT_EXIT_CODE=$? +act "${act_args[@]}" --log-prefix-job-id --pull=false -P "ubuntu-latest=nlnetlabs/cascade-tests-runner" -W "${WORKFLOW_PATH}" ${ACT_EXTRA_ARGS} "$@" && ACT_EXIT_CODE=$? || ACT_EXIT_CODE=$? # Stop the docker stats collection process, if needed. if [[ "$docker_stats" == true ]]; then @@ -191,7 +225,7 @@ if [[ "${docker_stats_graph}" == true && "${STATS_OKAY}" == true && "${ACT_EXIT_ # Generate the gnuplot control script. GNUPLOT_SCRIPT=$(cat < (start + timeout))); then + cascade zone list + echo "timeout: zone list output did not include the zone" >&2 + exit 1 + fi + sleep 1 + done + + - name: Check zone status + run: | + timeout=${{ inputs.timeout-seconds }} + start=$(date +%s) + until cascade zone status ${{ inputs.zone-name }} | grep -q "Published zone available"; do + if (($(date +%s) > (start + timeout))); then + cascade zone status ${{ inputs.zone-name }} + echo "timeout: zone status did not report published zone available" >&2 + exit 1 + fi + sleep 1 + NOW="$(date)" + echo -n "${NOW}: " + cascade zone status ${{ inputs.zone-name }} 2>&1 | tail -n 1 + tail -n 1 ${{ github.workspace }}/cascade-dir/cascade.log + done + + - name: Print log files on any failure in this job + uses: ./.github/actions/print-logfiles + if: failure()