@@ -3,6 +3,11 @@ name: benchmarks
3
3
on :
4
4
workflow_dispatch :
5
5
inputs :
6
+ runStandalone :
7
+ description : ' Run the benchmarks against standalone APM Server with Moxy'
8
+ required : false
9
+ type : boolean
10
+ default : false
6
11
profile :
7
12
description : ' The system profile used to run the benchmarks'
8
13
required : false
21
26
required : false
22
27
type : string
23
28
schedule :
24
- - cron : ' 0 17 * * *'
29
+ - cron : ' 0 17 * * *' # Scheduled regular benchmarks.
30
+ - cron : ' 0 5 */5 * *' # Scheduled PGO benchmarks.
25
31
26
32
env :
27
33
PNG_REPORT_FILE : out.png
34
+ BENCHMARK_CPU_OUT : default.pgo
28
35
BENCHMARK_RESULT : benchmark-result.txt
29
36
WORKING_DIRECTORY : testing/benchmark
30
37
@@ -38,12 +45,14 @@ jobs:
38
45
run :
39
46
working-directory : ${{ env.WORKING_DIRECTORY }}
40
47
permissions :
41
- contents : read
48
+ contents : write
42
49
id-token : write
43
50
env :
44
51
SSH_KEY : ./id_rsa_terraform
45
52
TF_VAR_private_key : ./id_rsa_terraform
46
53
TF_VAR_public_key : ./id_rsa_terraform.pub
54
+ TF_VAR_run_standalone : ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
55
+ RUN_STANDALONE : ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
47
56
TFVARS_SOURCE : ${{ inputs.profile || 'system-profiles/8GBx1zone.tfvars' }} # // Default to use an 8gb profile
48
57
TF_VAR_BUILD_ID : ${{ github.run_id }}
49
58
TF_VAR_ENVIRONMENT : ci
59
68
with :
60
69
go-version-file : ' go.mod'
61
70
62
- - uses : rlespinasse/github-slug-action@797d68864753cbceedc271349d402da4590e6302
71
+ - uses : rlespinasse/github-slug-action@aba9f8db6ef36e0733227a62673d6592b1f430ea
63
72
64
73
- name : Set up env
65
74
run : |
90
99
with :
91
100
role-duration-seconds : 18000 # 5 hours
92
101
93
- - uses : google-github-actions/get-secretmanager-secrets@95a0b09b8348ef3d02c68c6ba5662a037e78d713 # v2.1.4
102
+ - uses : google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
94
103
with :
95
104
export_to_environment : true
96
105
secrets : |-
@@ -101,28 +110,44 @@ jobs:
101
110
terraform_version : 1.3.7
102
111
terraform_wrapper : false
103
112
113
+ - name : Init terraform module
114
+ id : init
115
+ run : make init
116
+
104
117
- name : Build apmbench
105
118
run : make apmbench $SSH_KEY terraform.tfvars
106
119
120
+ - name : Build APM Server and Moxy
121
+ if : ${{ env.RUN_STANDALONE == 'true' }}
122
+ run : |
123
+ make apm-server
124
+ make moxy
125
+
107
126
- name : Override docker committed version
108
- if : ${{ ! inputs.runOnStable }}
127
+ if : ${{ ! inputs.runOnStable && env.RUN_STANDALONE == 'false' }}
109
128
run : make docker-override-committed-version
110
129
111
130
- name : Spin up benchmark environment
112
131
id : deploy
113
132
run : |
114
- make init apply
133
+ make apply
115
134
admin_console_url=$(terraform output -raw admin_console_url)
116
135
echo "admin_console_url=$admin_console_url" >> "$GITHUB_OUTPUT"
117
136
echo "-> infra setup done"
118
-
119
137
- name : Run benchmarks autotuned
120
138
if : ${{ inputs.benchmarkAgents == '' }}
121
- run : make run-benchmark-autotuned index-benchmark-results
139
+ run : make run-benchmark-autotuned
122
140
123
141
- name : Run benchmarks self tuned
124
142
if : ${{ inputs.benchmarkAgents != '' }}
125
- run : make run-benchmark index-benchmark-results
143
+ run : make run-benchmark
144
+
145
+ - name : Cat standalone server logs
146
+ if : ${{ env.RUN_STANDALONE == 'true' && failure() }}
147
+ run : make cat-apm-server-logs
148
+
149
+ - name : Index benchmarks result
150
+ run : make index-benchmark-results
126
151
127
152
- name : Download PNG
128
153
run : >-
@@ -150,15 +175,76 @@ jobs:
150
175
151
176
- name : Upload benchmark result
152
177
uses : actions/upload-artifact@v4
153
- if : always()
154
178
with :
155
179
name : benchmark-result
156
180
path : ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_RESULT }}
157
181
if-no-files-found : error
158
182
183
+ # The next section injects CPU profile collected by apmbench into the build.
184
+ # By copying the profile, uploading it to the artifacts and pushing it
185
+ # via a PR to update default.pgo.
186
+
187
+ - name : Copy CPU profile
188
+ run : make cp-cpuprof
189
+
190
+ - name : Upload CPU profile
191
+ uses : actions/upload-artifact@v4
192
+ with :
193
+ name : cpu-profile
194
+ path : ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
195
+ if-no-files-found : error
196
+
197
+ - name : Get token
198
+ id : get_token
199
+ uses : tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
200
+ with :
201
+ app_id : ${{ secrets.OBS_AUTOMATION_APP_ID }}
202
+ private_key : ${{ secrets.OBS_AUTOMATION_APP_PEM }}
203
+ permissions : >-
204
+ {
205
+ "contents": "write",
206
+ "pull_requests": "write"
207
+ }
208
+
209
+ # Required to use a service account, otherwise PRs created by
210
+ # GitHub bot won't trigger any CI builds.
211
+ # See https://github.com/peter-evans/create-pull-request/issues/48#issuecomment-537478081
212
+ - name : Configure git user
213
+ uses : elastic/oblt-actions/git/setup@v1
214
+ with :
215
+ github-token : ${{ steps.get_token.outputs.token }}
216
+
217
+ - name : Import GPG key
218
+ uses : crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
219
+ with :
220
+ gpg_private_key : ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }}
221
+ passphrase : ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }}
222
+ git_user_signingkey : true
223
+ git_commit_gpgsign : true
224
+
225
+ - name : Open PGO PR
226
+ if : ${{ env.RUN_STANDALONE == 'true' }}
227
+ run : ${{ github.workspace }}/.ci/scripts/push-pgo-pr.sh
228
+ env :
229
+ WORKSPACE_PATH : ${{ github.workspace }}
230
+ PROFILE_PATH : ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
231
+ GITHUB_TOKEN : ${{ steps.get_token.outputs.token }}
232
+ WORKFLOW : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
233
+
234
+ # Secrets are rotated daily, if the benchmarks run between the rotation window, then
235
+ # there is a high chance things will stop working
236
+ # This is trying to reduce the chances of that happening.
237
+ # See https://github.com/elastic/observability-test-environments/actions/workflows/cluster-rotate-api-keys.yml
238
+ - uses : google-github-actions/get-secretmanager-secrets@e5bb06c2ca53b244f978d33348d18317a7f263ce # v2.2.2
239
+ if : always()
240
+ with :
241
+ export_to_environment : true
242
+ secrets : |-
243
+ EC_API_KEY:elastic-observability/elastic-cloud-observability-team-pro-api-key
244
+
159
245
- name : Tear down benchmark environment
160
246
if : always()
161
- run : make destroy
247
+ run : make init destroy
162
248
163
249
# Notify failure to Slack only on schedule (nightly run)
164
250
- if : failure() && github.event_name == 'schedule'
@@ -170,13 +256,14 @@ jobs:
170
256
171
257
# Notify result to Slack only on schedule (nightly run)
172
258
- if : github.event_name == 'schedule'
173
- uses : slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
174
- env :
175
- SLACK_BOT_TOKEN : ${{ secrets.SLACK_BOT_TOKEN }}
259
+ uses : slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
176
260
with :
177
- channel-id : " #apm-server"
261
+ method : chat.postMessage
262
+ token : ${{ secrets.SLACK_BOT_TOKEN }}
178
263
payload : |
179
264
{
265
+ "channel": "#apm-server",
266
+ "text": "${{ github.event_name == 'schedule' && 'Nightly' || '' }} APM Server benchmarks succesfully executed!",
180
267
"blocks": [
181
268
{
182
269
"type": "section",
0 commit comments