Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces system tests for the Bigtable Accelerator daemon, covering daemon startup behaviors and error handling scenarios (including fallback to native clients, midflight daemon termination, timeout enforcement, and error type matching) for both asynchronous and synchronous autogenerated paths. The feedback recommends wrapping daemon startup and assertions in try...finally blocks within test_daemon_startup.py to guarantee proper cleanup of daemon processes and prevent resource leaks in case of test failures.
| daemon = AcceleratorDaemon(_FLAGS, binary_path=path) | ||
| with pytest.raises(RuntimeError, match="spawn"): | ||
| _harness.call_with_timeout(daemon.start, timeout=5.0) | ||
| _harness.force_kill_daemon(daemon) |
There was a problem hiding this comment.
If an unexpected exception is raised or if the assertion fails, _harness.force_kill_daemon(daemon) will not be executed, potentially leaking the daemon process. Wrapping the startup and assertion in a try...finally block ensures that the daemon is always cleaned up properly, preventing resource leaks in the test environment.
| daemon = AcceleratorDaemon(_FLAGS, binary_path=path) | |
| with pytest.raises(RuntimeError, match="spawn"): | |
| _harness.call_with_timeout(daemon.start, timeout=5.0) | |
| _harness.force_kill_daemon(daemon) | |
| daemon = AcceleratorDaemon(_FLAGS, binary_path=path) | |
| try: | |
| with pytest.raises(RuntimeError, match="spawn"): | |
| _harness.call_with_timeout(daemon.start, timeout=5.0) | |
| finally: | |
| _harness.force_kill_daemon(daemon) |
| daemon = AcceleratorDaemon(_FLAGS, binary_path=path) | ||
| started = time.monotonic() | ||
| with pytest.raises(RuntimeError, match="exited during startup"): | ||
| _harness.call_with_timeout(daemon.start, timeout=5.0) | ||
| elapsed = time.monotonic() - started | ||
| assert elapsed < 3.0, f"exit-during-startup took {elapsed:.2f}s; not prompt" | ||
| _harness.force_kill_daemon(daemon) |
There was a problem hiding this comment.
Similar to the previous test, if any assertion fails or an unexpected exception occurs, the daemon process will not be killed. Wrapping this block in a try...finally ensures reliable cleanup of the daemon process.
| daemon = AcceleratorDaemon(_FLAGS, binary_path=path) | |
| started = time.monotonic() | |
| with pytest.raises(RuntimeError, match="exited during startup"): | |
| _harness.call_with_timeout(daemon.start, timeout=5.0) | |
| elapsed = time.monotonic() - started | |
| assert elapsed < 3.0, f"exit-during-startup took {elapsed:.2f}s; not prompt" | |
| _harness.force_kill_daemon(daemon) | |
| daemon = AcceleratorDaemon(_FLAGS, binary_path=path) | |
| started = time.monotonic() | |
| try: | |
| with pytest.raises(RuntimeError, match="exited during startup"): | |
| _harness.call_with_timeout(daemon.start, timeout=5.0) | |
| elapsed = time.monotonic() - started | |
| assert elapsed < 3.0, f"exit-during-startup took {elapsed:.2f}s; not prompt" | |
| finally: | |
| _harness.force_kill_daemon(daemon) |
Add Cloud Bigtable accelerator daemon startup fault-injection (
test_daemon_startup.py) and end-to-end error handling / mid-flight crash fallback system tests (test_error_handling_async.py,test_error_handling_autogen.py).Part of Stack #18691 (stacked on #18789).