Skip to content

Commit 809e006

Browse files
committed
Update scripts to take artillery api keys as an option.
1 parent e83dec8 commit 809e006

5 files changed

Lines changed: 53 additions & 17 deletions

File tree

.github/workflows/run_notify_load.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ on:
88
required: true
99
default: 'ref'
1010
arrivalRate:
11-
description: 'How many requests to send per second'
11+
description: 'How many requests to send per second during the main test'
1212
required: true
1313
default: '100'
1414
duration:
15-
description: 'The duration of the test'
15+
description: 'The duration of the main test'
16+
required: true
17+
default: '900'
18+
rampUpDuration:
19+
description: 'The duration of ramp-up phase of the test'
1620
required: true
1721
default: '900'
1822
maxVusers:
@@ -34,6 +38,7 @@ jobs:
3438
echo "## environment : ${{ github.event.inputs.environment }}" >> "$GITHUB_STEP_SUMMARY"
3539
echo "## arrivalRate : ${{ github.event.inputs.arrivalRate }}" >> "$GITHUB_STEP_SUMMARY"
3640
echo "## duration : ${{ github.event.inputs.duration }}" >> "$GITHUB_STEP_SUMMARY"
41+
echo "## rampUpDuration : ${{ github.event.inputs.rampUpDuration }}" >> "$GITHUB_STEP_SUMMARY"
3742
echo "## maxVusers : ${{ github.event.inputs.maxVusers }}" >> "$GITHUB_STEP_SUMMARY"
3843
3944
- name: Checkout repo

artillery/notify_load_test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ config:
44
expect: {}
55
apdex: {}
66
phases:
7+
- name: ramp up phase
8+
duration: "{{ $env.rampUpDuration }}"
9+
arrivalRate: 1
10+
rampTo: "{{ $env.arrivalRate }}"
11+
maxVusers: "{{ $env.maxVusers }}"
712
- name: run phase
813
duration: "{{ $env.duration }}"
914
arrivalRate: "{{ $env.arrivalRate }}"

scripts/run_notify_load_test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ if [ -z "${duration}" ]; then
1616
exit 1
1717
fi
1818

19+
if [ -z "${rampUpDuration}" ]; then
20+
echo "rampUpDuration is unset or set to the empty string"
21+
exit 1
22+
fi
23+
1924
if [ -z "${arrivalRate}" ]; then
2025
echo "arrivalRate is unset or set to the empty string"
2126
exit 1
@@ -39,6 +44,7 @@ cat <<EOF > runtimeenv.env
3944
maxVusers=$maxVusers
4045
duration=$duration
4146
arrivalRate=$arrivalRate
47+
rampUpDuration=$rampUpDuration
4248
EOF
4349

4450
echo ${launch_config}

scripts/test_notify_load_test.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#!/usr/bin/env bash
22

3-
4-
if [ -z "${artillery_key}" ]; then
5-
echo "artillery_key is unset or set to the empty string. Get one from here: https://app.artillery.io/"
6-
exit 1
7-
fi
8-
3+
# Required checks
94
if [ -z "${environment}" ]; then
105
echo "environment is unset or set to the empty string"
116
exit 1
@@ -21,6 +16,11 @@ if [ -z "${duration}" ]; then
2116
exit 1
2217
fi
2318

19+
if [ -z "${rampUpDuration}" ]; then
20+
echo "rampUpDuration is unset or set to the empty string"
21+
exit 1
22+
fi
23+
2424
if [ -z "${arrivalRate}" ]; then
2525
echo "arrivalRate is unset or set to the empty string"
2626
exit 1
@@ -41,12 +41,20 @@ if [ -z "${psu_kid}" ]; then
4141
exit 1
4242
fi
4343

44+
# Check artillery_key but don't fail — just omit recording if absent
45+
if [ -z "${artillery_key}" ]; then
46+
echo "Warning: artillery_key is unset; running test without recording to Artillery Cloud."
47+
RECORD_ARGS=""
48+
else
49+
RECORD_ARGS="--record --key ${artillery_key}"
50+
fi
4451

4552
# Create a dotenv file with the variables for Artillery
4653
cat <<EOF > runtimeenv.env
4754
maxVusers=${maxVusers}
4855
duration=${duration}
4956
arrivalRate=${arrivalRate}
57+
rampUpDuration=${rampUpDuration}
5058
psu_api_key="${psu_api_key}"
5159
psu_private_key="${psu_private_key}"
5260
psu_kid="${psu_kid}"
@@ -58,15 +66,17 @@ echo ""
5866
echo "Environment: ${environment}"
5967
echo "Max Virtual Users: ${maxVusers}"
6068
echo "Run Phase Duration: ${duration}"
69+
echo "Ramp-up Duration: ${rampUpDuration}"
6170
echo "Arrival Rate: ${arrivalRate}"
71+
[ -n "${artillery_key}" ] && echo "Recording to Artillery Cloud with key: ${artillery_key}"
6272
echo ""
6373

6474
set -e
6575

66-
# Run the Artillery test locally
76+
# Run the Artillery test locally, conditionally including recording flags
6777
npx artillery run \
6878
-e "${environment}" \
69-
--env-file /workspaces/eps-load-test/runtimeenv.env \
70-
--output /workspaces/eps-load-test/notify_load_test.json \
71-
--record --key ${artillery_key} \
72-
/workspaces/eps-load-test/artillery/notify_load_test.yml
79+
--env-file "$(pwd)/runtimeenv.env" \
80+
--output "$(pwd)/notify_load_test.json" \
81+
$RECORD_ARGS \
82+
"$(pwd)/artillery/notify_load_test.yml"

scripts/test_psu_load_test.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ if [ -z "${psu_kid}" ]; then
4141
exit 1
4242
fi
4343

44+
# Check for Artillery Cloud key (optional)
45+
if [ -z "${artillery_key}" ]; then
46+
echo "Warning: artillery_key is unset; running test without recording to Artillery Cloud."
47+
RECORD_ARGS=""
48+
else
49+
RECORD_ARGS="--record --key ${artillery_key}"
50+
fi
4451

4552
# Create a dotenv file with the variables for Artillery
4653
cat <<EOF > runtimeenv.env
@@ -55,20 +62,23 @@ EOF
5562

5663
echo "Running Artillery test locally..."
5764
echo ""
65+
echo "Environment: ${environment}"
5866
echo "Max Virtual Users: ${maxVusers}"
5967
echo "Phase Duration: ${duration}"
6068
echo "Arrival Rate: ${arrivalRate}"
61-
echo "Ramp Up Duration: ${rampUpDuration}"
69+
echo "Ramp-up Duration: ${rampUpDuration}"
70+
[ -n "${artillery_key}" ] && echo "Recording to Artillery Cloud with key: ${artillery_key}"
6271
echo ""
6372

6473
set -e
6574

6675
# Run the Artillery test locally
6776
npx artillery run \
6877
-e "${environment}" \
69-
--env-file /workspaces/eps-load-test/runtimeenv.env \
70-
--output /workspaces/eps-load-test/psu_load_test.json \
71-
/workspaces/eps-load-test/artillery/psu_load_test.yml
78+
--env-file "$(pwd)/runtimeenv.env" \
79+
--output "$(pwd)/psu_load_test.json" \
80+
$RECORD_ARGS \
81+
"$(pwd)/artillery/psu_load_test.yml"
7282

7383
# Generate a report from the test results
7484
npx artillery report psu_load_test.json

0 commit comments

Comments
 (0)