Repository navigation
151 lines (134 loc) · 4.08 KB
/
Copy pathload-test-run.yml
File metadata and controls
151 lines (134 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Load Test Run
on:
workflow_dispatch:
inputs:
vus:
description: "k6 VUs"
required: true
default: "10"
type: string
iterations:
description: "k6 iterations per VU"
required: true
default: "10"
type: string
max_duration:
description: "k6 max duration"
required: true
default: "15m"
type: string
test_mode:
description: "k6 test mode"
required: true
default: "bruno-all-apis"
type: choice
options:
- bruno-all-apis
- whole-user-flow
api_docs_ref:
description: "api-docs git ref used when test_mode is bruno-all-apis"
required: false
default: "main"
type: string
target_base_url:
description: "Target base URL. Empty uses Terraform default."
required: false
default: ""
type: string
prometheus_remote_write_url:
description: "Prometheus remote-write URL. Empty uses Terraform default."
required: false
default: ""
type: string
destroy_runner:
description: "Destroy the k6 load generator after this run"
required: true
default: true
type: boolean
rebuild_k6:
description: "Rebuild the k6 binary before running"
required: true
default: false
type: boolean
permissions:
id-token: write
contents: read
concurrency:
group: load-test-environment
cancel-in-progress: false
env:
TF_VERSION: "1.10.5"
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_PAT }}
persist-credentials: false
- uses: actions/checkout@v4
if: inputs.test_mode == 'bruno-all-apis'
with:
repository: solid-connection/api-docs
ref: ${{ inputs.api_docs_ref }}
path: api-docs
token: ${{ secrets.GH_PAT }}
persist-credentials: false
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_LOAD_TEST_ROLE_ARN }}
aws-region: ap-northeast-2
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TF_VERSION }}
terraform_wrapper: false
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Test Bruno k6 generator
run: python -m unittest scripts.load_test.tests.test_generate_bruno_k6
- name: Run k6 on load generator
env:
VUS: ${{ inputs.vus }}
ITERATIONS: ${{ inputs.iterations }}
MAX_DURATION: ${{ inputs.max_duration }}
TEST_MODE: ${{ inputs.test_mode }}
TARGET_BASE_URL: ${{ inputs.target_base_url }}
PROMETHEUS_REMOTE_WRITE_URL: ${{ inputs.prometheus_remote_write_url }}
run: |
args=(
--vus "$VUS"
--iterations "$ITERATIONS"
--max-duration "$MAX_DURATION"
)
case "$TEST_MODE" in
bruno-all-apis)
args+=(
--script bruno-all-apis.js
--generate-bruno-script
--bruno-collection-dir "api-docs/Solid Connection"
)
;;
whole-user-flow)
args+=(--script whole-user-flow.js)
;;
*)
echo "::error::Invalid test_mode: $TEST_MODE"
exit 1
;;
esac
if [ -n "$TARGET_BASE_URL" ]; then
args+=(--target-base-url "$TARGET_BASE_URL")
fi
if [ -n "$PROMETHEUS_REMOTE_WRITE_URL" ]; then
args+=(--prometheus-remote-write-url "$PROMETHEUS_REMOTE_WRITE_URL")
fi
if [ "${{ inputs.destroy_runner }}" != "true" ]; then
args+=(--skip-runner-destroy)
fi
if [ "${{ inputs.rebuild_k6 }}" = "true" ]; then
args+=(--rebuild-k6)
fi
bash scripts/load_test/run_k6.sh "${args[@]}"