fix(ssh-console): avoid test port allocation race#4142
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughSSH and metrics servers now report their actual bound socket addresses. ChangesBound Address Propagation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai full review. |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/ssh-console/tests/util/ssh_console_test_helper.rs (1)
97-98: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the runtime-bound addresses.
Assert that both returned ports are non-zero and that clients can connect using the addresses reported by
SpawnHandle; this protects the port-zero propagation contract from regressing.As per path instructions, prioritize missing tests for changed behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/ssh-console/tests/util/ssh_console_test_helper.rs` around lines 97 - 98, Add regression coverage near the existing SpawnHandle setup for listen_address and metrics_address: assert each reported port is non-zero, then connect clients using both returned addresses and verify the connections succeed. Keep the test focused on validating runtime-assigned port propagation through SpawnHandle.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/ssh-console/tests/util/ssh_console_test_helper.rs`:
- Around line 97-98: Add regression coverage near the existing SpawnHandle setup
for listen_address and metrics_address: assert each reported port is non-zero,
then connect clients using both returned addresses and verify the connections
succeed. Keep the test focused on validating runtime-assigned port propagation
through SpawnHandle.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 8d011ab7-afc9-46e9-b25c-55f291549169
📒 Files selected for processing (4)
crates/ssh-console/src/lib.rscrates/ssh-console/src/metrics.rscrates/ssh-console/src/ssh_server.rscrates/ssh-console/tests/util/ssh_console_test_helper.rs
Summary
SpawnHandleRoot cause
The test helper previously bound
127.0.0.1:0, recorded the selected port, dropped the listener, and later askedssh_console::spawnto bind that port again. Parallel tests or another process could claim the released port in between, intermittently causingAddress already in usefailures such as the metrics-listener failure in this CI run.Binding port
0in the actual SSH and metrics servers removes that time-of-check/time-of-use window. Configured nonzero production addresses retain their existing behavior.Validation
cargo fmt --all -- --checkgit diff --checkcargo test -p carbide-ssh-console --no-default-featuresreached the crate but is blocked on macOS by existing Linux-specifictermios/ioctlassumptions inio_util.rsx86_64-linux-gnu-gcctoolchain required by crypto dependenciesThe Linux CI integration suite will provide the full runtime validation.