Skip to content

Commit bc9150c

Browse files
Specify any params structured
With this commit we get rid of all string-based representation of more complex parameters. This affects track-params and car-params specifically which will now be passed to Rally as JSON string in any case. This allows to merge those parameters in more complex scenarios where we need to source them from multiple places. Closes elastic#82 Relates elastic#83
1 parent aa3da3c commit bc9150c

File tree

3 files changed

+92
-32
lines changed

3 files changed

+92
-32
lines changed

night_rally/night_rally.py

+23-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import shlex
99
import socket
1010
import time
11+
import json
1112

1213
ROOT = os.path.dirname(os.path.realpath(__file__))
1314
RALLY_BINARY = "rally --skip-update"
@@ -263,9 +264,10 @@ def __init__(self, params, distribution_version):
263264
if int(self.distribution_version[0]) < 6:
264265
# 5.x needs additional settings as we removed this from Rally in c805ccda0ea05f15bdae22a1eac601bb33a66eae
265266
docker_params.append(
266-
ConstantParam("car-params", "{\\\"additional_cluster_settings\\\": {\\\"xpack.security.enabled\\\": \\\"false\\\", "
267-
"\\\"xpack.ml.enabled\\\": \\\"false\\\", \\\"xpack.monitoring.enabled\\\": \\\"false\\\", "
268-
"\\\"xpack.watcher.enabled\\\": \\\"false\\\"}}")
267+
ConstantParam("car-params", {"additional_cluster_settings": {"xpack.security.enabled": "false",
268+
"xpack.ml.enabled": "false",
269+
"xpack.monitoring.enabled": "false",
270+
"xpack.watcher.enabled": "false"}})
269271
)
270272

271273
self.params = ParamsFormatter(params=params + docker_params)
@@ -301,15 +303,24 @@ def command_line(self, race_config):
301303
for p in self.params:
302304
for k, v in p(race_config).items():
303305
if k in cmd_line_params:
304-
# treat as array first, then join them later
305-
cmd_line_params[k] = cmd_line_params[k] + v
306+
if isinstance(v, dict):
307+
cmd_line_params[k].update(v)
308+
else:
309+
# treat as array first, then join them later
310+
cmd_line_params[k] = cmd_line_params[k] + v
306311
else:
307-
cmd_line_params[k] = v
312+
if isinstance(v, dict):
313+
cmd_line_params[k] = collections.OrderedDict()
314+
cmd_line_params[k].update(v)
315+
else:
316+
cmd_line_params[k] = v
308317

309318
cmd = RALLY_BINARY
310319
for k, v in cmd_line_params.items():
311320
if isinstance(v, list):
312321
cmd += " --{}=\"{}\"".format(k, join_nullables(*v))
322+
elif isinstance(v, dict):
323+
cmd += " --{}=\"{}\"".format(k, json.dumps(v).replace('"', '\\"'))
313324
elif v is None:
314325
cmd += " --{}".format(k)
315326
else:
@@ -370,7 +381,7 @@ def __call__(self, race_config):
370381
"effective-start-date": self.effective_start_date,
371382
"track": race_config.track,
372383
"challenge": race_config.challenge,
373-
"car": [race_config.car],
384+
"car": race_config.car,
374385
"user-tag": self.format_tag(additional_tags={"name": race_config.name})
375386
}
376387
add_if_present(params, "runtime-jdk", self.runtime_jdk)
@@ -456,7 +467,11 @@ def challenge(self):
456467

457468
@property
458469
def car(self):
459-
return self.configuration["car"]
470+
c = self.configuration["car"]
471+
if isinstance(c, str):
472+
return [c]
473+
else:
474+
return c
460475

461476
@property
462477
def car_params(self):

night_rally/resources/tracks.json

