-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Benchmark] Add mechanism to retreive the logs from test-execution.json #4686
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import logging | ||
import os | ||
import subprocess | ||
from typing import Union | ||
|
||
import yaml | ||
|
@@ -42,8 +43,10 @@ def run_tests(self) -> None: | |
cluster = BenchmarkTestCluster(self.args) | ||
cluster.start() | ||
benchmark_test_suite = BenchmarkTestSuite(cluster.endpoint_with_port, self.security, self.args, cluster.fetch_password()) | ||
retry_call(benchmark_test_suite.execute, tries=3, delay=60, backoff=2) | ||
|
||
try: | ||
retry_call(benchmark_test_suite.execute, tries=3, delay=60, backoff=2) | ||
finally: | ||
subprocess.check_call(f"docker rm docker-container-{self.args.stack_suffix}", cwd=os.getcwd(), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
else: | ||
config = yaml.safe_load(self.args.config) | ||
|
||
|
@@ -53,4 +56,7 @@ def run_tests(self) -> None: | |
with WorkingDirectory(current_workspace): | ||
with BenchmarkCreateCluster.create(self.args, self.test_manifest, config, current_workspace) as test_cluster: | ||
benchmark_test_suite = BenchmarkTestSuite(test_cluster.endpoint_with_port, self.security, self.args, test_cluster.fetch_password()) | ||
retry_call(benchmark_test_suite.execute, tries=3, delay=60, backoff=2) | ||
try: | ||
benchmark_test_suite.execute() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove retry_call? |
||
finally: | ||
subprocess.check_call(f"docker rm docker-container-{self.args.stack_suffix}", cwd=os.getcwd(), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,17 @@ | |
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import glob | ||
import json | ||
import logging | ||
import os | ||
import shutil | ||
import subprocess | ||
from typing import Any | ||
|
||
import pandas as pd | ||
|
||
from system.temporary_directory import TemporaryDirectory | ||
from test_workflow.benchmark_test.benchmark_args import BenchmarkArgs | ||
|
||
|
||
|
@@ -37,7 +43,7 @@ def __init__( | |
self.password = password | ||
|
||
# Pass the cluster endpoints with -t for multi-cluster use cases(e.g. cross-cluster-replication) | ||
self.command = 'docker run --rm' | ||
self.command = f'docker run --name docker-container-{self.args.stack_suffix}' | ||
if self.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} " \ | ||
|
@@ -67,11 +73,27 @@ def __init__( | |
if self.args.telemetry_params: | ||
self.command += f" --telemetry-params '{self.args.telemetry_params}'" | ||
|
||
def execute(self) -> None: | ||
if self.security: | ||
self.command += f' --client-options="timeout:300,use_ssl:true,verify_certs:false,basic_auth_user:\'{self.args.username}\',basic_auth_password:\'{self.password}\'"' | ||
else: | ||
self.command += ' --client-options="timeout:300"' | ||
|
||
def execute(self) -> None: | ||
log_info = f"Executing {self.command.replace(self.endpoint, len(self.endpoint) * '*').replace(self.args.username, len(self.args.username) * '*')}" | ||
logging.info(log_info.replace(self.password, len(self.password) * '*') if self.password else log_info) | ||
subprocess.check_call(f"{self.command}", cwd=os.getcwd(), shell=True) | ||
with TemporaryDirectory() as work_dir: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this file processing logic a new method and call that method only in the case endpoint is provided. This way the existing nightly runs will not be affected and we can enable it whenever we are ready. |
||
subprocess.check_call(f"docker cp docker-container-{self.args.stack_suffix}:opensearch-benchmark/. {str(work_dir.path)}", cwd=os.getcwd(), shell=True) | ||
file_path = glob.glob(os.path.join(str(work_dir.path), "test_executions", "*", "test_execution.json")) | ||
self.convert(file_path[0]) | ||
|
||
def convert(self, results: str) -> None: | ||
with open(results) as file: | ||
data = json.load(file) | ||
formatted_data = pd.json_normalize(data["results"]["op_metrics"]) | ||
formatted_data.to_csv(os.path.join(os.getcwd(), "test_execution.csv"), index=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename the csv file to |
||
df = pd.read_csv(os.path.join(os.getcwd(), "test_execution.csv")) | ||
pd.set_option('display.width', int(2 * shutil.get_terminal_size().columns)) | ||
pd.set_option('display.max_rows', None) | ||
pd.set_option('display.max_columns', None) | ||
logging.info(f"\n{df}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the
docker rm
command to BenchmarkTestSuite class to a method likeremove_container
or whatever you like and then use that?