Skip to content

Commit

Permalink
added option to specify external endpoint for testing and logic to su…
Browse files Browse the repository at this point in the history
…pport that with the scheduled nature of the job
  • Loading branch information
gzukel committed Jul 3, 2024
1 parent 53826f9 commit 350996e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/actions/performance-tests/art.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
target: "http://localhost:9545"
target: "-=http_request_protocol=-://-=endpoint_to_test=-"
phases:
- duration: 300
arrivalRate: 425
Expand Down
58 changes: 54 additions & 4 deletions .github/workflows/ci-nightly-performance-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ name: "NIGHTLY:EVM:PERFORMANCE:TESTING"

on:
workflow_dispatch:
inputs:
endpoint:
description: 'The EVM endpoint you want to test.'
required: false
default: 'http://localhost:9545'
schedule:
- cron: '0 0 * * *' # Runs every day at midnight UTC

jobs:
nightly_evm_api_performance_test:
name: "NIGHTLY:EVM:API:PERFORMANCE:TEST"
runs-on: "buildjet-16vcpu-ubuntu-2204"
env:
endpoint_to_test: "http://localhost:9545"
steps:
- uses: actions/checkout@v4

Expand All @@ -25,22 +32,65 @@ jobs:
run: |
npm install -g artillery@latest
- name: "CONFIGURE:PERFORMANCE:TEMPLATE"
run: |
# Check if the inputs.endpoint starts with https:// or http://
if [[ "${{inputs.endpoint}}" =~ ^https:// ]]; then
# Set the http_request_protocol to https if the URL starts with https://
export http_request_protocol=https
elif [[ "${{inputs.endpoint}}" =~ ^http:// ]]; then
# Set the http_request_protocol to http if the URL starts with http://
export http_request_protocol=http
else
# If the URL doesn't start with either http:// or https://, print an error and exit
echo "Please input a url with either https:// or http://" && exit 1
fi
# Check if inputs.endpoint is different from the default "http://localhost:9545"
if [ "${{inputs.endpoint}}" != "http://localhost:9545" ]; then
# Check if inputs.endpoint is not empty
if [ -n "${{inputs.endpoint}}" ]; then
# If inputs.endpoint isn't different from the default and is not empty, use inputs.endpoint
export endpoint_to_test=${{inputs.endpoint}}
# Remove the protocol (http:// or https://) from endpoint_to_test
endpoint_to_test=${endpoint_to_test#http://}
endpoint_to_test=${endpoint_to_test#https://}
else
# If inputs.endpoint is empty, strip the protocol from endpoint_to_test
endpoint_to_test=${endpoint_to_test#http://}
endpoint_to_test=${endpoint_to_test#https://}
fi
else
# If inputs.endpoint is "http://localhost:9545", strip the protocol from endpoint_to_test
endpoint_to_test=${endpoint_to_test#http://}
endpoint_to_test=${endpoint_to_test#https://}
fi
# Replace -=endpoint_to_test=- placeholder in the art.yaml file with the endpoint_to_test value
sed -i "s/-=endpoint_to_test=-/${endpoint_to_test}/g" .github/actions/performance-tests/art.yaml
# Replace -=http_request_protocol=- placeholder in the art.yaml file with the http_request_protocol value
sed -i "s/-=http_request_protocol=-/${http_request_protocol}/g" .github/actions/performance-tests/art.yaml
- name: "EXECUTE:PERFORMANCE:TESTS"
run: |
# Execute Artillery to run performance tests using the specified configuration file
artillery run .github/actions/performance-tests/art.yaml \
# Enable recording of test results to Artillery's reporting service
--record \
# Use the secret ARTILLERY_KEY for authentication with the reporting service
--key ${{ secrets.ARTILLERY_KEY }} \
# Output the test results to a JSON file named report.json
--output ./report.json
- name: "CHECK:RESULTS"
run: |
- name: "CHECK:TEST:RESULTS"
run: |
# Check Artillery exit status
if [ $? -ne 0 ]; then
echo "Artillery command failed to execute."
exit 1
fi
# Parse the results.json file to check for failed vusers and http response codes
# Parse the results.json file to check for failed vusers and HTTP response codes
failed_vusers=$(jq '.aggregate.counters["vusers.failed"] // 0' ./report.json)
http_codes_200=$(jq '.aggregate.counters["http.codes.200"] // 0' ./report.json)
http_responses=$(jq '.aggregate.counters["http.responses"] // 0' ./report.json)
Expand All @@ -51,7 +101,7 @@ jobs:
else
echo "EVM Performance Testing Successful"
fi
# Read the JSON file and extract the required metrics
p99_values=$(jq -r '.aggregate.summaries["http.response_time"].p99, .aggregate.summaries["plugins.metrics-by-endpoint.response_time./"].p99, .aggregate.summaries["vusers.session_length"].p99' ./report.json)
p50_values=$(jq -r '.aggregate.summaries["http.response_time"].p50, .aggregate.summaries["plugins.metrics-by-endpoint.response_time./"].p50, .aggregate.summaries["vusers.session_length"].p50' ./report.json)
Expand Down

0 comments on commit 350996e

Please sign in to comment.