test: cluster command and CLI integration tests#80
Merged
Conversation
spawn_gossip and ClusterNode::new_primary were hardcoded to use +10000 for the gossip bus port. this caused panics on high port numbers (>55535) where the addition overflows u16. - add ClusterNode::new_primary_with_offset for custom bus port offsets - store gossip_port_offset in ClusterCoordinator - use the configured offset in spawn_gossip and cluster_meet - use wrapping_add to prevent overflow panics
- add cluster_enabled/cluster_bootstrap fields to ServerOptions - wire cluster flags into server spawn with small port offset - add cli_binary() and run_cli() helpers for CLI binary tests - refactor server_binary() into shared find_binary() helper
cluster tests (17): - query commands: info, nodes, slots, myid, keyslot - state-changing: addslots, delslots, forget - data routing: set/get on owned slot, clusterdown on empty - slot queries: countkeysinslot, getkeysinslot - stubs: replicate, failover, migrate, setslot importing - error handling: meet with invalid address cli tests (7): - one-shot: ping, set/get roundtrip, bad command error - cluster subcommands: cluster info, cluster keyslot - benchmark: smoke test with -n 100 -c 2 -q - error handling: connection refused on unused port
kacy
added a commit
that referenced
this pull request
Feb 11, 2026
* fix: respect --cluster-port-offset in gossip and node creation spawn_gossip and ClusterNode::new_primary were hardcoded to use +10000 for the gossip bus port. this caused panics on high port numbers (>55535) where the addition overflows u16. - add ClusterNode::new_primary_with_offset for custom bus port offsets - store gossip_port_offset in ClusterCoordinator - use the configured offset in spawn_gossip and cluster_meet - use wrapping_add to prevent overflow panics * test: add cluster and CLI options to integration test helpers - add cluster_enabled/cluster_bootstrap fields to ServerOptions - wire cluster flags into server spawn with small port offset - add cli_binary() and run_cli() helpers for CLI binary tests - refactor server_binary() into shared find_binary() helper * test: add cluster command and CLI integration tests cluster tests (17): - query commands: info, nodes, slots, myid, keyslot - state-changing: addslots, delslots, forget - data routing: set/get on owned slot, clusterdown on empty - slot queries: countkeysinslot, getkeysinslot - stubs: replicate, failover, migrate, setslot importing - error handling: meet with invalid address cli tests (7): - one-shot: ping, set/get roundtrip, bad command error - cluster subcommands: cluster info, cluster keyslot - benchmark: smoke test with -n 100 -c 2 -q - error handling: connection refused on unused port * docs: update test count to 886
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
adds 24 integration tests covering cluster command dispatch (17 tests) and CLI binary behavior (7 tests). also fixes a bug where
--cluster-port-offsetwas ignored.cluster tests cover the full surface: query commands (info, nodes, slots, myid, keyslot), state-changing commands (addslots, delslots, forget), data routing (owned slot set/get, clusterdown on empty cluster), slot introspection (countkeysinslot, getkeysinslot), stubs that return clean errors (replicate, failover, migrate, setslot importing), and error handling (meet with invalid address).
cli tests cover one-shot mode (ping, set/get roundtrip, bad command), cluster subcommands (info, keyslot), benchmark smoke test, and connection refused error handling.
bug fix:
spawn_gossipandClusterNode::new_primaryhad a hardcoded +10000 port offset for the gossip bus, ignoring--cluster-port-offset. this caused panics on ports >55535 where the addition overflows u16. now uses the configured offset everywhere.what was tested
cargo test --workspace --lib— 301 unit tests passcargo test --test integration— 69 integration tests pass (with--test-threads=4for stability; pre-existing flakiness at higher parallelism is unrelated)cargo clippy --workspace -- -D warnings— cleancargo fmt --all --check— cleandesign considerations
--cluster-port-offset 1to keep gossip ports in valid u16 range when the OS assigns high random data portsClusterNode::new_primary_with_offsetalongside the existingnew_primaryto avoid breaking the cluster crate's own unit tests which use low portsrun_clihelper) rather than importing the binary crate, testing the actual user-facing binary