Skip to content

test: cluster command and CLI integration tests#80

Merged
kacy merged 4 commits intomainfrom
test/cluster-cli-integration
Feb 10, 2026
Merged

test: cluster command and CLI integration tests#80
kacy merged 4 commits intomainfrom
test/cluster-cli-integration

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented Feb 10, 2026

summary

adds 24 integration tests covering cluster command dispatch (17 tests) and CLI binary behavior (7 tests). also fixes a bug where --cluster-port-offset was 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_gossip and ClusterNode::new_primary had 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 pass
  • cargo test --test integration — 69 integration tests pass (with --test-threads=4 for stability; pre-existing flakiness at higher parallelism is unrelated)
  • cargo clippy --workspace -- -D warnings — clean
  • cargo fmt --all --check — clean

design considerations

  • cluster test servers use --cluster-port-offset 1 to keep gossip ports in valid u16 range when the OS assigns high random data ports
  • added ClusterNode::new_primary_with_offset alongside the existing new_primary to avoid breaking the cluster crate's own unit tests which use low ports
  • cli tests use subprocess invocation (run_cli helper) rather than importing the binary crate, testing the actual user-facing binary

kacy added 4 commits February 10, 2026 08:33
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 kacy merged commit 2a000eb into main Feb 10, 2026
7 checks passed
@kacy kacy deleted the test/cluster-cli-integration branch February 10, 2026 14:18
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
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