Skip to content

Commit

Permalink
Initial empty dictionary for None additional cluster configs in OSD I…
Browse files Browse the repository at this point in the history
…ntegTest (#3593)

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Jun 2, 2023
1 parent aceb8b4 commit b2e8af3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def __setup_cluster_and_execute_test_config(self, config: str) -> int:
self.additional_cluster_config = self.test_config.integ_test.get("additional-cluster-configs")
logging.info(f"Additional config found: {self.additional_cluster_config}")

if self.additional_cluster_config is None:
self.additional_cluster_config = {}

with LocalTestClusterOpenSearchDashboards.create(
self.dependency_installer,
self.dependency_installer_opensearch_dashboards,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ 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'], "additional-cluster-configs": {'server.host': '0.0.0.0'}}
self.test_config.integ_test = {"test-configs": ['with-security', 'without-security']}

self.test_config_additional_config = MagicMock()
self.test_config_additional_config.working_directory = "test_working_directory"
self.test_config_additional_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 +97,58 @@ 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), "{}")

@patch("os.chdir")
@patch("os.path.exists")
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.TestResultData")
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.GitRepository")
@patch("test_workflow.integ_test.integ_test_suite_opensearch_dashboards.execute", return_value=True)
def test_execute_tests_additional_config(self, mock_execute: Mock, mock_git: Mock, mock_test_result_data: Mock, mock_localTestClusterOSD: Mock, mock_path_exists: Mock, *mock: Any) -> None:
mock_find = MagicMock()
mock_find.return_value = "./integtest.sh"

ScriptFinder.find_integ_test_script = mock_find # type: ignore

mock_git_object = MagicMock()
mock_git_object.dir = "https://test.github.com"
mock_git.return_value = mock_git_object

mock_execute.return_value = ("test_status", "test_stdout", "")

mock_test_result_data_object = MagicMock()
mock_test_result_data.return_value = mock_test_result_data_object

mock_path_exists.return_value = True

mock_create = MagicMock()
mock_create.return_value.__enter__.return_value = ("test_endpoint", 1234)
LocalTestClusterOpenSearchDashboards.create = mock_create # type: ignore

suite = IntegTestSuiteOpenSearchDashboards(
self.dependency_installer_opensearch,
self.dependency_installer_opensearch_dashboards,
self.component,
self.test_config_additional_config,
self.bundle_manifest_opensearch,
self.bundle_manifest_opensearch_dashboards,
self.build_manifest_opensearch,
self.build_manifest_opensearch_dashboards,
self.work_dir,
self.test_recorder
)

mock_execute_integtest_sh = MagicMock()
suite.execute_integtest_sh = mock_execute_integtest_sh # type: ignore

# call the test target
suite.execute_tests()

mock_execute_integtest_sh.assert_has_calls([
call("test_endpoint", 1234, True, "with-security"),
call("test_endpoint", 1234, False, "without-security")
])

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

# test base class
Expand Down

0 comments on commit b2e8af3

Please sign in to comment.