Skip to content

Add Cluster Mode Enabled (CME) testing support#12

Open
detemmienation wants to merge 2 commits into
valkey-io:unstablefrom
detemmienation:cme
Open

Add Cluster Mode Enabled (CME) testing support#12
detemmienation wants to merge 2 commits into
valkey-io:unstablefrom
detemmienation:cme

Conversation

@detemmienation

Copy link
Copy Markdown

This PR implements CME (Cluster Mode Enabled) testing support, addressing issue #3.

What's added

Three classes in src/valkey_test_case.py:

  • ClusterInfo — exposes typed accessors over a CLUSTER INFO reply (is_cluster_ok, cluster_known_nodes, cluster_slots_assigned).
  • ClusterNodeHandle — a single cluster-mode node; wraps the standard CLUSTER commands (MEET / REPLICATE / ADDSLOTSRANGE) and the waiters for the cluster to converge.
  • ClusterTestCase — orchestrates bootstrap. setup_cluster(num_shards, num_replicas_per_shard) starts the nodes, gossips them together, evenly distributes the 16384 hash slots across primaries, optionally attaches replicas, waits for cluster_state:ok, and returns a topology-awareValkeyCluster client.

Cluster formation is done purely through standard CLUSTER commands, and it reuses the framework's existing port reservation, server lifecycle, and nodes.conf cleanup.

Tests

tests/test_cluster_mode.py:

  • 3-shard cluster: healthy state, all slots assigned, read/write through the cluster client.
  • Slot distribution (2/3/5 shards): CLUSTER SLOTS covers 0..16383 exactly once, no overlap.
  • Replica topologies (3-shard + 1-replica, 2-shard + 2-replica): attachment, online counts, read/write.

Signed-off-by: Tracy <yuningt@amazon.com>
Signed-off-by: Tracy <yuningt@amazon.com>
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