+56-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"label": "add-4g-3nodes",
99
"charts": ["indexing"],
1010
"challenge": "append-no-conflicts-index-only",
11-
"track-params": "number_of_replicas:1",
11+
"track-params": {
12+
"number_of_replicas": 1
13+
},
1214
"car": "4gheap",
1315
"node-count": 3
1416
},
@@ -32,7 +34,9 @@
3234
"label": "add-4g",
3335
"charts": ["indexing"],
3436
"challenge": "append-no-conflicts-index-only",
35-
"track-params": "number_of_replicas:0",
37+
"track-params": {
38+
"number_of_replicas": 0
39+
},
3640
"car": "4gheap"
3741
},
3842
{
@@ -54,9 +58,13 @@
5458
"#COMMENT": "Actually, we should not produce graphs for this one because indexing throughput is not that useful here.",
5559
"charts": [],
5660
"challenge": "append-no-conflicts-index-only",
57-
"track-params": "number_of_replicas:0",
61+
"track-params": {
62+
"number_of_replicas": 0
63+
},
5864
"car": "4gheap",
59-
"car-params": "verbose_iw_logging_enabled:true"
65+
"car-params": {
66+
"verbose_iw_logging_enabled": "true"
67+
}
6068
}
6169
]
6270
},
@@ -107,15 +115,19 @@
107115
"label": "add-4g",
108116
"charts": ["indexing"],
109117
"challenge": "append-no-conflicts-index-only",
110-
"track-params": "number_of_replicas:0",
118+
"track-params": {
119+
"number_of_replicas": 0
120+
},
111121
"car": "4gheap"
112122
},
113123
{
114124
"name": "geopoint-append-4g-3nodes",
115125
"label": "add-4g-3nodes",
116126
"charts": ["indexing"],
117127
"challenge": "append-no-conflicts-index-only",
118-
"track-params": "number_of_replicas:1",
128+
"track-params": {
129+
"number_of_replicas": 1
130+
},
119131
"car": "4gheap",
120132
"node-count": 3
121133
},
@@ -136,7 +148,9 @@
136148
"label": "add-defaults",
137149
"charts": ["indexing"],
138150
"challenge": "append-no-conflicts-index-only",
139-
"track-params": "number_of_replicas:0",
151+
"track-params": {
152+
"number_of_replicas": 0
153+
},
140154
"car": "defaults"
141155
},
142156
{
@@ -159,7 +173,9 @@
159173
"label": "add-4g-3nodes",
160174
"charts": ["indexing"],
161175
"challenge": "append-no-conflicts",
162-
"track-params": "number_of_replicas:1",
176+
"track-params": {
177+
"number_of_replicas": 1
178+
},
163179
"car": "4gheap",
164180
"node-count": 3
165181
},
@@ -168,9 +184,16 @@
168184
"label": "nio-4g-3nodes",
169185
"charts": ["indexing"],
170186
"challenge": "append-no-conflicts",
171-
"track-params": "number_of_replicas:1",
172-
"car": "4gheap,unpooled",
173-
"car-params": "{\\\"additional_cluster_settings\\\": {\\\"cache.recycler.page.limit.heap\\\": \\\"13.5%\\\",\\\"cache.recycler.page.weight.bytes\\\": 2}}",
187+
"track-params": {
188+
"number_of_replicas": 1
189+
},
190+
"car": ["4gheap", "unpooled"],
191+
"car-params": {
192+
"additional_cluster_settings": {
193+
"cache.recycler.page.limit.heap": "13.5%",
194+
"cache.recycler.page.weight.bytes": 2
195+
}
196+
},
174197
"plugins": "transport-nio:transport+http",
175198
"node-count": 3
176199
},
@@ -213,7 +236,9 @@
213236
"label": "add-sorted-4g",
214237
"charts": ["indexing"],
215238
"challenge": "append-sorted-no-conflicts-index-only",
216-
"track-params": "number_of_replicas:0",
239+
"track-params": {
240+
"number_of_replicas": 0
241+
},
217242
"car": "4gheap"
218243
},
219244
{
@@ -222,7 +247,12 @@
222247
"charts": ["indexing"],
223248
"challenge": "append-no-conflicts-index-only",
224249
"#COMMENT": "We need to be a bit more explicit here because nyc_taxis sets a bunch of other index settings as well which we don't want",
225-
"track-params": "{\\\"index_settings\\\": {\\\"index.number_of_replicas\\\": 1,\\\"index.number_of_shards\\\": 5}}",
250+
"track-params": {
251+
"index_settings": {
252+
"index.number_of_replicas": 1,
253+
"index.number_of_shards": 5
254+
}
255+
},
226256
"car": "4gheap",
227257
"node-count": 3
228258
}
@@ -236,7 +266,9 @@
236266
"label": "defaults",
237267
"charts": ["indexing"],
238268
"challenge": "append-no-conflicts-index-only",
239-
"track-params": "number_of_replicas:0",
269+
"track-params": {
270+
"number_of_replicas": 0
271+
},
240272
"car": "defaults"
241273
},
242274
{
@@ -251,7 +283,9 @@
251283
"label": "no-src-4g",
252284
"charts": ["indexing"],
253285
"challenge": "append-no-conflicts-index-only",
254-
"track-params": "source_enabled:false",
286+
"track-params": {
287+
"source_enabled": false
288+
},
255289
"car": "4gheap"
256290
},
257291
{
@@ -267,7 +301,9 @@
267301
"label": "3nodes-4g",
268302
"charts": ["indexing"],
269303
"challenge": "append-no-conflicts-index-only",
270-
"track-params": "number_of_replicas:1",
304+
"track-params": {
305+
"number_of_replicas": 1
306+
},
271307
"car": "4gheap",
272308
"node-count": 3
273309
},
@@ -283,7 +319,10 @@
283319
"label": "no-src-4g-grok",
284320
"charts": ["indexing"],
285321
"challenge": "append-index-only-with-ingest-pipeline",
286-
"track-params": "source_enabled:false,ingest_pipeline:'grok'",
322+
"track-params": {
323+
"source_enabled": false,
324+
"ingest_pipeline": "grok"
325+
},
287326
"car": "4gheap"
288327
}
289328
]

