@@ -3,6 +3,11 @@ name: benchmarks
33on :
44 workflow_dispatch :
55 inputs :
6+ runStandalone :
7+ description : ' Run the benchmarks against standalone APM Server with Moxy'
8+ required : false
9+ type : boolean
10+ default : false
611 profile :
712 description : ' The system profile used to run the benchmarks'
813 required : false
2126 required : false
2227 type : string
2328 schedule :
24- - cron : ' 0 17 * * *'
29+ - cron : ' 0 17 * * *' # Scheduled regular benchmarks.
30+ - cron : ' 0 5 */5 * *' # Scheduled PGO benchmarks.
2531
2632env :
2733 PNG_REPORT_FILE : out.png
34+ BENCHMARK_CPU_OUT : default.pgo
2835 BENCHMARK_RESULT : benchmark-result.txt
2936 WORKING_DIRECTORY : testing/benchmark
3037
@@ -38,12 +45,13 @@ jobs:
3845 run :
3946 working-directory : ${{ env.WORKING_DIRECTORY }}
4047 permissions :
41- contents : read
48+ contents : write
4249 id-token : write
4350 env :
4451 SSH_KEY : ./id_rsa_terraform
4552 TF_VAR_private_key : ./id_rsa_terraform
4653 TF_VAR_public_key : ./id_rsa_terraform.pub
54+ RUN_STANDALONE : ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
4755 TFVARS_SOURCE : ${{ inputs.profile || 'system-profiles/8GBx1zone.tfvars' }} # // Default to use an 8gb profile
4856 TF_VAR_BUILD_ID : ${{ github.run_id }}
4957 TF_VAR_ENVIRONMENT : ci
@@ -101,28 +109,48 @@ jobs:
101109 terraform_version : 1.3.7
102110 terraform_wrapper : false
103111
112+ - name : Init terraform module
113+ id : init
114+ run : make init
115+
104116 - name : Build apmbench
105117 run : make apmbench $SSH_KEY terraform.tfvars
106118
119+ - name : Build APM Server and Moxy
120+ if : ${{ env.RUN_STANDALONE == 'true' }}
121+ run : |
122+ make apm-server
123+ make moxy
124+
107125 - name : Override docker committed version
108- if : ${{ ! inputs.runOnStable }}
126+ if : ${{ ! inputs.runOnStable && env.RUN_STANDALONE == 'false' }}
109127 run : make docker-override-committed-version
110128
111129 - name : Spin up benchmark environment
112130 id : deploy
113131 run : |
114- make init apply
132+ make apply
115133 admin_console_url=$(terraform output -raw admin_console_url)
116134 echo "admin_console_url=$admin_console_url" >> "$GITHUB_OUTPUT"
117135 echo "-> infra setup done"
136+ env :
137+ TF_VAR_worker_region : ${{ env.AWS_REGION }}
138+ TF_VAR_run_standalone : ${{ env.RUN_STANDALONE }}
118139
119140 - name : Run benchmarks autotuned
120141 if : ${{ inputs.benchmarkAgents == '' }}
121- run : make run-benchmark-autotuned index-benchmark-results
142+ run : make run-benchmark-autotuned
122143
123144 - name : Run benchmarks self tuned
124145 if : ${{ inputs.benchmarkAgents != '' }}
125- run : make run-benchmark index-benchmark-results
146+ run : make run-benchmark
147+
148+ - name : Cat standalone server logs
149+ if : ${{ env.RUN_STANDALONE == 'true' && failure() }}
150+ run : make cat-apm-server-logs
151+
152+ - name : Index benchmarks result
153+ run : make index-benchmark-results
126154
127155 - name : Download PNG
128156 run : >-
@@ -150,15 +178,65 @@ jobs:
150178
151179 - name : Upload benchmark result
152180 uses : actions/upload-artifact@v4
153- if : always()
154181 with :
155182 name : benchmark-result
156183 path : ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_RESULT }}
157184 if-no-files-found : error
158185
186+ # The next section injects CPU profile collected by apmbench into the build.
187+ # By copying the profile, uploading it to the artifacts and pushing it
188+ # via a PR to update default.pgo.
189+
190+ - name : Copy CPU profile
191+ run : make cp-cpuprof
192+
193+ - name : Upload CPU profile
194+ uses : actions/upload-artifact@v4
195+ with :
196+ name : cpu-profile
197+ path : ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
198+ if-no-files-found : error
199+
200+ - name : Get token
201+ id : get_token
202+ uses : tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
203+ with :
204+ app_id : ${{ secrets.OBS_AUTOMATION_APP_ID }}
205+ private_key : ${{ secrets.OBS_AUTOMATION_APP_PEM }}
206+ permissions : >-
207+ {
208+ "contents": "write",
209+ "pull_requests": "write"
210+ }
211+
212+ # Required to use a service account, otherwise PRs created by
213+ # GitHub bot won't trigger any CI builds.
214+ # See https://github.com/peter-evans/create-pull-request/issues/48#issuecomment-537478081
215+ - name : Configure git user
216+ uses : elastic/oblt-actions/git/setup@v1
217+ with :
218+ github-token : ${{ steps.get_token.outputs.token }}
219+
220+ - name : Import GPG key
221+ uses : crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
222+ with :
223+ gpg_private_key : ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }}
224+ passphrase : ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }}
225+ git_user_signingkey : true
226+ git_commit_gpgsign : true
227+
228+ - name : Open PGO PR
229+ if : ${{ env.RUN_STANDALONE == 'true' && github.ref == 'refs/heads/main' }}
230+ run : ${{ github.workspace }}/.ci/scripts/push-pgo-pr.sh
231+ env :
232+ WORKSPACE_PATH : ${{ github.workspace }}
233+ PROFILE_PATH : ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
234+ GITHUB_TOKEN : ${{ steps.get_token.outputs.token }}
235+ WORKFLOW : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
236+
159237 - name : Tear down benchmark environment
160238 if : always()
161- run : make destroy
239+ run : make init destroy
162240
163241 # Notify failure to Slack only on schedule (nightly run)
164242 - if : failure() && github.event_name == 'schedule'
0 commit comments