Repository navigation
Description
Problem or Motivation
The project fake fakeredis[valkey]==2.40.0 (pyproject.toml:113) answers unknown command 'eval', and valkey-py Lock.release() fails with unknown command 'evalsha', because lupa is not installed. Every valkey-py lock and every limits moving window uses Lua. The move of Service state into Valkey depends on both.
docs/TESTING.md:242 says that the Valkey fake "has no contract suite yet", and docs/TESTING.md:83 says "A fake without a contract suite does not merge".
Proposed Solution & Architectural Design
- Add the
luaextra of fakeredis (lupa) to the test dependencies. - Add a contract suite that runs the same cases against the fake and against a real
valkey-serverbinary. The suite finds the binary onPATHand skips where it is missing (the CI rule for a missing host capability). Do not add a new pin tosrc/devops_cli/tools_lock/tools.lock: refactor(security): tools are found on PATH and not in tools.lock #4362 and chore(tools): remove devops install-tools and tools.lock #4363 move tools out of it. - Cases:
SET NX EX,EXAT,HINCRBY,ZADDand trims, valkey-pyLockacquire, extend,owned()and release, and alimitsmoving windowhit. - Keep the suite fast. The local test row is over its time budget today (chore(ci): the local test row takes over 5 minutes #4405, in flight); state the added seconds in the pull request.
Target Subsystem
Workstation Caching & Valkey (tests: tests/, docs/TESTING.md).
Existing Tool Considered
fakeredis with lupa, and the Valkey release binary. A live Valkey in pytest is refused by the network block. Cost: about 80,000 tokens and 4 hours to build, about 5,000 tokens a month to keep, about 10,000 tokens to fix.
Acceptance Criteria
- The suite passes against the fake, and against the real binary where the binary is on
PATH, in the devcontainer and on the GitHub runner. docs/TESTING.md:242lists the Valkey fake as covered.- The pull request states the time that the suite adds to the test row.
Dependencies
None.
Source: #4517
Proposed design
Problem statement
The Valkey fake cannot answer Lua commands because lupa is absent. Every valkey-py lock and every limits moving window uses Lua. Tests of the move of Service state into Valkey fail. The project requires a contract suite for each fake. This change adds the lua extra and a contract suite for the Valkey fake.
Acceptance criteria
Requirement: Lua extra is installed
The test dependency declaration SHALL enable the lua extra of fakeredis[valkey]==2.40.0 so that lupa installs.
Scenario: The fake answers EVAL and EVALSHA
- WHEN The test environment installs the dependencies from
pyproject.toml. - THEN
import lupasucceeds, and the Valkey fake answersEVALandEVALSHAwithoutunknown command.
Requirement: Contract suite runs both sides
The Valkey contract suite MUST run each case against the in-memory fake and against a real valkey-server binary when the binary is on PATH.
Scenario: The real binary is absent
- WHEN
valkey-serveris not onPATH. - THEN The fake cases run and pass, and the real-server cases skip with a reason that names the missing binary.
Requirement: Contract cases cover Lua users
The contract suite MUST cover SET NX EX, EXAT, HINCRBY, ZADD trims, valkey-py Lock acquire, extend, owned(), release, and a limits moving-window hit.
Scenario: Each case matches on both sides
- WHEN Each contract case runs against the fake and against the real binary.
- THEN Both sides return the same result and leave the same stored state.
Requirement: Documentation marks the fake covered
docs/TESTING.md SHALL list the Valkey fake as covered by tests/valkey/test_valkey_contract.py and SHALL remove the statement that it has no contract suite.
Scenario: The testing guide names the suite
- WHEN A reader opens the Valkey paragraph in
docs/TESTING.md. - THEN The paragraph names the contract suite and no longer says
has no contract suite yet.
Requirement: Pull request records the added time
The pull request body MUST state the measured seconds that the contract suite adds to the local test row.
Scenario: The author records the measurement
- WHEN The pull request is opened.
- THEN The body contains the measured added seconds and the command that measured them.
Existing Tool Considered
No alternatives check has run. fakeredis with the lua extra (lupa) covers EVAL and EVALSHA in the in-memory fake. The Valkey release binary covers the real server side. fakeredis lacks full parity with a real server. The suite therefore runs each case against both. If the project builds its own fake, the cost is about 80,000 tokens and 4 hours to build. It is about 5,000 tokens a month to keep and about 10,000 tokens to fix.
Key questions
- How does the Valkey fake get Lua support?: Add the
luaextra to the pinnedfakeredis[valkey]dependency. This installslupawith the test dependencies. Do not write a Lua shim. (best practice) [sources: pyproject.toml:113, docs/TESTING.md:242, tests/support/fakes/valkey.py]- Chosen: fakeredis lua extra.
fakeredisdocuments the extra, and it installs the missinglupaat the pinned version. - Rejected: Build a Lua shim. It duplicates a maintained library and carries the 80,000-token build cost.
- Rejected: Run a live Valkey in pytest. The test network block refuses a live service.
- Chosen: fakeredis lua extra.
- Where does the Valkey contract suite live?: Put it in
tests/valkey/test_valkey_contract.py. The name follows the contract-suite convention and stays beside the Valkey tests. (best practice) [sources: docs/TESTING.md, tests/commands/test_valkey.py]- Chosen: tests/valkey/test_valkey_contract.py. It follows the naming of the other fake contract suites and stays beside the Valkey tests.
- Rejected: tests/support/fakes/test_valkey_contract.py. The support checks keep test modules out of
tests/support/.
- How does the suite find the real Valkey server?: Use
shutil.which("valkey-server")to find the binary. Start it on a loopback port for the real cases. Skip those cases with a named reason when the binary is absent. Do not add a new pin totools.lock. (best practice) [sources: docs/TESTING.md:83, src/devops_cli/tools_lock/tools.lock]- Chosen: PATH discovery and skip. It follows the rule for a missing host capability and adds no new tool pin.
- Rejected: Add a
valkey-serverpin totools.lock. The issue says refactor(security): tools are found on PATH and not in tools.lock #4362 and chore(tools): remove devops install-tools and tools.lock #4363 move tools out oftools.lock. - Rejected: Require a live Valkey service. The network block refuses a live service in pytest.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-12: not-applicable.
Class: test, no search.
Tool: none found.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(valkey)scope of the title gives the scope.The project rule requires a contract suite before the fake merges, but this is not a blocking defect.It unblocks the Service state move into Valkey by making the fake trustworthy.Adding a dependency, writing six-plus test cases, wiring a real-binary skip, and updating docs takes about four hours.Both concern the Valkey fake and contract suites, but #1317 refactors the seam architecture while the candidate adds a specific test suite for the fake.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 5f75d25 (see proposed design in issue body).
devops-cli-service commentedon Nov 12, 2026
Alternatives check: not-applicable
Class: test. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-12. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 19, 2026
Design correction: the suite replays a record, pytest starts no
valkey-serverThe body tells pytest to start a real
valkey-serverfromPATHand to skip the real cases when the binary is missing. That design breaks four rules ofdocs/TESTING.md:src/starts no system program.devops ci.Also, the hermetic floor (lines 264 and 278) fails a connect to a loopback port that the test process did not bind. And
valkey-serveris not onPATHin the devcontainer or on a stock GitHub runner, so the first acceptance criterion cannot pass as written.Decided design. It follows the Docker engine contract suite (
tests/docker/test_engine_contract.py,docs/TESTING.mdline 284):tests/support/valkey_scenarios.pyholds the shared scenarios:SET NX EX,SET EXAT,HINCRBY,ZADDwith a trim, valkey-pyLockacquire, extend,owned()and release, and Lua throughregister_script(EVALSHA, with the NOSCRIPT fallback to EVAL).tests/support/valkey_recording.pyrecords each request and reply through a proxy in front of a realvalkey-serveron loopback, outside pytest. It keeps the server version and the valkey-py version.tests/support/valkey_replay.py(RecordedValkey) replays the record on a socket that the test binds. A request that is not the next recorded one gets an error reply.tests/valkey/test_valkey_contract.pyruns each scenario over the fake and over a real valkey-py client onRecordedValkey. Both sides must give the same result. A record of a different valkey-py version fails the suite. Nothing skips.fakeredis[lua,valkey]==2.40.0, solupa(MIT, maintained) installs and the fake answers EVAL and EVALSHA.The
limitsmoving-window case stays out.limitsis not a dependency of this repository today (no entry inuv.lock). #4563 addslimits, and it adds that case to this suite.