tests/night_rally_test.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def test_run_two_challenges_successfully(self, mocked_wait_until_port_is_free):
104104
"name": "geonames-defaults",
105105
"challenge": "append-no-conflicts",
106106
"car": "defaults",
107-
"car-params": "verbose_iw_logging_enabled:true"
107+
"car-params": {
108+
"verbose_iw_logging_enabled": "true"
109+
}
108110
},
109111
{
110112
"name": "geonames-4g",
@@ -124,7 +126,7 @@ def test_run_two_challenges_successfully(self, mocked_wait_until_port_is_free):
124126
"rally --skip-update --configuration-name=\"nightly\" --quiet --target-host=\"localhost:39200\" "
125127
"--effective-start-date=\"2016-01-01 00:00:00\" --track=\"geonames\" --challenge=\"append-no-conflicts\" "
126128
"--car=\"defaults\" --user-tag=\"env:bare,name:geonames-defaults\" --runtime-jdk=\"8\" "
127-
"--car-params=\"verbose_iw_logging_enabled:true\" --pipeline=\"from-sources-complete\" "
129+
"--car-params=\"{\\\"verbose_iw_logging_enabled\\\": \\\"true\\\"}\" --pipeline=\"from-sources-complete\" "
128130
"--revision=\"@2016-01-01T00:00:00Z\"",
129131

130132
"rally --skip-update --configuration-name=\"nightly\" --quiet --target-host=\"localhost:39200\" "
@@ -398,7 +400,7 @@ def test_run_release_benchmark_with_transport_nio(self, mocked_wait_until_port_i
398400
{
399401
"name": "geonames-defaults",
400402
"challenge": "append-no-conflicts",
401-
"car": "defaults",
403+
"car": ["defaults", "unpooled"],
402404
"plugins": "transport-nio:transport+http"
403405
}
404406
]
@@ -414,7 +416,7 @@ def test_run_release_benchmark_with_transport_nio(self, mocked_wait_until_port_i
414416
[
415417
"rally --skip-update --configuration-name=\"release\" --quiet --target-host=\"localhost:39200\" "
416418
"--effective-start-date=\"2016-01-01 00:00:00\" --track=\"geonames\" --challenge=\"append-no-conflicts\" "
417-
"--car=\"defaults\" --user-tag=\"env:bare,name:geonames-defaults\" --runtime-jdk=\"8\" "
419+
"--car=\"defaults,unpooled\" --user-tag=\"env:bare,name:geonames-defaults\" --runtime-jdk=\"8\" "
418420
"--elasticsearch-plugins=\"transport-nio:transport+http\" --distribution-version=\"7.0.0\" "
419421
"--pipeline=\"from-distribution\""
420422
]
@@ -487,7 +489,10 @@ def test_run_docker_5x_benchmark(self, mocked_wait_until_port_is_free):
487489
{
488490
"name": "geonames-4g",
489491
"challenge": "append-no-conflicts",
490-
"car": "4gheap"
492+
"car": "4gheap",
493+
"car-params": {
494+
"verbose_iw_logging_enabled": "true"
495+
}
491496
}
492497
]
493498
}
@@ -510,9 +515,10 @@ def test_run_docker_5x_benchmark(self, mocked_wait_until_port_is_free):
510515
"rally --skip-update --configuration-name=\"release\" --quiet --target-host=\"localhost:39200\" "
511516
"--effective-start-date=\"2016-01-01 00:00:00\" --track=\"geonames\" --challenge=\"append-no-conflicts\" "
512517
"--car=\"4gheap\" --user-tag=\"env:docker,name:geonames-4g\" --runtime-jdk=\"8\" "
513-
"--distribution-version=\"5.6.0\" --pipeline=\"docker\" --car-params=\"{\\\"additional_cluster_settings\\\": "
518+
"--car-params=\"{\\\"verbose_iw_logging_enabled\\\": \\\"true\\\", \\\"additional_cluster_settings\\\": "
514519
"{\\\"xpack.security.enabled\\\": \\\"false\\\", \\\"xpack.ml.enabled\\\": \\\"false\\\", "
515-
"\\\"xpack.monitoring.enabled\\\": \\\"false\\\", \\\"xpack.watcher.enabled\\\": \\\"false\\\"}}\""
520+
"\\\"xpack.monitoring.enabled\\\": \\\"false\\\", \\\"xpack.watcher.enabled\\\": \\\"false\\\"}}\" "
521+
"--distribution-version=\"5.6.0\" --pipeline=\"docker\""
516522
]
517523
,
518524
system_call.calls

0 commit comments

Comments
 (0)