-
Notifications
You must be signed in to change notification settings - Fork 508
178 lines (167 loc) · 6.21 KB
/
loadtest.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
---
name: Load Test
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
runner:
description: The runner to execute on
default: 'ubuntu-latest'
type: choice
options:
- ubuntu-latest
- loadtester
environment:
description: The environment to run against
required: false
type: environment
scenario:
default: 'simple'
description: The scenario to run
type: string
duration:
default: '5m'
description: Duration of the test
required: false
type: string
workflow_call:
inputs:
environment:
description: The environment to run against
type: string
required: true
runner:
required: true
type: string
description: The runner label to use
scenario:
required: true
description: The mode for the stress test
type: string
duration:
default: '5m'
description: Duration of the test
required: false
type: string
outputs:
workflow_output:
description: "Loadtest output"
value: ${{ jobs.run_k6.outputs.loadtest_output_success }}
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL:
required: true
DD_API_KEY:
required: true
LOADTEST_RPC_URL:
required: true
LOADTEST_MNEMONIC:
required: true
jobs:
run_k6:
environment: ${{ inputs.environment }}
runs-on: "${{ inputs.runner }}"
outputs:
loadtest_output_success: ${{ steps.run_k6_success.outputs.test_output }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@v3
- id: random-number-generator
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
shell: bash
- uses: datadog/agent-github-action@v1.3
with:
api_key: ${{ secrets.DD_API_KEY }}
container_name: "datadog-agent-${{ steps.random-number-generator.outputs.random-number }}"
- name: Install xk6
run: |
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with github.com/distribworks/xk6-ethereum@v1.0.3
- name: Install JQ
run: |
mkdir -p $HOME/.local/bin
curl -sLo $HOME/.local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && chmod +x $HOME/.local/bin/jq
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Download artifact to get rpc url
env:
url: ${{ secrets.LOADTEST_RPC_URL }}
if: ${{ env.url == '' }}
uses: actions/download-artifact@v3
with:
name: rpc_url
- name: Set rpc_url
id: set_rpc_url
run: |
if [[ -z "${{ secrets.LOADTEST_RPC_URL }}" ]]; then
echo "rpc_url=http://$(cat rpc_url.txt)" >> $GITHUB_OUTPUT
else
echo "rpc_url=${{ secrets.LOADTEST_RPC_URL }}" >> $GITHUB_OUTPUT
fi
- id: k6
name: Run scenario
run: |
./k6 run --out statsd loadtest/scenarios/${{ inputs.scenario }}.js
echo "tps_avg=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.avg')" >> $GITHUB_OUTPUT
echo "tps_max=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.max')" >> $GITHUB_OUTPUT
echo "iterations=$(cat summary.json | jq -r '.metrics.iterations.values.count')" >> $GITHUB_OUTPUT
echo "block=$(cat summary.json | jq -r '.metrics.ethereum_block.values.count')" >> $GITHUB_OUTPUT
echo "ttm=$(cat summary.json | jq -r '.metrics.ethereum_time_to_mine.values.avg')" >> $GITHUB_OUTPUT
echo "gas_avg=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.avg')" >> $GITHUB_OUTPUT
echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT
env:
K6_STATSD_ENABLE_TAGS: true
RPC_URL: ${{ steps.set_rpc_url.outputs.rpc_url }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }}
LOADTEST_DURATION: ${{ inputs.duration }}
- name: Run tests success
if: success()
id: run_k6_success
run: echo "test_output=true" >> $GITHUB_OUTPUT
- name: Notify Slack
uses: slackapi/slack-github-action@v1.23.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "K6 Loadtest Results"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Scenario*: `${{ inputs.scenario }}`\n *Average TPS*: `${{ steps.k6.outputs.tps_avg }}`\n*Max TPS*: `${{ steps.k6.outputs.tps_max }}`\n*Transactions*: `${{ steps.k6.outputs.iterations }}`\n*Block Number*: `${{ steps.k6.outputs.block }}`\n*Time to Mine*: `${{ steps.k6.outputs.ttm }}`\n*Average Gas Used*: `${{ steps.k6.outputs.gas_avg }}`\n*Max Gas Used*: `${{ steps.k6.outputs.gas_max }}`"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Environment: `${{ inputs.environment }}`"
},
{
"type": "mrkdwn",
"text": "JSON-RPC Endpoint: ${{ steps.set_rpc_url.outputs.rpc_url }}"
},
{
"type": "mrkdwn",
"text": "Workflow: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Results>"
}
]
}
]
}