Skip to content

Commit

Permalink
Add additional cluster config support in OSD integTest (#3590)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon authored Jun 1, 2023
1 parent 822fd36 commit aceb8b4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ def execute_tests(self) -> TestComponentResults:

def __setup_cluster_and_execute_test_config(self, config: str) -> int:
security = self.is_security_enabled(config)
if "additional-cluster-configs" in self.test_config.integ_test.keys():
self.additional_cluster_config = self.test_config.integ_test.get("additional-cluster-configs")
logging.info(f"Additional config found: {self.additional_cluster_config}")

with LocalTestClusterOpenSearchDashboards.create(
self.dependency_installer,
self.dependency_installer_opensearch_dashboards,
self.work_dir,
self.component.name,
{},
self.additional_cluster_config,
self.bundle_manifest,
self.bundle_manifest_opensearch_dashboards,
security,
Expand Down
5 changes: 5 additions & 0 deletions src/test_workflow/integ_test/service_opensearch_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def start(self) -> None:

self.__set_logging_dest()

# Newer version of NodeJS (16/18) might introduced bug when running test against localhost using cypress
# https://github.com/cypress-io/github-action/issues/811
# Temporarily set these additional configs to resolve the issue
self.additional_config["server.host"] = '0.0.0.0'

if self.additional_config:
self.__add_plugin_specific_config(self.additional_config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setUp(self) -> None:

self.test_config = MagicMock()
self.test_config.working_directory = "test_working_directory"
self.test_config.integ_test = {"test-configs": ['with-security', 'without-security']}
self.test_config.integ_test = {"test-configs": ['with-security', 'without-security'], "additional-cluster-configs": {'server.host': '0.0.0.0'}}

self.bundle_manifest_opensearch = MagicMock()
self.bundle_manifest_opensearch.build.version = "1.2.0"
Expand Down Expand Up @@ -93,6 +93,8 @@ def test_execute_tests(self, mock_execute: Mock, mock_git: Mock, mock_test_resul
call("test_endpoint", 1234, False, "without-security")
])

self.assertEqual(str(suite.additional_cluster_config), "{'server.host': '0.0.0.0'}")

# test base class

@patch("os.path.exists")
Expand Down Expand Up @@ -150,6 +152,7 @@ def test_execute_integtest_sh(self, mock_execute: Mock, mock_git: Mock, mock_tes
}
)
assert(mock_test_result_data.return_value in suite.result_data)
self.assertEqual(suite.additional_cluster_config, None)

@patch("os.path.exists")
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.TestResultData")
Expand Down Expand Up @@ -188,6 +191,7 @@ def test_execute_integtest_sh_script_do_not_exist(self, mock_execute: Mock, mock
mock_execute.assert_not_called()
mock_test_result_data.assert_not_called()
self.save_logs.assert_not_called()
self.assertEqual(suite.additional_cluster_config, None)

@patch("os.path.exists")
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.TestResultData")
Expand Down Expand Up @@ -226,6 +230,8 @@ def test_is_security_enabled(self, mock_execute: Mock, mock_git: Mock, mock_test

self.assertEqual(str(ctx.exception), "Unsupported test config: random-config")

self.assertEqual(suite.additional_cluster_config, None)

@patch("test_workflow.integ_test.integ_test_suite.logging")
@patch("os.path.exists")
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.TestResultData")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def test_start(self, mock_tarfile_open: Mock, mock_dump: Mock, mock_file: Mock,
mock_dump.assert_called_once_with(
{
"script.context.field.max_compilations_rate": "1000/1m",
"logging.dest": os.path.join(self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log")
"logging.dest": os.path.join(self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log"),
"server.host": "0.0.0.0"
}
)
mock_file.return_value.write.assert_called_once_with(mock_dump_result)
Expand Down Expand Up @@ -131,7 +132,7 @@ def test_start_without_security(self, mock_tarfile_open: Mock, mock_dump: Mock,
)

mock_dump.assert_called_once_with({"logging.dest": os.path.join(
self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log")})
self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log"), 'server.host': '0.0.0.0'})

mock_file_handler_for_security.close.assert_called_once()
mock_file_handler_for_additional_config.write.assert_called_once_with(mock_dump_result)
Expand Down Expand Up @@ -193,7 +194,7 @@ def test_start_without_security_and_not_installed(
)

mock_dump.assert_called_once_with({"logging.dest": os.path.join(
self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log")})
self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log"), 'server.host': '0.0.0.0'})

mock_file_handler_for_security.close.assert_called_once()
mock_file_handler_for_additional_config.write.assert_called_once_with(mock_dump_result)
Expand Down

0 comments on commit aceb8b4

Please sign in to comment.