Skip to content

Commit 03c7e58

Browse files
committed
Update check cluster readiness
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
1 parent 6adc380 commit 03c7e58

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/test_workflow/smoke_test/smoke_test_runner.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ def run(self) -> Any:
6565
logging.info("Initiating smoke tests.")
6666
test_cluster = SmokeTestClusterOpenSearch(self.args, os.path.join(work_dir.path), self.test_recorder)
6767
test_cluster.__start_cluster__(os.path.join(work_dir.path))
68+
is_cluster_ready = False
6869
for i in range(10):
6970
logging.info(f"Attempt {i} of 10 to check cluster.")
7071
if test_cluster.__check_cluster_ready__():
72+
is_cluster_ready = True
7173
break
72-
else:
73-
time.sleep(10)
74+
time.sleep(10)
7475
try:
75-
if test_cluster.__check_cluster_ready__():
76+
if is_cluster_ready:
7677
results_data = self.start_test(work_dir.path)
7778
else:
7879
logging.info("Cluster is not ready after 10 attempts.")

tests/tests_test_workflow/test_smoke_workflow/smoke_test/test_smoke_test_runner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_run(self, mock_temp_dir: Mock, mock_cluster: Mock, mock_recorder: Mock)
7272
mock_cluster_instance = mock_cluster.return_value
7373
mock_cluster_instance.__start_cluster__ = MagicMock()
7474
mock_cluster_status = MagicMock()
75-
mock_cluster_status.side_effect = [False, True, True] # Fails first check, passes second
75+
mock_cluster_status.side_effect = [False, True] # Fails first check, passes second
7676
mock_cluster_instance.__check_cluster_ready__ = mock_cluster_status
7777
mock_cluster_instance.__uninstall__ = MagicMock()
7878

@@ -81,7 +81,7 @@ def test_run(self, mock_temp_dir: Mock, mock_cluster: Mock, mock_recorder: Mock)
8181

8282
# Assert cluster start, ready check, and uninstall were called
8383
mock_cluster_instance.__start_cluster__.assert_called_once_with("/mock/temp/path")
84-
self.assertEqual(mock_cluster_instance.__check_cluster_ready__.call_count, 3) # Attempted twice
84+
self.assertEqual(mock_cluster_instance.__check_cluster_ready__.call_count, 2) # Attempted twice
8585
mock_cluster_instance.__uninstall__.assert_called_once()
8686

8787
# Assert result returned from start_test

0 commit comments

Comments
 (0)