Skip to content

Commit da1014a

Browse files
committed
Collect test results
* Store them in an S3 bucket * Collect and attach them to the GitHub workflow
1 parent 8eac575 commit da1014a

File tree

3 files changed

+100
-15
lines changed

3 files changed

+100
-15
lines changed

.github/workflows/performance.yaml

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,14 @@ jobs:
117117
runs-on: ubuntu-latest
118118
permissions:
119119
id-token: write
120+
contents: write
120121
timeout-minutes: 180
122+
env:
123+
RESULT_PATH: ${{ inputs.testToRun }}/${{ inputs.URN }}/${{ github.run_number }}
121124
steps:
122125
- uses: actions/checkout@v5
126+
- name: Set timestamp
127+
run: echo "timestamp=$(date '+%Y%m%d%H%M%S')" >> $GITHUB_ENV
123128
- name: Configure AWS credentials
124129
uses: aws-actions/configure-aws-credentials@v5
125130
with:
@@ -134,6 +139,7 @@ jobs:
134139
image: "393416225559.dkr.ecr.eu-west-2.amazonaws.com/performancetest:${{ github.sha }}"
135140
environment-variables: |
136141
TEST_TO_RUN=${{ inputs.testToRun }}
142+
RESULT_PATH=${{ env.RESULT_PATH }}
137143
URN=${{ inputs.URN }}
138144
DURATION=${{ inputs.duration }}
139145
THREADS=${{ inputs.threads }}
@@ -154,16 +160,15 @@ jobs:
154160
--output text
155161
)
156162
echo "task_definition_arn=$task_definition_arn" >> $GITHUB_OUTPUT
157-
- name: Run ECS Task
163+
- name: Start performance test
158164
id: run-task
159165
run: |
160166
echo "Starting ECS task for ${{ inputs.testToRun }} test against URN: ${{ inputs.URN }}"
161167
162-
# Prepare network configuration
163168
subnet_id=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=performancetest-subnet --query 'Subnets[0].SubnetId' --output text)
164169
security_group_id=$(aws ec2 describe-security-groups --filters Name=group-name,Values=performancetest-sg --query 'SecurityGroups[0].GroupId' --output text)
165170
166-
aws ecs run-task \
171+
task_arn=$(aws ecs run-task \
167172
--cluster performancetest \
168173
--task-definition ${{ steps.register-task-definition.outputs.task_definition_arn }} \
169174
--launch-type FARGATE \
@@ -172,5 +177,64 @@ jobs:
172177
"containerOverrides": [{
173178
"name": "performancetest-container"
174179
}]
175-
}'
176-
180+
}' \
181+
--query 'tasks[0].taskArn' \
182+
--output text)
183+
184+
echo "task_arn=$task_arn" >> $GITHUB_OUTPUT
185+
echo "Started task: $task_arn"
186+
- name: Wait for performance test to complete
187+
run: |
188+
echo "Waiting for task to complete: ${{ steps.run-task.outputs.task_arn }}"
189+
aws ecs wait tasks-stopped \
190+
--cluster performancetest \
191+
--tasks ${{ steps.run-task.outputs.task_arn }}
192+
193+
task_status=$(aws ecs describe-tasks \
194+
--cluster performancetest \
195+
--tasks ${{ steps.run-task.outputs.task_arn }} \
196+
--query 'tasks[0].lastStatus' \
197+
--output text)
198+
199+
exit_code=$(aws ecs describe-tasks \
200+
--cluster performancetest \
201+
--tasks ${{ steps.run-task.outputs.task_arn }} \
202+
--query 'tasks[0].containers[0].exitCode' \
203+
--output text)
204+
205+
echo "Task final status: $task_status"
206+
echo "Container exit code: $exit_code"
207+
208+
if [ "$exit_code" != "0" ]; then
209+
echo "ECS task failed with exit code: $exit_code"
210+
exit 1
211+
fi
212+
- name: Collect test result
213+
id: collect-results
214+
run: |
215+
echo "Downloading test results from S3"
216+
S3_PATH="s3://performancetest-reports/${{ env.RESULT_PATH }}"
217+
aws s3 sync "${S3_PATH}" ./test-results --no-progress
218+
219+
if [ "${{ inputs.testToRun }}" == "consent-journey" ]; then
220+
echo "REPORT_DIR=test-results/consent/report" >> $GITHUB_OUTPUT
221+
elif [ "${{ inputs.testToRun }}" == "nurse-journey" ]; then
222+
echo "REPORT_DIR=test-results/nurse/report" >> $GITHUB_OUTPUT
223+
fi
224+
- name: Publish report to GH Pages
225+
uses: peaceiris/actions-gh-pages@v4
226+
with:
227+
github_token: ${{ secrets.GITHUB_TOKEN }}
228+
publish_branch: gh-pages
229+
publish_dir: ${{ steps.collect-results.outputs.REPORT_DIR }}
230+
destination_dir: JMeter/${{ env.RESULT_PATH }}
231+
keep_files: true
232+
- name: Set Job Summary
233+
run: |
234+
echo "## Performance Test Results" >> $GITHUB_STEP_SUMMARY
235+
echo "" >> $GITHUB_STEP_SUMMARY
236+
echo "- **Test Type:** ${{ inputs.testToRun }}" >> $GITHUB_STEP_SUMMARY
237+
echo "- **URN:** ${{ inputs.URN }}" >> $GITHUB_STEP_SUMMARY
238+
echo "- **Run Number:** ${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
239+
echo "" >> $GITHUB_STEP_SUMMARY
240+
echo "📊 View Test Report: https://nhsdigital.github.io/manage-vaccinations-in-schools-testing/JMeter/${{ env.RESULT_PATH }}/" >> $GITHUB_STEP_SUMMARY

performance-tests/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ ENV JMETER_VERSION=5.6.3 \
77
JMETER_HOME=/opt/jmeter \
88
PATH="/opt/jmeter/bin:${PATH}"
99

10-
RUN apt-get update && apt-get install -y curl tar parallel && rm -rf /var/lib/apt/lists/*
10+
RUN apt-get update && apt-get install -y curl tar parallel unzip && rm -rf /var/lib/apt/lists/*
11+
12+
# Install AWS CLI v2 for S3 uploads
13+
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
14+
&& unzip awscliv2.zip \
15+
&& ./aws/install \
16+
&& rm -rf awscliv2.zip aws
1117

1218
WORKDIR /opt
1319

performance-tests/entrypoint.sh

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
set -e
33

44
# Default values
5-
TEST_TO_RUN=${TEST_TO_RUN:-"consent-journey"}
6-
URN=${URN:-""}
75
DURATION=${DURATION:-3600}
86
THREADS=${THREADS:-70}
97
RAMP_UP=${RAMP_UP:-900}
108
VACCINATION_LOOP=${VACCINATION_LOOP:-20}
119
ROW_COUNT=${ROW_COUNT:-1000}
12-
AUTH_TOKEN=${AUTH_TOKEN:-""}
1310

1411
# Validate required parameters
1512
if [ -z "$URN" ]; then
@@ -22,8 +19,10 @@ if [ -z "$AUTH_TOKEN" ]; then
2219
exit 1
2320
fi
2421

25-
# Set timestamp for output files
26-
TIMESTAMP=$(date '+%Y%m%d%H%M%S')
22+
if [ -z "$RESULT_PATH" ]; then
23+
echo "Error: RESULT_PATH is required"
24+
exit 1
25+
fi
2726

2827
echo "==================================="
2928
echo "Starting Performance Test"
@@ -35,7 +34,7 @@ echo "Threads: $THREADS"
3534
echo "Ramp Up: $RAMP_UP seconds"
3635
echo "Vaccination Loop: $VACCINATION_LOOP"
3736
echo "Row Count: $ROW_COUNT"
38-
echo "Timestamp: $TIMESTAMP"
37+
echo "Result Path: $RESULT_PATH"
3938
echo "==================================="
4039

4140
# Create output directories
@@ -130,9 +129,25 @@ if [ $TEST_EXIT_CODE -ne 0 ]; then
130129
exit 1
131130
fi
132131

132+
# Upload results to S3
133+
echo "==================================="
134+
echo "Uploading results to S3"
135+
echo "==================================="
136+
137+
S3_BUCKET="performancetest-reports"
138+
139+
S3_PATH="s3://${S3_BUCKET}/${RESULT_PATH}"
140+
141+
echo "Uploading to: ${S3_PATH}"
142+
143+
if aws s3 sync /output "${S3_PATH}" --no-progress; then
144+
echo "Successfully uploaded results to S3"
145+
echo "S3 Location: ${S3_PATH}"
146+
else
147+
echo "ERROR: Failed to upload results to S3"
148+
exit 1
149+
fi
150+
133151
echo "==================================="
134152
echo "Performance test completed successfully"
135153
echo "==================================="
136-
echo "Results are available in /output"
137-
ls -la /output/
138-
exit 0

0 commit comments

Comments
 (0)