Skip to content

Commit

Permalink
Save json to the workspace
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
Divyaasm committed Jun 27, 2024
1 parent 009e2bb commit 401b161
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/test_workflow/benchmark_test/benchmark_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def convert(self) -> None:
with TemporaryDirectory() as work_dir:
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"))
shutil.copy(file_path[0], os.path.join(os.getcwd(), f"test_execution_{self.args.stack_suffix}.json"))
with open(file_path[0]) as file:
data = json.load(file)
formatted_data = pd.json_normalize(data["results"]["op_metrics"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ def test_execute_cluster_endpoint(self, mock_convert: Mock, mock_check_call: Moc
@patch('builtins.open')
@patch('logging.info')
@patch('shutil.get_terminal_size')
@patch('shutil.copy')
@patch('test_workflow.benchmark_test.benchmark_test_suite.subprocess.check_call')
def test_convert(self, mock_check_call: Mock, mock_get_terminal_size: Mock, mock_logging_info: Mock, mock_open: Mock, mock_json_load: Mock, mock_read_csv: Mock,
def test_convert(self, mock_check_call: Mock, mock_copy: Mock, mock_get_terminal_size: Mock, mock_logging_info: Mock, mock_open: Mock, mock_json_load: Mock, mock_read_csv: Mock,
mock_json_normalize: Mock) -> None:
self.args.cluster_endpoint = "abc.com"
mock_get_terminal_size.return_value = MagicMock(columns=80)
Expand All @@ -241,6 +242,7 @@ def test_convert(self, mock_check_call: Mock, mock_get_terminal_size: Mock, mock
mock_glob.return_value = ['/mock/test_execution.json']
test_suite.convert()
mock_temp_directory.assert_called_once()
mock_copy.assert_called_once()
mock_check_call.assert_called_with(f"docker cp docker-container-{test_suite.args.stack_suffix}:opensearch-benchmark/. /mock/temp/dir", cwd=os.getcwd(), shell=True)
mock_open.assert_called_once_with("/mock/test_execution.json")
mock_json_load.assert_called_once()
Expand Down

0 comments on commit 401b161

Please sign in to comment.