Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update load test workflows #349

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions .github/workflows/process-load-test-result.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Process load test results

on:
repository_dispatch:
types: [mysql-load-test]
Expand All @@ -11,32 +10,46 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Process results
if: ${{ github.event.client_payload.status == 'success' }}
id: processResults
run: |
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
branch_name="load-test-results"
test_scenario="${{ github.event.client_payload.name }}"
git pull
git checkout $branch_name || git checkout -b $branch_name
echo ${{ github.event.client_payload.result }} >> load-tests/$test_scenario/results/summary.csv
git add load-tests/$test_scenario/results/summary.csv
git commit -m "Update $test_scenario test results on $(date)"
git checkout -b $branch_name
echo '${{ toJson(github.event.client_payload.results) }}' | jq -c '.[]' |
while read -r result; do
status=$(echo "$result" | jq -r '.status')
test_scenario=$(echo "$result" | jq -r '.name')
if [[ $status == "success" ]]
then
echo $(echo "$result" | jq -r '.result') >> load-tests/$test_scenario/results/summary.csv
git add load-tests/$test_scenario/results/summary.csv
git commit -m "Update $test_scenario test results on $(date)"
printf "::set-output name=hasPassed::true"
else
echo $test_scenario "test has failed with error rate" $(echo "$result" | jq -r '.errorRate')
printf "::set-output name=hasFailed::true"
fi
done
git push origin "${branch_name}"
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
- name: Create pull request for new summary
if: ${{ github.event.client_payload.status == 'success' }}
run: gh pr create --title "[Automated] Update summary csv files" --body "Update summary csv files"
id: createPR
if: ${{ steps.processResults.outputs.hasPassed }}
run: printf "::set-output name=prUrl::$(gh pr create --title "[Automated] Update summary csv files" --body "Update summary csv files")"
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
- name: Approve PR
if: ${{ github.event.client_payload.status == 'success' }}
run: gh pr review --approve
if: ${{ steps.processResults.outputs.hasPassed }}
run: |
sleep 5
gh pr review --approve ${{ steps.createPR.outputs.prUrl }}
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_REVIEWER_BOT_TOKEN }}
- name: Merge PR
if: ${{ github.event.client_payload.status == 'success' }}
if: ${{ steps.processResults.outputs.hasPassed }}
run: |
status="NOT COMPLETED"
while [ ! -z "$status" ]
Expand All @@ -49,8 +62,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
- name: Fail workflow
if: ${{ github.event.client_payload.status != 'success' }}
if: ${{ steps.processResults.outputs.hasFailed }}
run: |
echo "Load test result: "${{ github.event.client_payload.result }}
echo "Load test "${{ github.event.client_payload.name }}" failed with status: "${{ github.event.client_payload.status }} "and error rate: "${{ github.event.client_payload.errorRate }}
echo "One or more load tests have been failed"
echo '${{ toJson(github.event.client_payload.results) }}'
exit 1
12 changes: 11 additions & 1 deletion .github/workflows/trigger-load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ on:
description: 'Cluster name'
default: 'mysql-perf-cluster-test'
required: false
schedule:
- cron: '0 0 * * *'

jobs:
invokeLoadTests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Process cluster name
id: processClusterName
run: |
clusterName="${{github.event.inputs.clusterName}}"
if [ "$clusterName" = "" ]; then
clusterName="mysql-perf-cluster-test"
fi
printf "::set-output name=clusterName::%s" $clusterName
- name: Get latest ballerina runtime artifact
id: setRuntimeUrl
shell: bash
Expand Down Expand Up @@ -49,4 +59,4 @@ jobs:
repo: ballerina-platform/ballerina-performance-cloud
ref: refs/heads/main
token: ${{ secrets.BALLERINA_BOT_TOKEN }}
inputs: '{ "repo-name": "module-ballerinax-mysql", "tests": "${{ steps.formatTestNames.outputs.testNames }}", "zipURL": ${{ steps.setRuntimeUrl.outputs.runtimeUrl}}, "clusterName": "${{ github.event.inputs.clusterName }}", "dispatchType": "mysql-load-test" }'
inputs: '{ "repo-name": "module-ballerinax-mysql", "tests": "${{ steps.formatTestNames.outputs.testNames }}", "zipURL": ${{ steps.setRuntimeUrl.outputs.runtimeUrl}}, "clusterName": "${{ steps.processClusterName.outputs.clusterName }}", "dispatchType": "mysql-load-test" }'