Performance tests #741
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Performance tests | |
on: | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
go-version: | |
required: true | |
type: string | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
performance-test-suite-detect-runners: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.detect-runners.outputs.matrix }} | |
env: | |
PERF_TEST_RUNS_ON: ${{ secrets.PERF_TEST_RUNS_ON }} | |
PERF_TEST_RUNS_ON_DEFAULT: | | |
{ | |
"targets": [ | |
{ | |
"name": "github-ubuntu-latest", | |
"runs-on": "ubuntu-latest" | |
} | |
] | |
} | |
steps: | |
- id: detect-runners | |
run: | | |
RES="$(echo "${PERF_TEST_RUNS_ON:-${PERF_TEST_RUNS_ON_DEFAULT}}" | jq -c '.targets')" | |
echo "Detected targets:" | |
echo "$RES" | jq . | |
echo "matrix=${RES}" >> $GITHUB_OUTPUT | |
performance-test-suite: | |
name: Performance Test Suite (${{ matrix.target.name }}) | |
needs: | |
- performance-test-suite-detect-runners | |
strategy: | |
matrix: | |
target: ${{ fromJson(needs.performance-test-suite-detect-runners.outputs.matrix) }} | |
runs-on: ${{ matrix.target.runs-on }} | |
env: | |
ARG_DURATION: "${{ startsWith(github.ref, 'refs/tags/v') && '-d 2m' || '' }}" | |
INFLUX_HOST: ${{ secrets.INFLUX_HOST }} | |
INFLUX_TOKEN: ${{ secrets.INFLUX_TOKEN }} | |
steps: | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ inputs.go-version }} | |
- uses: actions/checkout@v4 | |
- run: go build -o perf-test-suite ./test/performance-test-suite/cmd/perf-test/ | |
- name: Run performance tests | |
id: performance | |
run: | | |
echo "version=$(cat Makefile | grep '\<VERSION=' | awk -F= '{print $2}' | tr -d [\',])" >> $GITHUB_ENV | |
SECONDS=0 | |
./perf-test-suite $ARG_DURATION -workdir /var/tmp -host $INFLUX_HOST -token $INFLUX_TOKEN -runner ${{ matrix.target.name }} -version $(cat Makefile | grep '\<VERSION=' | awk -F= '{print $2}' | tr -d [\',]) > perf-test-results-with-summaries.txt | |
echo "duration=$SECONDS" >> $GITHUB_ENV | |
sed '/^{/,/^}/!d' perf-test-results-with-summaries.txt > perf-test-results.json | |
env: | |
GOMEMLIMIT: 7680MiB | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Performance Test Results (${{ matrix.target.name }}) | |
path: perf-test-results.json | |
retention-days: 30 | |
- name: Create the Mattermost message | |
if: github.event.schedule == '0 0 * * *' | |
run: > | |
echo "{\"text\":\"### Performance tests results for scheduled daily run on ${{ github.ref_name }} branch and ${{ matrix.target.name }} runner\n | |
**Result**: ${{ steps.performance.outcome }}\n | |
**Duration**: ${{ env.duration }}s | **immudb version**: ${{ env.version }}\n | |
$(jq -r '.benchmarks[] | .name + "\n" + .summary' perf-test-results.json) \n | |
**Check details [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})** | |
\"}" > mattermost.json && echo MM_PAYLOAD=$(cat mattermost.json) >> $GITHUB_ENV | |
- name: Notify on immudb channel on Mattermost | |
if: github.event.schedule == '0 0 * * *' | |
uses: mattermost/action-mattermost-notify@master | |
with: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
MATTERMOST_CHANNEL: 'immudb-tests' | |
PAYLOAD: ${{ env.MM_PAYLOAD }} | |
performance-test-suite-upload-s3: | |
if: github.event.schedule != '0 0 * * *' | |
needs: | |
- performance-test-suite | |
- performance-test-suite-detect-runners | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: ${{ fromJson(needs.performance-test-suite-detect-runners.outputs.matrix) }} | |
env: | |
PERF_TEST_AWS_REGION: ${{ secrets.PERF_TEST_AWS_REGION }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download test results | |
if: "${{ env.PERF_TEST_AWS_REGION }}" | |
uses: actions/download-artifact@v4 | |
with: | |
name: Performance Test Results (${{ matrix.target.name }}) | |
- name: Configure AWS credentials | |
if: "${{ env.PERF_TEST_AWS_REGION }}" | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: "${{ secrets.PERF_TEST_AWS_ACCESS_KEY_ID }}" | |
aws-secret-access-key: "${{ secrets.PERF_TEST_AWS_SECRET_ACCESS_KEY }}" | |
aws-region: "${{ secrets.PERF_TEST_AWS_REGION }}" | |
- name: Upload perf results to S3 | |
if: "${{ env.PERF_TEST_AWS_REGION }}" | |
run: | | |
GIT_COMMIT_NAME="$(git show -s --format=%cd --date="format:%Y-%m-%d--%H-%I-%S")--$(git rev-parse HEAD)" | |
aws s3 cp \ | |
perf-test-results.json \ | |
"s3://${{ secrets.PERF_TEST_AWS_BUCKET_PREFIX }}/${{ github.ref_name }}/${GIT_COMMIT_NAME}/${{ matrix.target.name }}.json" |