YongGoose opened a new pull request, #1035:
URL: https://github.com/apache/burr/pull/1035

   The Redis and PostgreSQL persister integration tests left their data behind, 
so re-running them against the same databases failed 22 tests with 
duplicate-key errors. Each test now removes what it wrote.
   
   Closes #1034
   
   ## Changes
   
   - `test_postgresql.py`: the sync and async fixtures delete the rows in their 
test table on teardown. I used `DELETE` rather than `DROP TABLE` because `DROP` 
needs an exclusive lock and waits indefinitely behind any connection still idle 
in a read transaction (for example the unpickled persister in 
`test_serialization_with_pickle`, until it is garbage collected). `DELETE` 
doesn't conflict with readers.
   - `test_b_redis.py`: an autouse fixture records the keys in db 0 and db 1 
before each test and deletes only the keys that appeared during it. This covers 
the fixture-based tests and `test_redis_persister_class_backwards_compatible`, 
and leaves any existing data in db 0 (Redis' default db) alone, so there's no 
`FLUSHDB`.
   
   The persisters themselves are unchanged.
   
   ## How I tested this
   
   With postgres:15, mongo:7.0 and redis:7 (the CI images):
   
   - Ran `BURR_CI_INTEGRATION_TESTS=true pytest tests/integrations/persisters` 
three times in a row against the same databases: 68 passed each time. Before 
this change: 68 passed on the first run, then 22 failed on every later run.
   - Afterwards no test keys are left in Redis and both Postgres test tables 
are empty. A key I set in db 0 and db 1 before the runs was still there.
   - Got the same result running the suite twice inside a Linux container 
(Python 3.12).
   - Checked the `DELETE` vs `DROP TABLE` reasoning: with another connection 
idle in transaction after a `SELECT` on `testtable`, `DELETE FROM testtable` 
returned immediately, while `DROP TABLE testtable` was still waiting after 5 
minutes.
   - `pre-commit run` passes on the changed files.
   
   ## Notes
   
   - If your local databases already hold leftovers from earlier runs, reset 
them once (for example, recreate the containers). The Redis cleanup 
deliberately never deletes keys that existed before a test started.
   - #950 and #1012 also add tests to these two files. They only append tests 
and don't touch the fixtures, so this merges cleanly with both (checked with 
`git merge-tree`). The new Postgres tests in #950 use the same fixture, so they 
get cleaned up too.
   
   ## Checklist
   
   - [x] PR has an informative and human-readable title (this will be pulled 
into the release notes)
   - [x] Changes are limited to a single goal (no scope creep)
   - [x] Code passed the pre-commit check & code is left cleaner/nicer than 
when first encountered.
   - [x] Any _change_ in functionality is tested
   - [x] New functions are documented (with a description, list of inputs, and 
expected output)
   - [ ] Placeholder code is flagged / future TODOs are captured in comments 
(n/a)
   - [ ] Project documentation has been updated if adding/changing 
functionality. (n/a, test-only change)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to