Skip to content

test: add a parity harness and doc checks for the Redis Store - #5

Closed
moetemp wants to merge 5 commits into
moe/brook/review/r3-writer-suitefrom
moe/brook/review/r4-test-harness
Closed

moetemp wants to merge 5 commits into
moe/brook/review/r3-writer-suitefrom
moe/brook/review/r4-test-harness

Conversation

@moetemp

@moetemp moetemp commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

What changed?

This PR adds tests that act as a harness for later changes to the Redis Store. A change that breaks a rule of the Store fails one of them before review.

  • tests/parity.rs runs the same seeded random calls on the memory Store and the Redis Store, and compares the answers. The calls cover creates, appends, closes, reads, reverse reads, retry-run withdrawals and Local Activity task facts. A refused write must also leave the Stream's Redis keys as they were. A failure prints its seed and its last calls, and STREAMS_PARITY_SEED=<seed> replays it.
  • docs/redis.md is now the only list of each role's commands. tests/acl.rs reads it, and a unit test checks that each role's scripts call exactly those commands. Another unit test checks that the docs' load command gives the read scripts' exact bytes.
  • A unit test checks that a Stream's four keys share one cluster slot for any id.
  • A cluster case checks that a standalone Store at a cluster node, with a user that has no +info, gets a config error.

Why?

Agents will make more of the changes to this crate. These tests check the rules that a reviewer would otherwise check by hand. Both Stores agree, a refusal writes nothing, and the docs match the scripts.

I checked each test against a deliberate bug, and each bug failed its test. The bugs were a script write before a refusal, a wrong resend answer, a read with one entry too many, a missing orphan item, a missing run fence, a command that the docs don't list, and a MOVED mapping that does nothing. A long parity run on standalone Redis and on a cluster found no difference between the Stores.

How did you test it?

crates/streams-redis/scripts/redis-test-servers.sh
STREAMS_PARITY_SEEDS=3000 cargo test -p temporalio-streams-redis --test parity -- --include-ignored
  • Unit Tests
  • Staging
  • End to End Tests

The ACL tests now read the role lists from docs/redis.md, and a unit test checks that each role's scripts call exactly those commands. So a script that calls a new command fails until the docs list it.
A cluster refuses a script with CROSSSLOT when a key falls outside the hash tag. The ids take the characters that a tag or a key uses.
…rror

A user with no INFO gets past connect, and then each key of another node gets MOVED. The case checks a write, a read and a blocking read.
Each seed runs the same random calls on both Stores and compares the answers. A refused write must also leave the Stream's Redis keys as they were, since Redis doesn't roll a script back.
A retry run's creates and appends withdraw the previous run, and Local Activities of three Workflow Tasks give random task facts. These rules are the longest part of the append script.
@moetemp

moetemp commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

These tests are now in the stack, so each PR has the tests of its own code. The docs checks, the slot check, the standalone case and the parity check are on #1, from 18ae3e3 to 40c9b9a. The withdrawal part of the parity check is on #2 in 11adf65. #3 has all of it through its merge.

@moetemp moetemp closed this Nov 5, 2026
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