|
3 | 3 | import logging
|
4 | 4 | import os
|
5 | 5 | import pathlib
|
| 6 | +import re |
6 | 7 | import sys
|
| 8 | +import traceback |
7 | 9 |
|
8 | 10 | import yaml
|
9 | 11 | from python_terraform import Terraform
|
10 | 12 | from redistimeseries.client import Client
|
11 | 13 |
|
| 14 | +from redisbench_admin.run.redis_benchmark.redis_benchmark import prepareRedisBenchmarkCommand |
| 15 | +from redisbench_admin.run.run import redis_benchmark_ensure_min_version |
12 | 16 | from redisbench_admin.utils.benchmark_config import (
|
13 | 17 | parseExporterMetricsDefinition,
|
14 | 18 | parseExporterTimeMetricDefinition,
|
15 | 19 | parseExporterTimeMetric,
|
16 | 20 | )
|
| 21 | +from redisbench_admin.utils.local import prepareRedisGraphBenchmarkGoCommand |
17 | 22 | from redisbench_admin.utils.redisgraph_benchmark_go import (
|
18 | 23 | spinUpRemoteRedis,
|
19 | 24 | setupRemoteBenchmark,
|
@@ -261,16 +266,59 @@ def run_remote_command_logic(args):
|
261 | 266 | local_benchmark_output_filename
|
262 | 267 | )
|
263 | 268 | )
|
| 269 | + |
| 270 | + benchmark_tool = None |
| 271 | + benchmark_min_tool_version = None |
| 272 | + benchmark_min_tool_version_major = None |
| 273 | + benchmark_min_tool_version_minor = None |
| 274 | + benchmark_min_tool_version_patch = None |
| 275 | + for entry in benchmark_config["clientconfig"]: |
| 276 | + benchmark_min_tool_version, benchmark_min_tool_version_major, benchmark_min_tool_version_minor, benchmark_min_tool_version_patch, benchmark_tool = extract_tool_info( |
| 277 | + benchmark_min_tool_version, benchmark_min_tool_version_major, |
| 278 | + benchmark_min_tool_version_minor, benchmark_min_tool_version_patch, benchmark_tool, entry) |
| 279 | + if benchmark_tool is not None: |
| 280 | + logging.info("Detected benchmark config tool {}".format(benchmark_tool)) |
| 281 | + else: |
| 282 | + raise Exception("Unable to detect benchmark tool within 'clientconfig' section. Aborting...") |
| 283 | + |
| 284 | + if benchmark_tool not in args.allowed_tools.split(","): |
| 285 | + raise Exception( |
| 286 | + "Benchmark tool {} not in the allowed tools list [{}]. Aborting...".format(benchmark_tool, |
| 287 | + args.allowed_tools)) |
| 288 | + |
| 289 | + if benchmark_min_tool_version is not None and benchmark_tool == "redis-benchmark": |
| 290 | + redis_benchmark_ensure_min_version(benchmark_tool, benchmark_min_tool_version, |
| 291 | + benchmark_min_tool_version_major, |
| 292 | + benchmark_min_tool_version_minor, |
| 293 | + benchmark_min_tool_version_patch) |
| 294 | + |
| 295 | + for entry in benchmark_config["clientconfig"]: |
| 296 | + if 'parameters' in entry: |
| 297 | + if benchmark_tool == 'redis-benchmark': |
| 298 | + command = prepareRedisBenchmarkCommand( |
| 299 | + "redis-benchmark", |
| 300 | + server_private_ip, |
| 301 | + server_plaintext_port, |
| 302 | + entry |
| 303 | + ) |
| 304 | + if benchmark_tool == 'redisgraph-benchmark-go': |
| 305 | + print(entry) |
| 306 | + command = prepareRedisGraphBenchmarkGoCommand( |
| 307 | + "/tmp/redisgraph-benchmark-go", |
| 308 | + server_private_ip, |
| 309 | + server_plaintext_port, |
| 310 | + entry, |
| 311 | + remote_results_file, |
| 312 | + ) |
| 313 | + |
264 | 314 | # run the benchmark
|
265 | 315 | runRemoteBenchmark(
|
266 | 316 | client_public_ip,
|
267 | 317 | username,
|
268 | 318 | private_key,
|
269 |
| - server_private_ip, |
270 |
| - server_plaintext_port, |
271 |
| - benchmark_config, |
272 | 319 | remote_results_file,
|
273 | 320 | local_benchmark_output_filename,
|
| 321 | + command |
274 | 322 | )
|
275 | 323 |
|
276 | 324 | # check KPIs
|
@@ -362,10 +410,32 @@ def run_remote_command_logic(args):
|
362 | 410 | "Some unexpected exception was caught during remote work. Failing test...."
|
363 | 411 | )
|
364 | 412 | logging.critical(sys.exc_info()[0])
|
| 413 | + print("-" * 60) |
| 414 | + traceback.print_exc(file=sys.stdout) |
| 415 | + print("-" * 60) |
365 | 416 | finally:
|
366 | 417 | # tear-down
|
367 | 418 | logging.info("Tearing down setup")
|
368 | 419 | tf_output = tf.destroy()
|
369 | 420 | logging.info("Tear-down completed")
|
370 | 421 |
|
371 | 422 | exit(return_code)
|
| 423 | + |
| 424 | + |
| 425 | +def extract_tool_info(benchmark_min_tool_version, benchmark_min_tool_version_major, benchmark_min_tool_version_minor, |
| 426 | + benchmark_min_tool_version_patch, benchmark_tool, entry): |
| 427 | + if 'tool' in entry: |
| 428 | + benchmark_tool = entry['tool'] |
| 429 | + if 'min-tool-version' in entry: |
| 430 | + benchmark_min_tool_version = entry['min-tool-version'] |
| 431 | + p = re.compile("(\d+)\.(\d+)\.(\d+)") |
| 432 | + m = p.match(benchmark_min_tool_version) |
| 433 | + if m is None: |
| 434 | + logging.error( |
| 435 | + "Unable to extract semversion from 'min-tool-version'. Will not enforce version") |
| 436 | + benchmark_min_tool_version = None |
| 437 | + else: |
| 438 | + benchmark_min_tool_version_major = m.group(1) |
| 439 | + benchmark_min_tool_version_minor = m.group(2) |
| 440 | + benchmark_min_tool_version_patch = m.group(3) |
| 441 | + return benchmark_min_tool_version, benchmark_min_tool_version_major, benchmark_min_tool_version_minor, benchmark_min_tool_version_patch, benchmark_tool |
0 commit comments