test(examples): retry background sidecar on transient port-bind flake#1101
Conversation
`test_demo_actor` flakes when the demo-actor sidecar, started via `DaprRunner.start()`, loses a random-port race at boot: daprd assigns the same port to its API and internal gRPC servers, the internal listener fails with "bind: address already in use", and the runtime exits with "could not listen on any endpoint". The actor host is then dead, so the client's `invoke_method` fails with "did not find address for actor" and the expected output never appears. PR dapr#1030 already added this retry to the foreground `run()` path, but the background `start()` path was left uncovered. Apply the same exponential backoff retry there, reusing the existing failure markers. The captured log is only read once the process has exited (`poll()` is not None), so a healthy long-lived sidecar is never inspected and its append offset is left untouched. Adds unit tests mirroring the existing `run()` coverage. Fixes dapr#1061 Signed-off-by: Kshitiz Jain <kshitizj@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1101 +/- ##
==========================================
- Coverage 86.63% 82.15% -4.48%
==========================================
Files 84 116 +32
Lines 4473 9578 +5105
==========================================
+ Hits 3875 7869 +3994
- Misses 598 1709 +1111 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR reduces flakes in the examples test suite by making DaprRunner.start() resilient to a known transient Dapr sidecar startup failure (random-port bind collision), mirroring the retry behavior already implemented for DaprRunner.run().
Changes:
- Add exponential-backoff retry logic to
DaprRunner.start()when startup output matches the existing port-bind failure markers. - Add unit tests covering the retry and non-retry paths for
start()using a background-process stand-in.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/examples/conftest.py |
Adds port-bind collision retry logic to DaprRunner.start() and introduces a helper to detect the failure safely for background sidecars. |
tests/examples/test_dapr_runner.py |
Adds unit tests for start() retry behavior and introduces a fake background process for deterministic output simulation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@holopin-bot @kshitizj03 sdk-badge Thank you! Here's a digital badge as a small token of appreciation. |
|
Congratulations @kshitizj03, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cmr98z3sf0007jb0aqah46u4j This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
Description
test_demo_actorflakes when the demo-actor sidecar, started viaDaprRunner.start(), loses a random-port race at boot: daprd assigns the same port to its API and internal gRPC servers, the internal listener fails with "bind: address already in use", and the runtime exits with "could not listen on any endpoint". The actor host is then dead, so the client'sinvoke_methodfails with "did not find address for actor" and the expected output never appears.PR #1030 already added this retry to the foreground
run()path, but the backgroundstart()path was left uncovered. This applies the same exponential backoff retry there, reusing the existing failure markers. The captured log is only read once the process has exited (poll()is not None), so a healthy long-lived sidecar is never inspected and its append offset is left untouched.Adds unit tests mirroring the existing
run()coverage.Fixes #1061
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: