This guide provides comprehensive redis-cli commands and testing procedures for manually validating HyperCache's distributed functionality.
- Prerequisites
- Connection Commands
- Basic Operations
- Replication Testing
- Advanced Test Scenarios
- Complete Manual Test Script
- Expected Behaviors
- Troubleshooting
-
Start the HyperCache cluster:
./scripts/build-and-run.sh cluster
-
Wait for cluster formation:
sleep 5
-
Ensure redis-cli is installed:
# On macOS brew install redis # Or check if already installed which redis-cli
# Node 1 - RESP Protocol (Port 8080)
redis-cli -h localhost -p 8080
# Node 2 - RESP Protocol (Port 8081)
redis-cli -h localhost -p 8081
# Node 3 - RESP Protocol (Port 8082)
redis-cli -h localhost -p 8082# Ping each node
redis-cli -h localhost -p 8080 ping
redis-cli -h localhost -p 8081 ping
redis-cli -h localhost -p 8082 ping
# Expected response: PONG# Connect to any node (e.g., Node 1)
redis-cli -h localhost -p 8080
# Basic SET commands
127.0.0.1:8080> SET user:1 "John Doe"
127.0.0.1:8080> SET user:2 "Jane Smith"
127.0.0.1:8080> SET counter 42
127.0.0.1:8080> SET config:timeout 300
127.0.0.1:8080> SET session:abc123 "active_user_session"
# Expected response for each: OK# Get the values back
127.0.0.1:8080> GET user:1
# Expected: "John Doe"
127.0.0.1:8080> GET user:2
# Expected: "Jane Smith"
127.0.0.1:8080> GET counter
# Expected: "42"
127.0.0.1:8080> GET config:timeout
# Expected: "300"
127.0.0.1:8080> GET session:abc123
# Expected: "active_user_session"
# Test non-existent key
127.0.0.1:8080> GET nonexistent
# Expected: (nil)# Delete single keys
127.0.0.1:8080> DEL user:1
# Expected: (integer) 1
127.0.0.1:8080> DEL counter
# Expected: (integer) 1
# Verify deletion
127.0.0.1:8080> GET user:1
# Expected: (nil)
127.0.0.1:8080> GET counter
# Expected: (nil)
# Delete multiple keys at once
127.0.0.1:8080> SET temp1 "value1"
127.0.0.1:8080> SET temp2 "value2"
127.0.0.1:8080> SET temp3 "value3"
127.0.0.1:8080> DEL temp1 temp2 temp3
# Expected: (integer) 3
# Verify multiple deletion
127.0.0.1:8080> GET temp1
127.0.0.1:8080> GET temp2
127.0.0.1:8080> GET temp3
# All should return: (nil)redis-cli -h localhost -p 8080
127.0.0.1:8080> SET replication:test "from_node_1"
127.0.0.1:8080> SET cluster:data "distributed_value"
127.0.0.1:8080> SET node1:exclusive "created_on_node1"redis-cli -h localhost -p 8081
# Should be able to read data set on Node 1
127.0.0.1:8081> GET replication:test
# Expected: "from_node_1"
127.0.0.1:8081> GET cluster:data
# Expected: "distributed_value"
127.0.0.1:8081> GET node1:exclusive
# Expected: "created_on_node1"
# Set data from Node 2
127.0.0.1:8081> SET node2:exclusive "only_on_node2"redis-cli -h localhost -p 8082
# Should be able to read data from both Node 1 and Node 2
127.0.0.1:8082> GET replication:test
# Expected: "from_node_1"
127.0.0.1:8082> GET cluster:data
# Expected: "distributed_value"
127.0.0.1:8082> GET node2:exclusive
# Expected: "only_on_node2"
# Set data from Node 3
127.0.0.1:8082> SET node3:data "from_third_node"# Terminal 1 (Node 1) - Set a key
redis-cli -h localhost -p 8080
127.0.0.1:8080> SET delete:test "will_be_deleted"
# Terminal 2 (Node 2) - Verify it exists
redis-cli -h localhost -p 8081
127.0.0.1:8081> GET delete:test
# Expected: "will_be_deleted"
# Terminal 3 (Node 3) - Delete the key
redis-cli -h localhost -p 8082
127.0.0.1:8082> DEL delete:test
# Expected: (integer) 1
# Terminal 1 (Node 1) - Verify deletion replicated
127.0.0.1:8080> GET delete:test
# Expected: (nil)
# Terminal 2 (Node 2) - Verify deletion replicated
127.0.0.1:8081> GET delete:test
# Expected: (nil)# Connect to Node 1
redis-cli -h localhost -p 8080
# Set multiple keys that should distribute across nodes
127.0.0.1:8080> SET user:001 "Alice"
127.0.0.1:8080> SET user:002 "Bob"
127.0.0.1:8080> SET user:003 "Charlie"
127.0.0.1:8080> SET user:004 "Diana"
127.0.0.1:8080> SET user:005 "Eve"
127.0.0.1:8080> SET product:laptop "MacBook Pro"
127.0.0.1:8080> SET product:phone "iPhone"
127.0.0.1:8080> SET config:app "production"
# Verify all keys are accessible from any node
# Connect to Node 2
redis-cli -h localhost -p 8081
127.0.0.1:8081> GET user:001
127.0.0.1:8081> GET user:002
127.0.0.1:8081> GET product:laptop
127.0.0.1:8081> GET config:app
# Connect to Node 3
redis-cli -h localhost -p 8082
127.0.0.1:8082> GET user:003
127.0.0.1:8082> GET user:004
127.0.0.1:8082> GET product:phone
127.0.0.1:8082> GET config:app# Terminal 1 (Node 1)
redis-cli -h localhost -p 8080
127.0.0.1:8080> SET concurrent:key1 "from_node1"
# Terminal 2 (Node 2) - Simultaneously
redis-cli -h localhost -p 8081
127.0.0.1:8081> SET concurrent:key2 "from_node2"
# Terminal 3 (Node 3) - Simultaneously
redis-cli -h localhost -p 8082
127.0.0.1:8082> SET concurrent:key3 "from_node3"
# Verify all operations succeeded and replicated
# From any terminal:
GET concurrent:key1
GET concurrent:key2
GET concurrent:key3
# All should return their respective values# 1. Start the cluster
./scripts/build-and-run.sh cluster
# 2. Wait for cluster formation
sleep 5
# 3. Test basic connectivity
redis-cli -h localhost -p 8080 ping
redis-cli -h localhost -p 8081 ping
redis-cli -h localhost -p 8082 ping
# 4. Open 3 terminals for concurrent testingredis-cli -h localhost -p 8080
# Basic operations
SET test:key1 "value_from_node1"
SET shared:data "replicated_value"
SET numbers:one 1
GET test:key1
GET shared:dataredis-cli -h localhost -p 8081
# Verify replication
GET test:key1
# Expected: "value_from_node1"
GET shared:data
# Expected: "replicated_value"
# Add more data
SET test:key2 "value_from_node2"
SET numbers:two 2redis-cli -h localhost -p 8082
# Verify all data is available
GET test:key1
# Expected: "value_from_node1"
GET test:key2
# Expected: "value_from_node2"
GET shared:data
# Expected: "replicated_value"
# Test deletion
DEL test:key1
DEL numbers:one# Verify deletions replicated
GET test:key1
# Expected: (nil)
GET numbers:one
# Expected: (nil)
# Verify other data still exists
GET test:key2
# Expected: "value_from_node2"
GET shared:data
# Expected: "replicated_value"# 1. Set some data
redis-cli -h localhost -p 8080
SET persist:test "should_survive_restart"
SET persist:counter 100
SET persist:config "important_setting"
# 2. Stop cluster
./scripts/build-and-run.sh stop
# 3. Restart cluster
./scripts/build-and-run.sh cluster
sleep 5
# 4. Reconnect and verify data persisted
redis-cli -h localhost -p 8080
GET persist:test
# Expected: "should_survive_restart"
GET persist:counter
# Expected: "100"
GET persist:config
# Expected: "important_setting"- SET commands: Return
OK - GET commands: Return the stored value or
(nil)for non-existent keys - DEL commands: Return
(integer) Nwhere N is the number of keys deleted - Replication: Data set on one node should be readable from all nodes
- Delete Replication: Keys deleted from one node should be removed from all nodes
- Persistence: Data should survive cluster restarts (if persistence enabled)
- Connectivity:
PINGshould returnPONG
- Connection refused: Node might not be running or wrong port
- Data not replicated: Check cluster formation and event bus
- Inconsistent data: Possible replication lag or failure
- Keys not deleted everywhere: DELETE replication issue
- Data lost after restart: Persistence not working or not enabled
# Check if nodes are running
ps aux | grep hypercache
# Check which ports are in use
lsof -i :8080
lsof -i :8081
lsof -i :8082
# Try connecting with timeout
redis-cli -h localhost -p 8080 --connect-timeout 5 ping# Check startup logs
tail -f node1_startup.log
tail -f node2_startup.log
tail -f node3_startup.log
# Stop and restart cluster
./scripts/build-and-run.sh stop
sleep 2
./scripts/build-and-run.sh cluster# Check the same key from all nodes
redis-cli -h localhost -p 8080 GET test:key
redis-cli -h localhost -p 8081 GET test:key
redis-cli -h localhost -p 8082 GET test:key
# If values differ, there's a replication issue# Test with redis-benchmark (if available)
redis-benchmark -h localhost -p 8080 -t set,get -n 1000 -c 10
# Or manual performance test
redis-cli -h localhost -p 8080 --latency# Get server info (if implemented)
redis-cli -h localhost -p 8080 INFO
# Test with different data types
SET string:test "hello"
SET number:test 42
# Batch operations
redis-cli -h localhost -p 8080 --pipe < commands.txt# Stop cluster when done testing
./scripts/build-and-run.sh stop
# Clean up persistence data
./scripts/clean-persistence.sh
# Full cleanup
./scripts/final-cleanup.sh| Command | Purpose |
|---|---|
SET key value |
Store a key-value pair |
GET key |
Retrieve value for a key |
DEL key [key ...] |
Delete one or more keys |
PING |
Test connection |
INFO |
Get server information |
| Node | RESP Port | HTTP Port |
|---|---|---|
| Node 1 | 8080 | 9080 |
| Node 2 | 8081 | 9081 |
| Node 3 | 8082 | 9082 |
This comprehensive guide should help you thoroughly test your HyperCache distributed functionality using redis-cli!