Skip to content

Commit

Permalink
Update check cluster readiness
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed Nov 27, 2024
1 parent 6adc380 commit 03c7e58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/test_workflow/smoke_test/smoke_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ def run(self) -> Any:
logging.info("Initiating smoke tests.")
test_cluster = SmokeTestClusterOpenSearch(self.args, os.path.join(work_dir.path), self.test_recorder)
test_cluster.__start_cluster__(os.path.join(work_dir.path))
is_cluster_ready = False
for i in range(10):
logging.info(f"Attempt {i} of 10 to check cluster.")
if test_cluster.__check_cluster_ready__():
is_cluster_ready = True
break
else:
time.sleep(10)
time.sleep(10)
try:
if test_cluster.__check_cluster_ready__():
if is_cluster_ready:
results_data = self.start_test(work_dir.path)
else:
logging.info("Cluster is not ready after 10 attempts.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_run(self, mock_temp_dir: Mock, mock_cluster: Mock, mock_recorder: Mock)
mock_cluster_instance = mock_cluster.return_value
mock_cluster_instance.__start_cluster__ = MagicMock()
mock_cluster_status = MagicMock()
mock_cluster_status.side_effect = [False, True, True] # Fails first check, passes second
mock_cluster_status.side_effect = [False, True] # Fails first check, passes second
mock_cluster_instance.__check_cluster_ready__ = mock_cluster_status
mock_cluster_instance.__uninstall__ = MagicMock()

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

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

# Assert result returned from start_test
Expand Down

0 comments on commit 03c7e58

Please sign in to comment.