Follow these simple steps to test your distributed message broker:
go test ./... -vExpected output: All tests should pass ✅
go run ./cmd/broker -id node-1Expected output:
🚀 Starting Broker Node: node-1
gRPC: localhost:8080
Raft: localhost:9080
Metrics: localhost:9090/metrics
📊 Metrics server started on :9090
✅ Server ready!
Leave this running! Open a new terminal for the next steps.
In a new terminal:
go run ./examples/demoExpected output:
🚀 Broker Demo
1️⃣ Creating topic 'demo-topic'...
2️⃣ Producing single messages...
✅ Produced message 0 at offset 0
3️⃣ Consuming messages...
📖 Offset 0: Hello, World!
4️⃣ Batch producing 5 messages...
✅ Produced 5 records starting at offset 3
5️⃣ Batch consuming...
📖 Consumed 5 records
6️⃣ Listing topics...
📋 Topics: [demo-topic]
✅ Demo complete!
Open in browser or use curl:
# Health check
curl http://localhost:9090/health
# Metrics
curl http://localhost:9090/metricsgo run ./cmd/broker -id node-1 -grpc-port 8080 -raft-port 9080go run ./cmd/broker -id node-2 -grpc-port 8081 -raft-port 9081 -join localhost:8080go run ./cmd/broker -id node-3 -grpc-port 8082 -raft-port 9082 -join localhost:8080# Run demo (connects to node-1)
go run ./examples/demo
# Kill node-1 (Ctrl+C in Terminal 1)
# Wait ~5 seconds for leader election
# Demo still works with new leader!
go run ./examples/demogo test -v -run TestHighThroughput -timeout 2mProblem: Demo fails with "connection refused"
- Solution: Make sure broker is running first (Step 2)
Problem: Port already in use
- Solution: Clean up:
Remove-Item -Recurse -Force data
Problem: Tests fail
- Solution: Stop all brokers, then:
Remove-Item -Recurse -Force data
- ✅ Single message produce/consume
- ✅ Batch operations
- ✅ Topic management
- ✅ Consumer groups (in unit tests)
- ✅ Metrics & health checks
- ✅ Raft consensus
- ✅ Cluster join
- ✅ Leader election & failover
For detailed testing instructions, see TESTING.md