Skip to content

Commit

Permalink
Enhance health checks and test reliability
Browse files Browse the repository at this point in the history
- Added assertions for master and worker health in `daemon.py`
- Increased test repetition count in `test_daemon.py` for stability
- Wrapped test assertions in a try-finally block for better debugging

These changes improve the system's robustness and reliability 🛠️.
Health checks ensure system components are functioning correctly,
while the enhanced test suite stability helps catch intermittent issues.
  • Loading branch information
horta committed Dec 6, 2024
1 parent aa70aa0 commit bbabe25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions h3daemon/h3daemon/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def healthy(self) -> bool:
try:
if self._process:
assert self._process.is_running()
assert self._master.healthy()
assert self._worker.healthy()
assert_peers_healthy(self._master, self._worker)
except Exception as exception:
debug_exception(exception)
Expand Down
20 changes: 11 additions & 9 deletions h3daemon/tests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import h3daemon


@pytest.mark.repeat(30)
@pytest.mark.repeat(100)
def test_hmmer(tmp_path, files_path: Path):
os.chdir(tmp_path)
debug_file = Path(tmp_path / "h3daemon_debug.txt")
Expand All @@ -18,12 +18,14 @@ def test_hmmer(tmp_path, files_path: Path):
os.environ["H3DAEMON_DEBUG_FILE"] = str(debug_file)

shutil.copy(files_path / "minifam.hmm", Path("minifam.hmm"))
hmmfile = HMMFile(path=Path("minifam.hmm"))

pidfile = h3daemon.spawn(hmmfile, detach=False, force=True)
daemon = h3daemon.possess(pidfile)
daemon.wait_for_readiness()
print(f"daemon.port(): {daemon.port()}")
daemon.shutdown()
with open(debug_file, "r") as f:
print(f.read())
try:
hmmfile = HMMFile(path=Path("minifam.hmm"))
pidfile = h3daemon.spawn(hmmfile, detach=False, force=True)
daemon = h3daemon.possess(pidfile)
daemon.wait_for_readiness()
print(f"daemon.port(): {daemon.port()}")
daemon.shutdown()
finally:
with open(debug_file, "r") as f:
print(f.read())

0 comments on commit bbabe25

Please sign in to comment.