-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tier-2): Lane A — SWAPDB, MOVE, COPY DB n, CLUSTER REPLICAS/SLAVES, COUNT-FAILURE-REPORTS #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c381b31
4958dc9
bbc6117
f538589
ebd240a
608e2d1
e429b2b
3267648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -540,6 +540,44 @@ both SET edge:touch "val" | |
| assert_both "TOUCH" TOUCH edge:touch | ||
| assert_both "TOUCH missing" TOUCH edge:nomiss | ||
|
|
||
| # =========================================================================== | ||
| # SWAPDB consistency | ||
| # =========================================================================== | ||
| log "=== SWAPDB ===" | ||
|
|
||
| # Seed: db0 has swapkey=hello, db1 is empty | ||
| both SELECT 0 | ||
| both SET swapkey hello | ||
| both SELECT 1 | ||
| both DEL swapkey | ||
|
|
||
| # SWAPDB 0 1 — swaps databases 0 and 1 | ||
| assert_both "SWAPDB 0 1" SWAPDB 0 1 | ||
|
|
||
| # After swap: db0 should be empty (swapkey gone), db1 should have swapkey=hello | ||
| redis_after_swap=$(redis-cli -p "$PORT_REDIS" -n 1 GET swapkey 2>&1) || true | ||
| rust_after_swap=$(redis-cli -p "$PORT_RUST" -n 1 GET swapkey 2>&1) || true | ||
| assert_eq "SWAPDB: key moved to db1" "$redis_after_swap" "$rust_after_swap" | ||
|
|
||
| redis_db0_gone=$(redis-cli -p "$PORT_REDIS" -n 0 GET swapkey 2>&1) || true | ||
| rust_db0_gone=$(redis-cli -p "$PORT_RUST" -n 0 GET swapkey 2>&1) || true | ||
| assert_eq "SWAPDB: key absent from db0" "$redis_db0_gone" "$rust_db0_gone" | ||
|
|
||
| # Same-index SWAPDB is a no-op; must return OK (not error) | ||
| assert_both "SWAPDB 0 0 (same-index no-op)" SWAPDB 0 0 | ||
|
|
||
| # Out-of-range indices must return ERR (not panic) | ||
| redis_oor=$(redis-cli -p "$PORT_REDIS" SWAPDB 0 9999 2>&1) || true | ||
| rust_oor=$(redis-cli -p "$PORT_RUST" SWAPDB 0 9999 2>&1) || true | ||
| if echo "$rust_oor" | grep -qi "ERR"; then | ||
| PASS=$((PASS + 1)) | ||
| else | ||
| FAIL=$((FAIL + 1)); echo " FAIL: SWAPDB out-of-range should return ERR, got: $rust_oor" | ||
| fi | ||
|
Comment on lines
+570
to
+576
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assert out-of-range parity against Redis (and use Line 570 captures Suggested fix redis_oor=$(redis-cli -p "$PORT_REDIS" SWAPDB 0 9999 2>&1) || true
rust_oor=$(redis-cli -p "$PORT_RUST" SWAPDB 0 9999 2>&1) || true
-if echo "$rust_oor" | grep -qi "ERR"; then
- PASS=$((PASS + 1))
-else
- FAIL=$((FAIL + 1)); echo " FAIL: SWAPDB out-of-range should return ERR, got: $rust_oor"
-fi
+assert_eq "SWAPDB out-of-range parity" "$redis_oor" "$rust_oor"🧰 Tools🪛 Shellcheck (0.11.0)[warning] 570-570: redis_oor appears unused. Verify use (or export if used externally). (SC2034) 🤖 Prompt for AI Agents |
||
|
|
||
| # Swap back to restore state for remaining tests | ||
| both SWAPDB 0 1 | ||
|
|
||
| # FLUSHDB (run last — clears all keys) | ||
| assert_both "FLUSHDB" FLUSHDB | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use explicit DB targeting when seeding SWAPDB state
both SELECT ...does not persist DB selection across laterredis-cliinvocations. On Line 552,DEL swapkeyruns against default DB 0, which can invalidate the intended seed and make the swap check non-representative.Suggested fix
🤖 Prompt for AI Agents