Skip to content

Commit aceb8b4

Browse files
Add additional cluster config support in OSD integTest (#3590)
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent 822fd36 commit aceb8b4

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/test_workflow/integ_test/integ_test_suite_opensearch_dashboards.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ def execute_tests(self) -> TestComponentResults:
8080

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

8487
with LocalTestClusterOpenSearchDashboards.create(
8588
self.dependency_installer,
8689
self.dependency_installer_opensearch_dashboards,
8790
self.work_dir,
8891
self.component.name,
89-
{},
92+
self.additional_cluster_config,
9093
self.bundle_manifest,
9194
self.bundle_manifest_opensearch_dashboards,
9295
security,

src/test_workflow/integ_test/service_opensearch_dashboards.py

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def start(self) -> None:
5050

5151
self.__set_logging_dest()
5252

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

tests/tests_test_workflow/test_integ_workflow/integ_test/test_integ_test_suite_opensearch_dashboards.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setUp(self) -> None:
2929

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

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

96+
self.assertEqual(str(suite.additional_cluster_config), "{'server.host': '0.0.0.0'}")
97+
9698
# test base class
9799

98100
@patch("os.path.exists")
@@ -150,6 +152,7 @@ def test_execute_integtest_sh(self, mock_execute: Mock, mock_git: Mock, mock_tes
150152
}
151153
)
152154
assert(mock_test_result_data.return_value in suite.result_data)
155+
self.assertEqual(suite.additional_cluster_config, None)
153156

154157
@patch("os.path.exists")
155158
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.TestResultData")
@@ -188,6 +191,7 @@ def test_execute_integtest_sh_script_do_not_exist(self, mock_execute: Mock, mock
188191
mock_execute.assert_not_called()
189192
mock_test_result_data.assert_not_called()
190193
self.save_logs.assert_not_called()
194+
self.assertEqual(suite.additional_cluster_config, None)
191195

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

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

233+
self.assertEqual(suite.additional_cluster_config, None)
234+
229235
@patch("test_workflow.integ_test.integ_test_suite.logging")
230236
@patch("os.path.exists")
231237
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.TestResultData")

tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch_dashboards.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def test_start(self, mock_tarfile_open: Mock, mock_dump: Mock, mock_file: Mock,
6767
mock_dump.assert_called_once_with(
6868
{
6969
"script.context.field.max_compilations_rate": "1000/1m",
70-
"logging.dest": os.path.join(self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log")
70+
"logging.dest": os.path.join(self.work_dir, "opensearch-dashboards-1.1.0", "logs", "opensearch_dashboards.log"),
71+
"server.host": "0.0.0.0"
7172
}
7273
)
7374
mock_file.return_value.write.assert_called_once_with(mock_dump_result)
@@ -131,7 +132,7 @@ def test_start_without_security(self, mock_tarfile_open: Mock, mock_dump: Mock,
131132
)
132133

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

136137
mock_file_handler_for_security.close.assert_called_once()
137138
mock_file_handler_for_additional_config.write.assert_called_once_with(mock_dump_result)
@@ -193,7 +194,7 @@ def test_start_without_security_and_not_installed(
193194
)
194195

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

198199
mock_file_handler_for_security.close.assert_called_once()
199200
mock_file_handler_for_additional_config.write.assert_called_once_with(mock_dump_result)

0 commit comments

Comments
 (0)