Skip to content

Commit 6eadb23

Browse files
committed
ci: custom self hosted load test action, run load tests as part of the CI based on labels
1 parent 3ff0e95 commit 6eadb23

File tree

3 files changed

+99
-14
lines changed

3 files changed

+99
-14
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: 'Run Load Test on Self-Hosted Runners'
2+
description: 'Run load tests against Kubernetes cluster on self-hosted runners'
3+
4+
inputs:
5+
avalanchego_image:
6+
description: 'AvalancheGo image to test'
7+
required: false
8+
default: 'avaplatform/avalanchego:latest'
9+
exclusive_scheduling:
10+
description: 'Enable exclusive scheduling'
11+
required: false
12+
default: "false"
13+
duration:
14+
description: "Load test duration"
15+
required: false
16+
artifact_prefix:
17+
description: 'Prefix for artifact names'
18+
required: false
19+
default: 'load-test-self-hosted-runners'
20+
prometheus_username:
21+
description: 'Prometheus username for monitoring'
22+
required: true
23+
prometheus_password:
24+
description: 'Prometheus password for monitoring'
25+
required: true
26+
loki_username:
27+
description: 'Loki username for logging'
28+
required: true
29+
loki_password:
30+
description: 'Loki password for logging'
31+
required: true
32+
33+
runs:
34+
using: composite
35+
steps:
36+
- name: Install dependencies
37+
shell: bash
38+
# The xz-utils might be present on some containers
39+
run: |
40+
if ! command -v xz &> /dev/null; then
41+
sudo apt-get update
42+
sudo apt-get install -y xz-utils
43+
fi
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
- name: Setup Go for project
49+
uses: ./.github/actions/setup-go-for-project
50+
- name: Run exclusive load test
51+
if: inputs.exclusive_scheduling == 'true'
52+
uses: ./.github/actions/run-monitored-tmpnet-cmd
53+
with:
54+
run: ./scripts/run_task.sh test-load-exclusive -- --kube-image ${{ inputs.avalanchego_image }}${{ inputs.duration && format(' --duration {0}', inputs.duration) || '' }}
55+
artifact_prefix: ${{ inputs.artifact_prefix }}
56+
prometheus_username: ${{ inputs.prometheus_username }}
57+
prometheus_password: ${{ inputs.prometheus_password }}
58+
loki_username: ${{ inputs.loki_username }}
59+
loki_password: ${{ inputs.loki_password }}
60+
- name: Run load test
61+
if: inputs.exclusive_scheduling != 'true'
62+
uses: ./.github/actions/run-monitored-tmpnet-cmd
63+
with:
64+
run: ./scripts/run_task.sh test-load-kube -- --kube-image ${{ inputs.avalanchego_image }}${{ inputs.duration && format(' --duration {0}', inputs.duration) || '' }}
65+
artifact_prefix: ${{ inputs.artifact_prefix }}
66+
prometheus_username: ${{ inputs.prometheus_username }}
67+
prometheus_password: ${{ inputs.prometheus_password }}
68+
loki_username: ${{ inputs.loki_username }}
69+
loki_password: ${{ inputs.loki_password }}

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,20 @@ jobs:
274274
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
275275
loki_username: ${{ secrets.LOKI_ID || '' }}
276276
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
277+
load_self_hosted:
278+
name: Run load test on self-hosted runners
279+
if: contains(github.event.pull_request.labels.*.name, 'load-test') || contains(github.event.pull_request.labels.*.name, 'load-test-exclusive')
280+
runs-on: avalanche-avalanchego-runner
281+
container:
282+
image: ghcr.io/actions/actions-runner:2.325.0
283+
steps:
284+
- name: Run load test
285+
uses: ./.github/actions/self-hosted-load-test
286+
with:
287+
avalanchego_image: 'avalanchego:${{ github.sha }}'
288+
exclusive_scheduling: ${{ contains(github.event.pull_request.labels.*.name, 'load-test-exclusive') }}
289+
artifact_prefix: load-ci-self-hosted
290+
prometheus_username: ${{ secrets.PROMETHEUS_ID }}
291+
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD }}
292+
loki_username: ${{ secrets.LOKI_ID }}
293+
loki_password: ${{ secrets.LOKI_PASSWORD }}

.github/workflows/load-tests.yaml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ name: Load test on self-hosted runners
44
on:
55
workflow_dispatch:
66
inputs:
7-
image:
7+
avalanchego_image:
88
description: 'AvalancheGo image to test'
99
required: false
1010
default: 'avaplatform/avalanchego:latest'
1111
type: string
12+
exclusive_scheduling:
13+
description: 'Enable exclusive scheduling'
14+
required: false
15+
default: false
16+
type: boolean
17+
duration:
18+
description: "Load test duration"
19+
required: false
1220

1321
jobs:
1422
load_tests:
@@ -17,20 +25,11 @@ jobs:
1725
container:
1826
image: ghcr.io/actions/actions-runner:2.325.0
1927
steps:
20-
- name: Install dependencies
21-
run: |
22-
sudo apt-get update
23-
sudo apt-get install -y xz-utils
24-
- name: Checkout code
25-
uses: actions/checkout@v4
26-
with:
27-
fetch-depth: 0
28-
- name: Setup Go for project
29-
uses: ./.github/actions/setup-go-for-project
30-
- uses: ./.github/actions/run-monitored-tmpnet-cmd
28+
- uses: ./.github/actions/self-hosted-load-test
3129
with:
32-
run: ./scripts/run_task.sh test-load-kube -- --kube-image ${{ inputs.image }}
33-
artifact_prefix: load-self-hosted-runner
30+
avalanchego_image: ${{ inputs.avalanchego_image }}
31+
exclusive_scheduling: ${{ inputs.exclusive_scheduling }}
32+
duration: ${{ inputs.duration }}
3433
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
3534
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
3635
loki_username: ${{ secrets.LOKI_ID || '' }}

0 commit comments

Comments
 (0)