diff --git a/contrib/containerized-pbench/pbench_demo b/contrib/containerized-pbench/pbench_demo index 015acf7a53..fb29eb5bd1 100755 --- a/contrib/containerized-pbench/pbench_demo +++ b/contrib/containerized-pbench/pbench_demo @@ -1,34 +1,52 @@ -#! /bin/bash -xe +#! /bin/bash -e # # This script provides a demonstration of the contrib/containerized-pbench/pbench -# wrapper script. +# wrapper script, using it to run the FIO workload. It is not really intended +# to be a tool unto itself -- it is intended to document the workflow which a +# user might follow using the containerized Agent. +# +# Inputs to this script are provided via environment variables: +# PBENCH_AGENT_SERVER_LOC: the Pbench Server host address, including schema +# and port (e.g., https://example.com:8443) +# PBENCH_API_KEY: the Pbench Server API Key token value, which is obtained +# from the Pbench Dashboard profile page # #+ -# Set up a few things to make life simpler. Typically, these would already be -# set in the users environment (e.g., the `pbench` command alias would be done -# by the user's login script; we wouldn't need the `shopt` command if these -# commands were being run interactively; and, we only need `PB_AGENT_IMAGE_NAME` -# here because we're not using the default image). +# Set up a couple of things to make life simpler. Typically, these would +# already be set in the users environment (e.g., the `pbench` command alias +# would be done by the user's login script, and we wouldn't need the `shopt` +# command if these commands were being run interactively). #- shopt -s expand_aliases alias pbench="$(git rev-parse --show-toplevel)"/contrib/containerized-pbench/pbench -FIOTEST=${PWD}/fiotest -export PB_AGENT_PODMAN_OPTIONS="--pull newer -v ${FIOTEST}:/fiotest:z" -export PB_AGENT_IMAGE_NAME=quay.io/pbench/pbench-agent-all-fedora-38:main - -mkdir -p "${FIOTEST}" - -# Before we run the demo, we need a Pbench API key. The key can be an -# environment variable of PBENCH_API_KEY or need to be supplied to this -# script as an argument. -api_key=${1:-${PBENCH_API_KEY}} -if [[ -z "${api_key}" ]]; then - echo "Pbench API key must be provided, either on the command line or via the PBENCH_API_KEY environment variable" +#+ +# In order to upload the results of the demo to the Pbench Server, we need a +# Pbench API key; and, to simplify things, we specify the Pbench Server on the +# pbench-results-push command line instead of modifying the Agent configuration +# file. Make sure that the environment variables for them are set. +#- +if [[ -z "${PBENCH_API_KEY}" || ! (${PBENCH_AGENT_SERVER_LOC} =~ ^https?://[a-z0-9.-]+(:[0-9]+)?$) ]]; then + echo "Environment variables PBENCH_API_KEY and PBENCH_AGENT_SERVER_LOC must be properly defined" exit 2 fi +#+ +# Echo the rest of the commands as though the user had typed them. +#- +set -x + +#+ +# The workload that we're going to run requires a directory to run in, so +# create that directory if it doesn't exist and then arrange for it to be made +# available at a particular path inside the container where the workload will +# be run. +#- +FIOTEST=${PWD}/fiotest +mkdir -p "${FIOTEST}" +export PB_AGENT_PODMAN_OPTIONS="--pull newer -v ${FIOTEST}:/fiotest:z" + #+ # Run the demo! #- @@ -38,4 +56,4 @@ pbench pbench-user-benchmark --config example-workload -- \ fio --directory=/fiotest --name fio_test_file --direct=1 --rw=randread \ --bs=16k --size=100M --numjobs=8 --time_based --runtime=5s \ --group_reporting --norandommap -pbench pbench-results-move --token=${api_key} +pbench pbench-results-move --server ${PBENCH_AGENT_SERVER_LOC} --token=${PBENCH_API_KEY}