corso/.github/workflows/load_test.yml
Keepers 1bc3210c97
add rolling data production to load test (#1339)
## Description

Adds production of 10 exchange items of each type, only for the load_test user, every time the load tests succeed.  Also migrates that user ID out to a secret value stored in github.

## Type of change

- [x] 🤖 Test

## Issue(s)

* #902

## Test Plan

- [x] 💚 E2E
2022-10-26 21:56:32 +00:00

127 lines
4.2 KiB
YAML

name: Nightly Load Testing
on:
schedule:
# every day at 01:59 (01:59am) UTC
# - cron: "59 1 * * *"
# temp, for testing: every 4 hours
- cron: "0 */4 * * *"
permissions:
# required to retrieve AWS credentials
id-token: write
contents: write
# cancel currently running jobs if a new version of the branch is pushed
concurrency:
group: load_testing-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Load-Tests:
environment: Testing
runs-on: ubuntu-latest
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version-file: src/go.mod
- run: mkdir test_results
# Install gotestfmt
- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
# AWS creds
- name: Configure AWS credentials from Test account
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
role-session-name: integration-testing
aws-region: us-east-1
# run the tests
- name: Integration Tests
env:
AZURE_CLIENT_ID: ${{ secrets.CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
CORSO_PASSPHRASE: ${{ secrets.INTEGRATION_TEST_CORSO_PASSPHRASE }}
CORSO_M356_LOAD_TEST_USER_ID: ${{ secrets.CORSO_M356_LOAD_TEST_USER_ID }}
CORSO_LOAD_TESTS: true
run: |
set -euo pipefail
go test \
-count=1 \
-json \
-v \
--timeout 12h \
-blockprofile=block.prof \
-cpuprofile=cpu.prof \
-memprofile=mem.prof \
-mutexprofile=mutex.prof \
-trace=trace.out \
-outputdir=test_results \
./pkg/repository/repository_load_test.go \
2>&1 | tee ./test_results/goloadtest.log | gotestfmt -hide successful-tests
# package all artifacts for later review
- name: Upload Log, Profilers, Traces
if: always()
uses: actions/upload-artifact@v3
with:
name: load-test-profiling
path: src/test_results/*
if-no-files-found: error
retention-days: 14
# currently, we're required to generate a unique folder for each factory
# production. Whenever possible, this should be reverted to increasing the
# item count of a single folder instead, to prevent overproduction of folders
# during restore.
- name: Set folder destination date
run: |
echo "NOW=$(date -u +"%Y-%m-%d_%H-%M-%S")" >> $GITHUB_ENV
# generate new entries to roll into the next load test
# only runs if the test was successful
- name: New Data Creation
working-directory: ./src/cmd/factory
env:
AZURE_CLIENT_ID: ${{ secrets.CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
CORSO_M356_LOAD_TEST_USER_ID: ${{ secrets.CORSO_M356_LOAD_TEST_USER_ID }}
run: |
go run . exchange emails \
--user ${{ env.CORSO_M356_LOAD_TEST_USER_ID }} \
--destination lt_${{ env.NOW }} \
--count 10
go run . exchange contacts \
--user ${{ env.CORSO_M356_LOAD_TEST_USER_ID }} \
--destination lt_${{ env.NOW }} \
--count 10
go run . exchange events \
--user ${{ env.CORSO_M356_LOAD_TEST_USER_ID }} \
--destination lt_${{ env.NOW }} \
--count 10
# cleanup folders produced by load test
- name: Restored Folder Purge
if: always()
working-directory: ./src
env:
AZURE_CLIENT_ID: ${{ secrets.CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
DELETE_FOLDER_PREFIX: "Corso_Restore_"
run: >
go run ./cmd/purge/purge.go
--user '*'
--prefix ${{ env.DELETE_FOLDER_PREFIX }}