fix(cache): redis backend uses async clients + real-redis CI#725
Merged
wbarnha merged 1 commit intoJul 21, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## claude/fix-715-cibuildwheel-314 #725 +/- ##
===================================================================
+ Coverage 94.81% 94.84% +0.02%
===================================================================
Files 104 104
Lines 11154 11158 +4
Branches 1202 1203 +1
===================================================================
+ Hits 10576 10583 +7
+ Misses 482 479 -3
Partials 96 96 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The redis cache backend was broken against a real server: it maps schemes to the *synchronous* redis.StrictRedis / redis.RedisCluster clients but `_get`/ `_set`/`_delete`/`connect` await them, so `await self.client.get(...)` raised "object ... can't be used in 'await' expression". It only appeared to work because every test mocks the client. * Use the asyncio clients (redis.asyncio.StrictRedis / .RedisCluster), so the awaited calls are real coroutines. Verified end-to-end against a live redis (set/get/delete round-trip). * Close the client on stop (`on_stop` -> `await client.aclose()`); the async client holds real connections. * Bind `redis = None` (not just `aredis`) on ImportError so the "not installed" guard raises ImproperlyConfigured instead of NameError. * mocked_redis fixture: patch redis.asyncio.StrictRedis (the name the backend now uses) and give the mock `aclose`. * Re-enable Test_RedisScheme / the not-installed test, asserting the async client wiring. Add a real-redis CI leg: a `test-redis-integration` job with a redis service container runs new env-gated integration tests (tests/integration/cache) that exercise the backend against a live server -- the coverage the mocks can't give. Advisory (not in the required `check` gate), matching the Kafka job. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
wbarnha
force-pushed
the
claude/redis-async-client-and-ci
branch
from
July 21, 2026 00:02
21a4c69 to
7015cb1
Compare
This was referenced Jul 21, 2026
wbarnha
force-pushed
the
claude/redis-async-client-and-ci
branch
from
July 21, 2026 00:16
cf8c97f to
7015cb1
Compare
wbarnha
merged commit Jul 21, 2026
e0bdeb3
into
claude/fix-715-cibuildwheel-314
29 of 30 checks passed
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.
Description
Answers "can we test redis in CI?" — yes, and doing so surfaced that the redis cache backend was broken against a real server. This fixes it and adds the real-redis CI leg. Independent, off
master. Supersedes #724 (its guard fix + test rewrite are folded in here; #724 is closed).The bug (proven against a live redis)
The backend maps schemes to the synchronous
redis.StrictRedis/redis.RedisCluster, but_get/_set/_delete/connectawait the client:It only ever looked fine because every unit test mocks the client with
AsyncMock.Fix —
faust/web/cache/backends/redis.pyredis.asyncio.StrictRedis/redis.asyncio.RedisCluster) so the awaited calls are real coroutines. Verified end-to-end against a live redis (set → get → overwrite → delete round-trip).on_stop→await client.aclose()) — the async client holds real connections.redis = None(not justaredis) onImportError, so the "not installed" guard raisesImproperlyConfiguredinstead ofNameError.Tests
mocked_redisfixture now patchesredis.asyncio.StrictRedis(the name the backend uses) and providesaclose.Test_RedisScheme+ the not-installed test re-enabled, asserting the async client wiring.tests/integration/cache/), env-gated onFAUST_TEST_REDIS(skip when no server is reachable, like the broker suite), exercising set/get/overwrite/delete/missing against a live server. A conftest fixture reaps the loop's default-executor thread so the strict hygiene guards stay green.CI
New
test-redis-integrationjob with aredis:7service container runs the integration tests against a real server. Advisory (not in the requiredcheckgate), matching the Kafka integration job — easy to promote to required later since, unlike the broker, redis is deterministic.Verification
Unit
test_cache.py(32) + integrationtests/integration/cache(2) → 34 passed; the integration tests skip cleanly with no reachable redis; flake8/black/isort clean.redisis already inrequirements/test.txt(viaextras/redis.txt), so the CI job installs it.🤖 Generated with Claude Code
Generated by Claude Code