Skip to content

[tests] Run the distributed locks on fakeredis - #1233

Merged
nledez merged 1 commit into
cgwire:mainfrom
nledez:chore/tests-fakeredis-redis-lock
Sep 22, 2026
Merged

nledez merged 1 commit into
cgwire:mainfrom
nledez:chore/tests-fakeredis-redis-lock

Conversation

@nledez

@nledez nledez commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Problem

  • The CI provides no Redis, and redis_lock.get_redis_client opens a fresh client and pings it on every lock
  • Each playlist, annotation or cache single-flight lock taken in a test therefore waited for redis-py's connection retries (about ten seconds) before falling back to the unlocked degraded mode: tests/blueprints/files/test_extract_annotated_frame.py
    alone took 112 s instead of 2 s
  • The locks themselves were never exercised by the suite, since every test ran in the degraded mode where a lock is always granted

Solution

  • Point redis_lock.get_redis_client at a fakeredis in the test base, flushed after each test like the revoked token, config and job queue stores already are
  • Install fakeredis with its lua extra (fakeredis[lua]==2.35.1, pulls lupa): redis-py's Lock releases through a Lua script, which fakeredis only runs with it
  • Add tests/stores/test_redis_lock.py covering the lock exclusivity until release and the independence of two different keys
  • Without a Redis server, the full suite drops from 22 minutes to under 10 locally, and the locks are now really tested

The CI provides no Redis. redis_lock opens a fresh client and pings it
on every lock: each playlist, annotation or cache single-flight lock in
a test waited for redis-py's connection retries (about ten seconds)
before falling back to the unlocked mode, and the locks themselves were
never exercised.

- Point redis_lock.get_redis_client at a fakeredis in the test base,
  flushed after each test like the other fake stores.
- Install fakeredis with its lua extra: redis-py's Lock releases through
  a Lua script.
- Cover the lock exclusivity and the per-key independence.

Without Redis the full suite drops from 22 to under 10 minutes locally.

Tests: tests/stores/test_redis_lock.py, full suite without Redis
(3128 passed, known ffmpeg-version failure in test_movie aside)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nledez
nledez merged commit 64b1192 into cgwire:main Sep 22, 2026
15 checks passed
@nledez
nledez deleted the chore/tests-fakeredis-redis-lock branch September 22, 2026 18:12
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