Repoint database/cache pub/sub to fake redis in the e2e harness - #23
Merged
Merged
Conversation
…ness Follow-up to the register_script re-bind. database/cache.py lazily builds RedisPubSubManager(r).start() on first cache access (spawning a background subscribe loop) using a redis client captured at import; the harness r-repoint doesn't cover it, so /v1/users/me/subscription -> phone_calls.get_quota_snapshot -> cache init -> redis_pubsub.start dialed a real redis and raised ConnectionRefused under the redis-less hermetic job (order-dependent). Repoint database.cache.r and any already-built _pubsub_manager.redis_client to the harness fake, in both the app factory and the per-test isolation fixture. This closes the last redis-isolation gap for the subscription path and lets the users.py available_plans assertion run hermetically (re-added here). Verified: full hermetic harness 119 passed, 3 skipped both with redis up and with no redis; real redis dbsize 0 after a full redis-up run (no leaked keys). Failure-Class: none Co-authored-by: Tselem <formed2forge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Follow-up to #22 (register_script re-bind). While re-enabling the
routers/users.pysubscriptionavailable_plansassertion I closed the last redis-isolation gap in the hermetic harness.database/cache.pylazily buildsRedisPubSubManager(r).start()on first cache access (spawning a background subscribe loop) using a redis client captured at import. The harnessredis_db.rrepoint doesn't cover it, so/v1/users/me/subscription→utils/phone_calls.get_quota_snapshot→ cache init →database/redis_pubsub.startdialed a real redis and raisedConnectionRefusedunder the redis-less hermetic job (order-dependent — only after a test first triggered cache init).Fix: repoint
database.cache.rand any already-built_pubsub_manager.redis_clientto the harness fake, in both the app factory and the per-test isolation fixture. This lets the users.pyavailable_plansassertion run hermetically (re-added in this PR).Product invariants affected
none — test-harness change only; no production code.
How it was verified
On the Cloud VM (Python 3.11.15 venv):
119 passed, 3 skipped(adds the re-enabledtest_user_subscription_available_plans_populated).dbsizeis 0 (no leaked keys — the register_script re-bind from Re-bind register_script Lua to the fake redis in the e2e harness #22 still holds and pub/sub uses the fake).black(pinned 24.4.2) clean.Tests
Re-enables
backend/testing/e2e/test_stripe_available_plans.py::test_user_subscription_available_plans_populated, which now exercises the cache-backedrouters/users.pyavailable_planspath offline. Bothavailable_planssurfaces (payment + users) are now proven hermetically.Failure-Class: none