Skip to content

Commit 5d28677

Browse files
bsetoclaude
andcommitted
docs: add test harness usage to README
Document the local development test harness including: - Prerequisites (Docker, yq, jq) - Quick start commands (make up/down) - Configuration options (cluster.yaml) - Example topologies - Available make targets - Troubleshooting tips Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent fe8a841 commit 5d28677

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,112 @@ $ ./_build/kvctl migrate slot 123 --target 1 -n test-ns -c test-cluster
118118

119119
For the HTTP API, you can find the [HTTP API(work in progress)](docs/API.md) for more details.
120120

121+
## Local Development Test Harness
122+
123+
A config-driven test harness for quickly spinning up KVRocks clusters with any topology. Useful for integration testing, debugging, and local development.
124+
125+
### Prerequisites
126+
127+
- Docker and Docker Compose
128+
- [yq](https://github.com/mikefarah/yq) (YAML processor) - `brew install yq`
129+
- [jq](https://jqlang.github.io/jq/) (JSON processor) - `brew install jq`
130+
131+
### Quick Start
132+
133+
```bash
134+
# Start a cluster with default config (3 shards, 1 replica per shard)
135+
make up
136+
137+
# Verify the cluster is ready
138+
redis-cli -p 7770 CLUSTER NODES
139+
redis-cli -p 7770 CLUSTER INFO
140+
141+
# Tear down the cluster
142+
make down
143+
```
144+
145+
### Configuration
146+
147+
Edit `harness/config/cluster.yaml` to customize your cluster topology:
148+
149+
```yaml
150+
# Number of shards (hash slots distributed across these)
151+
shards: 3
152+
153+
# Replicas per shard (0 = primary only, 1 = primary + 1 replica, etc.)
154+
replicas_per_shard: 1
155+
156+
# Base port for KVRocks nodes (allocates sequentially: 7770, 7771, ...)
157+
base_port: 7770
158+
159+
# Cluster name (used in kvrocks-controller)
160+
name: test-cluster
161+
162+
# Namespace (for kvrocks-controller organization)
163+
namespace: default
164+
```
165+
166+
### Examples
167+
168+
**Single-shard cluster with 2 replicas (1 primary + 2 replicas):**
169+
```yaml
170+
shards: 1
171+
replicas_per_shard: 2
172+
```
173+
174+
**Multi-shard cluster for testing slot migration:**
175+
```yaml
176+
shards: 3
177+
replicas_per_shard: 1
178+
```
179+
180+
**Minimal cluster for quick tests:**
181+
```yaml
182+
shards: 1
183+
replicas_per_shard: 0
184+
```
185+
186+
### Available Commands
187+
188+
| Command | Description |
189+
|---------|-------------|
190+
| `make up` | Start the cluster (generates compose, starts services, initializes cluster) |
191+
| `make down` | Stop and remove all containers and volumes |
192+
| `make generate` | Regenerate docker-compose.yml from config |
193+
| `make validate-config` | Validate cluster.yaml configuration |
194+
195+
### Architecture
196+
197+
The test harness creates:
198+
- **Consul** - Storage backend for kvrocks-controller
199+
- **kvrocks-controller** - Cluster management (built from source)
200+
- **KVRocks nodes** - One container per node with proper isolation
201+
202+
All services have health checks, and `make up` blocks until everything is healthy and the cluster is initialized.
203+
204+
### Troubleshooting
205+
206+
**Check service status:**
207+
```bash
208+
docker compose -p kvrocks-harness -f harness/generated/docker-compose.yml ps
209+
```
210+
211+
**View controller logs:**
212+
```bash
213+
docker logs kvrocks-controller
214+
```
215+
216+
**View KVRocks node logs:**
217+
```bash
218+
docker logs kvrocks-0-0
219+
```
220+
221+
**Connect to a specific node:**
222+
```bash
223+
redis-cli -p 7770 # First node
224+
redis-cli -p 7771 # Second node
225+
```
226+
121227
## License
122228

123229
Licensed under the [Apache License, Version 2.0](LICENSE)

0 commit comments

Comments
 (0)