Skip to content

Commit 6d59fdc

Browse files
Add parameter to specify ES plugins
With this commit we add a new command line parameter --elasticsearch-plugins to Night Rally. It will pass this parameter to Rally but also check whether we've specified "x-pack:security" as a plugin and will make the necessary adjustments (change expected cluster health and adjust the client options). Relates elastic#21
1 parent 8982252 commit 6d59fdc

File tree

3 files changed

+79
-6
lines changed

3 files changed

+79
-6
lines changed

night_rally.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ def __init__(self, revision, effective_start_date, target_host, root_dir, config
145145

146146

147147
class ReleaseCommand(BaseCommand):
148-
def __init__(self, effective_start_date, target_host, root_dir, distribution_version, configuration_name, tag):
148+
def __init__(self, effective_start_date, target_host, plugins, root_dir, distribution_version, configuration_name, tag):
149149
super().__init__(effective_start_date, target_host, root_dir)
150+
self.plugins = plugins
150151
self.configuration_name = configuration_name
151152
self.pipeline = "from-distribution"
152153
self.distribution_version = distribution_version
@@ -167,6 +168,12 @@ def command_line(self, track, challenge, car):
167168
"--user-tag=\"{9}\"".format(self.distribution_version, self.ts, track, challenge, car,
168169
self.report_path(track, challenge, car), self.pipeline,
169170
self.target_host, self.configuration_name, self.tag(), RALLY_BINARY)
171+
if self.plugins:
172+
cmd += " --elasticsearch-plugins=\"%s\"" % self.plugins
173+
if "x-pack:security" in self.plugins:
174+
cmd += " --cluster-health=yellow " \
175+
"--client-options=\"use_ssl:true,verify_certs:false,basic_auth_user:'rally',basic_auth_password:'rally-password'\""
176+
170177
return cmd
171178

172179
def tag(self):
@@ -352,6 +359,10 @@ def parse_args():
352359
"--target-host",
353360
help="The Elasticsearch node that should be targeted",
354361
required=True)
362+
parser.add_argument(
363+
"--elasticsearch-plugins",
364+
help="Elasticsearch plugins to install for the benchmark (default: None)",
365+
default=None)
355366
parser.add_argument(
356367
"--fixtures",
357368
help="A comma-separated list of fixtures that have been run",
@@ -391,8 +402,15 @@ def main():
391402
adhoc_mode = args.mode == "adhoc"
392403
nightly_mode = args.mode == "nightly"
393404

405+
plugins = args.elasticsearch_plugins
406+
394407
tag = args.tag
395-
release_tag = "env:ear" if "encryption-at-rest" in args.fixtures else "env:bare"
408+
if "encryption-at-rest" in args.fixtures:
409+
release_tag = "env:ear"
410+
elif "x-pack:security" in plugins:
411+
release_tag = "env:x-pack"
412+
else:
413+
release_tag = "env:bare"
396414
docker_benchmark = args.release.startswith("Docker ")
397415
release = args.release.replace("Docker ", "")
398416

@@ -403,20 +421,26 @@ def main():
403421
# use always the same name for release comparison benchmarks
404422
env_name = sanitize(args.mode)
405423
if docker_benchmark:
424+
if plugins:
425+
raise RuntimeError("User specified plugins [%s] but this is not supported for Docker benchmarks." % plugins)
406426
logger.info("Running Docker release benchmarks for release [%s] against [%s]." % (release, args.target_host))
407427
command = DockerCommand(args.effective_start_date, args.target_host, root_dir, release, env_name)
408428
tag = command.tag()
409429
else:
410430
logger.info("Running release benchmarks for release [%s] against [%s] (release tag is [%s])."
411431
% (release, args.target_host, release_tag))
412-
command = ReleaseCommand(args.effective_start_date, args.target_host, root_dir, release, env_name, release_tag)
432+
command = ReleaseCommand(args.effective_start_date, args.target_host, plugins, root_dir, release, env_name, release_tag)
413433
tag = command.tag()
414434
elif adhoc_mode:
435+
if plugins:
436+
raise RuntimeError("User specified plugins [%s] but this is not supported for adhoc benchmarks." % plugins)
415437
logger.info("Running adhoc benchmarks for revision [%s] against [%s]." % (args.revision, args.target_host))
416438
# copy data from templates directory to our dedicated output directory
417439
env_name = sanitize(args.release)
418440
command = AdHocCommand(args.revision, args.effective_start_date, args.target_host, root_dir, env_name, args.tag, args.override_src_dir)
419441
else:
442+
if plugins:
443+
raise RuntimeError("User specified plugins [%s] but this is not supported for nightly benchmarks." % plugins)
420444
logger.info("Running nightly benchmarks against [%s]." % args.target_host)
421445
env_name = NightlyCommand.CONFIG_NAME
422446
command = NightlyCommand(args.effective_start_date, args.target_host, root_dir, args.override_src_dir)

night_rally.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ RELEASE="master"
4343
REVISION="latest"
4444
TARGET_HOST="localhost:9200"
4545
TAG=""
46+
PLUGINS=""
4647

4748

4849
for i in "$@"
@@ -88,6 +89,10 @@ case ${i} in
8889
TARGET_HOST="${i#*=}"
8990
shift # past argument=value
9091
;;
92+
--elasticsearch-plugins=*)
93+
PLUGINS="${i#*=}"
94+
shift # past argument=value
95+
;;
9196
*)
9297
echo "unknown command line option passed to night_rally"
9398
exit 1
@@ -164,7 +169,7 @@ fi
164169
#****************************
165170
set +e
166171
# Avoid failing before we transferred all results. Usually only a single benchmark trial run fails but lots of other succeed.
167-
python3 ${NIGHT_RALLY_HOME}/night_rally.py --target-host=${TARGET_HOST} --effective-start-date="${START_DATE}" ${NIGHT_RALLY_OVERRIDE} --mode=${MODE} ${NIGHT_RALLY_DRY_RUN} --fixtures="${FIXTURES}" --revision="${REVISION}" --release="${RELEASE}" --tag="${TAG}"
172+
python3 ${NIGHT_RALLY_HOME}/night_rally.py --target-host=${TARGET_HOST} --elasticsearch-plugins="${PLUGINS}" --effective-start-date="${START_DATE}" ${NIGHT_RALLY_OVERRIDE} --mode=${MODE} ${NIGHT_RALLY_DRY_RUN} --fixtures="${FIXTURES}" --revision="${REVISION}" --release="${RELEASE}" --tag="${TAG}"
168173
exit_code=$?
169174

