Skip to content

fix(tests): use portpicker for ephemeral port in default_role_integration_test#933

Open
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2947-fix-flaky-port-8085
Open

fix(tests): use portpicker for ephemeral port in default_role_integration_test#933
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2947-fix-flaky-port-8085

Conversation

@AlexMikhalev

Copy link
Copy Markdown
Contributor

Summary

  • Replaces hardcoded port 8085 in terraphim_server/tests/default_role_integration_test.rs with portpicker::pick_unused_port().
  • portpicker is already a crate dependency (in [dependencies], used by tests/server.rs).
  • No other changes — one-line root cause, minimal diff.

Root cause

"127.0.0.1:8085".parse().unwrap() is a fixed address. When the OS kernel has not fully released the port from a previous test run, TcpListener::bind fails with EADDRINUSE (os error 98), producing a flaky Server error: ApiError(500, Address already in use). The pattern was already established correctly in tests/server.rs.

Verification

cargo test -p terraphim_server --test default_role_integration_test
# running 2 tests
# test test_default_role_config_structure ... ok
# test test_default_role_ripgrep_integration ... ok
# test result: ok. 2 passed; 0 failed; 0 ignored
cargo clippy -p terraphim_server -- -D warnings  # clean
cargo fmt --all -- --check                        # clean

Refs terraphim/terraphim-ai#2947 (Gitea)

…tion_test

Hardcoded port 8085 caused intermittent "Address already in use (os error 98)"
failures when the OS had not yet released the port from a prior test run.
Replace with portpicker::pick_unused_port() following the pattern already used
in tests/server.rs. portpicker is already a crate dependency.

Refs #2947

Co-Authored-By: Terraphim AI <noreply@terraphim.ai>
@AlexMikhalev AlexMikhalev force-pushed the task/2947-fix-flaky-port-8085 branch from 8b626dd to 757c68b Compare June 26, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant