-
Notifications
You must be signed in to change notification settings - Fork 281
/
Copy pathbenchmark_test_suite.py
60 lines (50 loc) · 2.11 KB
/
benchmark_test_suite.py
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
# 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.
import logging
import os
import subprocess
from typing import Any
from test_workflow.benchmark_test.benchmark_args import BenchmarkArgs
class BenchmarkTestSuite:
endpoint: str
security: bool
current_workspace: str
args: BenchmarkArgs
command: str
"""
Represents a performance test suite. This class runs rally test on the deployed cluster with the provided IP.
"""
def __init__(
self,
endpoint: Any,
security: bool,
args: BenchmarkArgs,
) -> None:
self.endpoint = endpoint
self.security = security
self.args = args
# Pass the cluster endpoints with -t for multi-cluster use cases(e.g. cross-cluster-replication)
self.command = 'docker run --rm'
if args.benchmark_config:
self.command += f" -v {args.benchmark_config}:/opensearch-benchmark/.benchmark/benchmark.ini"
self.command += f" opensearchproject/opensearch-benchmark:latest execute-test --workload={self.args.workload} " \
f"--pipeline=benchmark-only --target-hosts={endpoint}"
if args.workload_params:
logging.info(f"Workload Params are {args.workload_params}")
self.command += f" --workload-params \"{args.workload_params}\""
if args.user_tag:
user_tag = f"--user-tag=\"{args.user_tag}\""
self.command += f" {user_tag}"
if args.capture_node_stat:
self.command += " --telemetry node-stats"
def execute(self) -> None:
if self.security:
self.command += ' --client-options="timeout:300,use_ssl:true,verify_certs:false,basic_auth_user:\'admin\',basic_auth_password:\'admin\'"'
else:
self.command += ' --client-options="timeout:300"'
logging.info(f"Executing {self.command}")
subprocess.check_call(f"{self.command}", cwd=os.getcwd(), shell=True)