170175
echo "Killing any lingering Rally processes"

tests.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_run_adhoc_benchmark(self):
162162
system_call.calls
163163
)
164164

165-
def test_run_release_benchmark(self):
165+
def test_run_release_benchmark_without_plugins(self):
166166
system_call = RecordingSystemCall(return_value=False)
167167

168168
tracks = [
@@ -181,7 +181,7 @@ def test_run_release_benchmark(self):
181181
}
182182
]
183183
start_date = datetime.datetime(2016, 1, 1)
184-
cmd = night_rally.ReleaseCommand(start_date, "localhost", "/rally_root", "5.3.0", "release", tag="env:bare")
184+
cmd = night_rally.ReleaseCommand(start_date, "localhost", None, "/rally_root", "5.3.0", "release", tag="env:bare")
185185
night_rally.run_rally(tracks, cmd, system=system_call)
186186
self.assertEqual(2, len(system_call.calls))
187187
self.assertEqual(
@@ -202,6 +202,50 @@ def test_run_release_benchmark(self):
202202
system_call.calls
203203
)
204204

205+
def test_run_release_benchmark_with_plugins(self):
206+
system_call = RecordingSystemCall(return_value=False)
207+
208+
tracks = [
209+
{
210+
"track": "geonames",
211+
"combinations": [
212+
{
213+
"challenge": "append-no-conflicts",
214+
"car": "defaults"
215+
},
216+
{
217+
"challenge": "append-no-conflicts",
218+
"car": "4gheap"
219+
}
220+
]
221+
}
222+
]
223+
start_date = datetime.datetime(2016, 1, 1)
224+
cmd = night_rally.ReleaseCommand(start_date, "localhost", "x-pack:security,monitoring", "/rally_root", "5.3.0", "release",
225+
tag="env:x-pack")
226+
night_rally.run_rally(tracks, cmd, system=system_call)
227+
self.assertEqual(2, len(system_call.calls))
228+
self.assertEqual(
229+
[
230+
"rally --skip-update --configuration-name=release --target-host=localhost --pipeline=from-distribution --quiet "
231+
"--distribution-version=5.3.0 --effective-start-date \"2016-01-01 00:00:00\" --track=geonames "
232+
"--challenge=append-no-conflicts --car=defaults --report-format=csv "
233+
"--report-file=/rally_root/reports/rally/2016-01-01-00-00-00/geonames/append-no-conflicts/defaults/report.csv "
234+
"--user-tag=\"env:x-pack\" --elasticsearch-plugins=\"x-pack:security,monitoring\" --cluster-health=yellow "
235+
"--client-options=\"use_ssl:true,verify_certs:false,basic_auth_user:'rally',basic_auth_password:'rally-password'\"",
236+
237+
"rally --skip-update --configuration-name=release --target-host=localhost --pipeline=from-distribution --quiet "
238+
"--distribution-version=5.3.0 --effective-start-date \"2016-01-01 00:00:00\" --track=geonames "
239+
"--challenge=append-no-conflicts --car=4gheap --report-format=csv "
240+
"--report-file=/rally_root/reports/rally/2016-01-01-00-00-00/geonames/append-no-conflicts/4gheap/report.csv "
241+
"--user-tag=\"env:x-pack\" --elasticsearch-plugins=\"x-pack:security,monitoring\" --cluster-health=yellow "
242+
"--client-options=\"use_ssl:true,verify_certs:false,basic_auth_user:'rally',basic_auth_password:'rally-password'\"",
243+
]
244+
,
245+
system_call.calls
246+
)
247+
248+
205249
def test_run_docker_benchmark(self):
206250
system_call = RecordingSystemCall(return_value=False)
207251

0 commit comments

Comments
 (0)