forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark-pull-request.jenkinsfile
347 lines (337 loc) · 20.4 KB
/
benchmark-pull-request.jenkinsfile
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
pipeline {
agent {label 'Jenkins-Agent-AL2023-X64-M52xlarge-Benchmark-Test'}
options {
timeout(time: 24, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '30'))
throttleJobProperty(
categories: [],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 0,
maxConcurrentTotal: 20,
paramsToUseForLimit: '',
throttleEnabled: true,
throttleOption: 'project',
)
}
environment {
JOB_NAME = 'pull-request-benchmark-test'
}
parameters {
string(
name: 'DISTRIBUTION_URL',
description: 'Publicly available download url of the OpenSearch artifact tarball. Currently only supports x64 arch.',
)
string(
name: 'DISTRIBUTION_VERSION',
description: 'The distribution version of of the OpenSearch artifact, only to be provided in combination with DISTRIBUTION_URL param.',
trim: true
)
booleanParam(
name: 'SECURITY_ENABLED',
description: 'Mention if the cluster is secured or insecured.',
defaultValue: false,
)
booleanParam(
name: 'SINGLE_NODE_CLUSTER',
description: 'Benchmark test on a single node cluster',
defaultValue: true
)
booleanParam(
name: 'MIN_DISTRIBUTION',
description: 'Use OpenSearch min distribution',
defaultValue: false
)
string(
name: 'TEST_WORKLOAD',
description: 'The workload name from OpenSearch Benchmark Workloads.',
defaultValue: 'nyc_taxis',
trim: true
)
string(
name: 'MANAGER_NODE_COUNT',
description: 'Number of cluster manager nodes, empty value defaults to 3.',
trim: true
)
string(
name: 'DATA_NODE_COUNT',
description: 'Number of cluster data nodes, empty value defaults to 2.',
trim: true
)
string(
name: 'CLIENT_NODE_COUNT',
description: 'Number of cluster client nodes, empty value default to 0.',
trim: true
)
string(
name: 'INGEST_NODE_COUNT',
description: 'Number of cluster INGEST nodes, empty value defaults to 0.',
trim: true
)
string(
name: 'ML_NODE_COUNT',
description: 'Number of cluster ml nodes, empty value defaults to 0.',
trim: true
)
string(
name: 'DATA_INSTANCE_TYPE',
description: 'EC2 instance type for data node, empty defaults to r5.xlarge.',
trim: true
)
string(
name: 'DATA_NODE_STORAGE',
description: 'Data node ebs block storage size, empty value defaults to 100Gb',
trim: true
)
string(
name: 'ML_NODE_STORAGE',
description: 'ML node ebs block storage size, empty value defaults to 100Gb',
trim: true
)
string(
name: 'JVM_SYS_PROPS',
description: 'A comma-separated list of key=value pairs that will be added to jvm.options as JVM system properties.',
trim: true
)
string(
name: 'ADDITIONAL_CONFIG',
description: 'Additional opensearch.yml config parameters passed as JSON. e.g., `opensearch.experimental.feature.segment_replication_experimental.enabled:true cluster.indices.replication.strategy:SEGMENT`',
trim: true
)
booleanParam(
name: 'USE_50_PERCENT_HEAP',
description: 'Use 50 percent of physical memory as heap.',
defaultValue: true
)
string(
name: 'USER_TAGS',
description: 'Attach arbitrary text to the meta-data of each benchmark metric record, without any spaces. e.g., `run-type:adhoc,segrep:enabled,arch:x64`. ',
trim: true
)
string(
name: 'WORKLOAD_PARAMS',
description: 'With this parameter you can inject variables into workloads. Use json type. e.g., `{"number_of_replicas":"1","number_of_shards":"5"}`',
trim: true
)
string(
name: 'TEST_PROCEDURE',
description: 'Defines a test procedure to use. e.g., `append-no-conflicts,significant-text`',
trim: true
)
string(
name: 'EXCLUDE_TASKS',
description: 'Defines a comma-separated list of test procedure tasks not to run. Default runs all. e.g., `type:search,delete-index`',
trim: true
)
string(
name: 'INCLUDE_TASKS',
description: 'Defines a comma-separated list of test procedure tasks to run. Default runs all. e.g., `type:search,delete-index`',
trim: true
)
booleanParam(
name: 'CAPTURE_NODE_STAT',
description: 'Enable opensearch-benchmark node-stats telemetry to capture system level metrics.',
defaultValue: false
)
string(
name: 'TELEMETRY_PARAMS',
description: 'Allows to set parameters for telemetry devices. Use json type. e.g.,{"node-stats-include-indices":"true","node-stats-include-indices-metrics":"segments"}',
trim: true
)
}
triggers {
GenericTrigger(
genericVariables: [
[key: 'pull_request_number', value: '$.pull_request_number'],
[key: 'repository', value: '$.repository'],
[key: 'baseline_cluster_config', value: '$.baseline_cluster_config'],
[key: 'DISTRIBUTION_URL', value: '$.DISTRIBUTION_URL'],
[key: 'DISTRIBUTION_VERSION', value: '$.DISTRIBUTION_VERSION'],
[key: 'TEST_WORKLOAD', value: '$.TEST_WORKLOAD'],
[key: 'SECURITY_ENABLED', value: '$.SECURITY_ENABLED'],
[key: 'SINGLE_NODE_CLUSTER', value: '$.SINGLE_NODE_CLUSTER'],
[key: 'MIN_DISTRIBUTION', value: '$.MIN_DISTRIBUTION'],
[key: 'MANAGER_NODE_COUNT', value: '$.MANAGER_NODE_COUNT'],
[key: 'DATA_NODE_COUNT', value: '$.DATA_NODE_COUNT'],
[key: 'CLIENT_NODE_COUNT', value: '$.CLIENT_NODE_COUNT'],
[key: 'INGEST_NODE_COUNT', value: '$.INGEST_NODE_COUNT'],
[key: 'ML_NODE_COUNT', value: '$.ML_NODE_COUNT'],
[key: 'DATA_INSTANCE_TYPE', value: '$.DATA_INSTANCE_TYPE'],
[key: 'DATA_NODE_STORAGE', value: '$.DATA_NODE_STORAGE'],
[key: 'ML_NODE_STORAGE', value: '$.ML_NODE_STORAGE'],
[key: 'JVM_SYS_PROPS', value: '$.JVM_SYS_PROPS'],
[key: 'ADDITIONAL_CONFIG', value: '$.ADDITIONAL_CONFIG'],
[key: 'USE_50_PERCENT_HEAP', value: '$.USE_50_PERCENT_HEAP'],
[key: 'USER_TAGS', value: '$.USER_TAGS'],
[key: 'WORKLOAD_PARAMS', value: '$.WORKLOAD_PARAMS'],
[key: 'TEST_PROCEDURE', value: '$.TEST_PROCEDURE'],
[key: 'EXCLUDE_TASKS', value: '$.EXCLUDE_TASKS'],
[key: 'INCLUDE_TASKS', value: '$.INCLUDE_TASKS'],
[key: 'CAPTURE_NODE_STAT', value: '$.CAPTURE_NODE_STAT'],
[key: 'TELEMETRY_PARAMS', value: '$.TELEMETRY_PARAMS']
],
tokenCredentialId: 'jenkins-pr-benchmark-generic-webhook-token',
causeString: 'Triggered by comment on PR on OpenSearch core repository',
printContributedVariables: true,
printPostContent: true
)
parameterizedCron '''
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=big5;SINGLE_NODE_CLUSTER=true;DATA_INSTANCE_TYPE=r5.xlarge;USE_50_PERCENT_HEAP=true;USER_TAGS=run-type:nightly,cluster-config:x64-r5.xlarge-1-shard-0-replica-snapshot-baseline;WORKLOAD_PARAMS={"snapshot_repo_name":"benchmark-workloads-repo-300","snapshot_bucket_name":"benchmark-workload-snapshots","snapshot_region":"us-east-1","snapshot_base_path":"workload-snapshots-300","snapshot_name":"big5_1_shard_ordered"};TEST_PROCEDURE=restore-from-snapshot;CAPTURE_NODE_STAT=true;MIN_DISTRIBUTION=true
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=nyc_taxis;SINGLE_NODE_CLUSTER=true;DATA_INSTANCE_TYPE=r5.xlarge;USE_50_PERCENT_HEAP=true;USER_TAGS=run-type:nightly,cluster-config:x64-r5.xlarge-1-shard-0-replica-snapshot-baseline;WORKLOAD_PARAMS={"snapshot_repo_name":"benchmark-workloads-repo-300","snapshot_bucket_name":"benchmark-workload-snapshots","snapshot_region":"us-east-1","snapshot_base_path":"workload-snapshots-300","snapshot_name":"nyc_taxis_1_shard"};TEST_PROCEDURE=restore-from-snapshot;CAPTURE_NODE_STAT=true;MIN_DISTRIBUTION=true
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=http_logs;SINGLE_NODE_CLUSTER=true;DATA_INSTANCE_TYPE=r5.xlarge;USE_50_PERCENT_HEAP=true;USER_TAGS=run-type:nightly,cluster-config:x64-r5.xlarge-1-shard-0-replica-snapshot-baseline;WORKLOAD_PARAMS={"snapshot_repo_name":"benchmark-workloads-repo-300","snapshot_bucket_name":"benchmark-workload-snapshots","snapshot_region":"us-east-1","snapshot_base_path":"workload-snapshots-300","snapshot_name":"http_logs_1_shard"};TEST_PROCEDURE=restore-from-snapshot;CAPTURE_NODE_STAT=true;MIN_DISTRIBUTION=true
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=http_logs;SINGLE_NODE_CLUSTER=true;USE_50_PERCENT_HEAP=true;USER_TAGS=cluster-config:x64-r5.xlarge-single-node-1-shard-0-replica-baseline;WORKLOAD_PARAMS={"number_of_replicas":"0","number_of_shards":"1"};EXCLUDE_TASKS=type:search;MIN_DISTRIBUTION=true
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=nyc_taxis;SINGLE_NODE_CLUSTER=true;USE_50_PERCENT_HEAP=true;USER_TAGS=cluster-config:x64-r5.xlarge-single-node-1-shard-0-replica-baseline;WORKLOAD_PARAMS={"number_of_replicas":"0","number_of_shards":"1"};EXCLUDE_TASKS=type:search;MIN_DISTRIBUTION=true
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=pmc;SINGLE_NODE_CLUSTER=true;USE_50_PERCENT_HEAP=true;USER_TAGS=cluster-config:x64-r5.xlarge-single-node-1-shard-0-replica-baseline;WORKLOAD_PARAMS={"number_of_replicas":"0","number_of_shards":"1"};MIN_DISTRIBUTION=true
H 17 * * * %DISTRIBUTION_URL=https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-linux-x64-latest.tar.gz;DISTRIBUTION_VERSION=3.0.0;TEST_WORKLOAD=so;SINGLE_NODE_CLUSTER=true;USE_50_PERCENT_HEAP=true;USER_TAGS=cluster-config:x64-r5.xlarge-single-node-1-shard-0-replica-baseline;WORKLOAD_PARAMS={"number_of_replicas":"0","number_of_shards":"1"};MIN_DISTRIBUTION=true
'''
}
stages {
stage('validate-and-set-parameters') {
steps {
script {
if (DISTRIBUTION_URL == '' || DISTRIBUTION_VERSION == '') {
currentBuild.result = 'ABORTED'
error("Benchmark Tests failed to start. Provide DISTRIBUTION_URL and DISTRIBUTION_VERSION to run tests")
}
env.ARCHITECTURE = "x64"
lib.jenkins.Messages.new(this).add(JOB_NAME, "Benchmark tests for ${DISTRIBUTION_URL}")
if (currentBuild.rawBuild.getCauses().toString().contains("GenericCause")) {
currentBuild.description = "Benchmark initiated by PR:${pull_request_number} on ${repository}"
}
else {
currentBuild.description = "Running benchmark test for distribution-url: ${DISTRIBUTION_URL} distribution-version: ${DISTRIBUTION_VERSION}"
}
}
}
}
stage('benchmark-pull-request') {
steps {
script {
echo "security-enabled: ${SECURITY_ENABLED}"
runBenchmarkTestScript(
command: 'execute-test',
distributionUrl: DISTRIBUTION_URL,
distributionVersion: DISTRIBUTION_VERSION,
workload: TEST_WORKLOAD,
insecure: !(params.SECURITY_ENABLED),
singleNode: SINGLE_NODE_CLUSTER,
minDistribution: MIN_DISTRIBUTION,
use50PercentHeap: USE_50_PERCENT_HEAP,
managerNodeCount: MANAGER_NODE_COUNT,
dataNodeCount: DATA_NODE_COUNT,
clientNodeCount: CLIENT_NODE_COUNT,
ingestNodeCount: INGEST_NODE_COUNT,
mlNodeCount: ML_NODE_COUNT,
dataInstanceType: DATA_INSTANCE_TYPE,
additionalConfig: ADDITIONAL_CONFIG,
dataStorageSize: DATA_NODE_STORAGE,
mlStorageSize: ML_NODE_STORAGE,
jvmSysProps: JVM_SYS_PROPS,
userTag: USER_TAGS.isEmpty() ? "security-enabled:${SECURITY_ENABLED}" : "${USER_TAGS},security-enabled:${SECURITY_ENABLED}",
suffix: "${BUILD_NUMBER}",
workloadParams: WORKLOAD_PARAMS,
testProcedure: TEST_PROCEDURE,
excludeTasks: EXCLUDE_TASKS,
includeTasks: INCLUDE_TASKS,
captureNodeStat: CAPTURE_NODE_STAT,
telemetryParams: TELEMETRY_PARAMS
)
sh "cp /tmp/final_result_${BUILD_NUMBER}.md final_result_${BUILD_NUMBER}.md"
}
}
post {
success {
sh """
echo '<details><summary>Benchmark Results</summary>' > temp_result_${BUILD_NUMBER}.md
echo '' >> temp_result_${BUILD_NUMBER}.md
echo '#### Benchmark Results for Job: ${BUILD_URL}' >> temp_result_${BUILD_NUMBER}.md
cat final_result_${BUILD_NUMBER}.md >> temp_result_${BUILD_NUMBER}.md
echo '</details>' >> temp_result_${BUILD_NUMBER}.md
mv temp_result_${BUILD_NUMBER}.md final_result_${BUILD_NUMBER}.md
"""
script {
if (currentBuild.rawBuild.getCauses().toString().contains("GenericCause")) {
if ("${pull_request_number}" != '' && "${repository}" != '') {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', passwordVariable: 'GITHUB_TOKEN', usernameVariable: 'GITHUB_USER')]) {
def pull_request = Integer.parseInt("${pull_request_number}")
sh ("gh pr comment ${pull_request} --repo ${repository} --body-file final_result_${BUILD_NUMBER}.md")
}
if ("${baseline_cluster_config}" != '') {
Map <String, String> benchmarkTestIds = getCompareBenchmarkIds(
baselineClusterConfig: "${baseline_cluster_config}",
distributionVersion: "${DISTRIBUTION_VERSION}-SNAPSHOT",
workload: "${TEST_WORKLOAD}",
pullRequestNumber: "${pull_request_number}"
)
// Trigger benchmark-compare job
build job: 'benchmark-compare',
parameters: [
string(name:'BASELINE_TEST_EXECUTION_ID', value: "${benchmarkTestIds.baseline}"),
string(name:'CONTENDER_TEST_EXECUTION_ID', value: "${benchmarkTestIds.contender}"),
string(name:'PULL_REQUEST_NUMBER', value: "${pull_request_number}"),
string(name:'REPOSITORY', value: "${repository}")
],
wait: false,
propagate: false
}
}
}
}
postCleanup()
}
failure {
script {
if (currentBuild.rawBuild.getCauses().toString().contains("GenericCause")) {
if ("${pull_request_number}" != '' && "${repository}" != '') {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', passwordVariable: 'GITHUB_TOKEN', usernameVariable: 'GITHUB_USER')]) {
def pull_request = Integer.parseInt("${pull_request_number}")
sh ("gh pr comment ${pull_request} --repo ${repository} --body \"The benchmark job ${BUILD_URL} failed.\n Please see logs to debug.\"")
}
}
}
postCleanup()
}
}
aborted {
script {
def stackNames = [
"opensearch-infra-stack-${BUILD_NUMBER}"
]
withCredentials([string(credentialsId: 'perf-test-account-id', variable: 'PERF_TEST_ACCOUNT_ID')]) {
withAWS(role: 'cfn-set-up', roleAccount: "${PERF_TEST_ACCOUNT_ID}", duration: 900, roleSessionName: 'jenkins-session', region: 'us-east-1') {
try {
for (String stackName : stackNames) {
def stack = null
try {
stack = cfnDescribe(stack: stackName)
} catch (Exception) {
echo "Stack '${stackName}' does not exist, nothing to remove"
}
if (stack != null) {
echo "Deleting stack '${stackName}'"
cfnDelete(stack: stackName, pollInterval:1000)
}
}
} catch (Exception e) {
error "Exception occurred while deleting the CloudFormation stack: ${e.toString()}"
}
}
}
}
postCleanup()
}
}
}
}
}