Skip to content

Commit

Permalink
Merge branch 'main' into no-downtime-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arlowatts committed Aug 30, 2024
2 parents cc6e500 + 1673ac5 commit f62c285
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 16 deletions.
1 change: 1 addition & 0 deletions test/k6/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ services:
- "ERX_VUS=${ERX_VUS}"
- "ERX_ITERATIONS=${ERX_ITERATIONS}"
- "ERX_ITERATION_LENGTH=${ERX_ITERATION_LENGTH}"
- "ERX_MAX_DURATION=${ERX_MAX_DURATION}"
3 changes: 2 additions & 1 deletion test/k6/options/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/medication.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/medicationdispense.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/medicationrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/medicationstatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
3 changes: 2 additions & 1 deletion test/k6/options/practitioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// see https://k6.io/docs/using-k6/k6-options/ for more information
export const options = {
vus: __ENV.ERX_VUS ? __ENV.ERX_VUS : 1,
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1
iterations: __ENV.ERX_ITERATIONS ? __ENV.ERX_ITERATIONS : 1,
duration: __ENV.ERX_MAX_DURATION ? __ENV.ERX_MAX_DURATION : "10m",
};

// the mean time delay in seconds between each transaction
Expand Down
22 changes: 15 additions & 7 deletions test/k6/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
# Runs a smoke test (or load test) on all PPM API services and logs the results in output/$ENVIRONMENT
#
# Usage:
# run-all.sh ENVIRONMENT CLIENT_ID CLIENT_SECRET [VUS] [ITERATIONS] [ITERATION_LENGTH]
# run-all.sh ENVIRONMENT CLIENT_ID CLIENT_SECRET [VUS] [ITERATIONS] [ITERATION_LENGTH] [MAX_DURATION]
#
# Substitute ENVIRONMENT for the three-letter name of the PPM API environment to be tested. The environments are dev, tr1, vs1, vc1, vc2, and prd.
# Substitute CLIENT_ID for the Keycloak client ID associated with the given environment.
# Substitute CLIENT_SECRET for the client secret associated with the given client ID. Set to "stdin" to read the secret from standard input rather than command line arguments.
# Substitute VUS for the maximum number of concurrent virtual users. Defaults to 1 if not set. See the confluence documentation for more information about virtual users.
# Substitute ITERATIONS for the number of iterations to run on each service. Defaults to 1 if not set.
# Substitute ITERATION_LENGTH for the number of transactions sent in each iteration. Set to -1 to run all available test transactions on every service. Defaults to 1 if not set.
# Substitute MAX_DURATION for the maximum duration of the test. Defaults to "10m" (10 minutes) if not set.
#
# Author: Arlo Watts
# Date: 2024-08-14
Expand All @@ -21,17 +22,19 @@ secret=$3
vus=$4
iterations=$5
iterationLength=$6
maxDuration=$7

if [ "$secret" = "" ]; then
echo "Usage:"
echo " run-all.sh ENVIRONMENT CLIENT_ID CLIENT_SECRET [VUS] [ITERATIONS] [ITERATION_LENGTH]"
echo " run-all.sh ENVIRONMENT CLIENT_ID CLIENT_SECRET [VUS] [ITERATIONS] [ITERATION_LENGTH] [MAX_DURATION]"
echo
echo "Substitute ENVIRONMENT for the three-letter name of the PPM API environment to be tested. The environments are dev, tr1, vs1, vc1, vc2, and prd."
echo "Substitute CLIENT_ID for the Keycloak client ID associated with the given environment."
echo "Substitute CLIENT_SECRET for the client secret associated with the given client ID. Set to "stdin" to read the secret from standard input rather than command line arguments."
echo "Substitute CLIENT_SECRET for the client secret associated with the given client ID. Set to \"stdin\" to read the secret from standard input rather than command line arguments."
echo "Substitute VUS for the maximum number of concurrent virtual users. Defaults to 1 if not set. See the confluence documentation for more information about virtual users."
echo "Substitute ITERATIONS for the number of iterations to run on each service. Defaults to 1 if not set."
echo "Substitute ITERATION_LENGTH for the number of transactions sent in each iteration. Set to -1 to run all available test transactions on every service. Defaults to 1 if not set."
echo "Substitute MAX_DURATION for the maximum duration of the test. Defaults to \"10m\" (10 minutes) if not set."
exit 1

elif [ "$secret" = "stdin" ]; then
Expand All @@ -50,8 +53,11 @@ BASEDIR=$(dirname $0)
mkdir --parents ${BASEDIR}/output/${env}
rm --force ${BASEDIR}/output/${env}/*

# Create an empty file for the full test summary
touch ${BASEDIR}/output/${env}/summary.txt

# Set environment variables for docker compose stacks
export ERX_ENV=${env} ERX_CLIENT=${client} ERX_CLIENT_SECRET=${secret} ERX_VUS=${vus} ERX_ITERATIONS=${iterations} ERX_ITERATION_LENGTH=${iterationLength}
export ERX_ENV=${env} ERX_CLIENT=${client} ERX_CLIENT_SECRET=${secret} ERX_VUS=${vus} ERX_ITERATIONS=${iterations} ERX_ITERATION_LENGTH=${iterationLength} ERX_MAX_DURATION=${maxDuration}

for service in "${services[@]}"; do
# Compose up the test container in the background - this will run all nine containers concurrently
Expand All @@ -67,7 +73,9 @@ for service in "${services[@]}"; do

# Delete the compose stack after the logs are finished
docker compose --project-name ${service} rm --force
done

# Grab the summaries from each log file and dump them in a new file
tail --lines 24 ${BASEDIR}/output/${env}/* > ${BASEDIR}/output/${env}/summary.txt
# Append the container test summary to the overall test summary
echo "==> ${BASEDIR}/output/${env}/${service}.txt <==" >> ${BASEDIR}/output/${env}/summary.txt
sed --silent '/^.\{44\}:/p' ${BASEDIR}/output/${env}/${service}.txt >> ${BASEDIR}/output/${env}/summary.txt
echo >> ${BASEDIR}/output/${env}/summary.txt
done

0 comments on commit f62c285

Please sign in to comment.