openobserve/tests/api-testing/support
Shrinath Rao a647e6aee9
test: add retry_on_db_lock helper to support/wait.py (#12434)
## Summary

- Adds `retry_on_db_lock()` to `tests/api-testing/support/wait.py`
- Companion to the enterprise-side fix (openobserve/o2-enterprise#TBD)
that applies the helper across all RBAC entity base tests

## Root cause

The `ent_rbac` CI shard runs with `-n 2` (two pytest-xdist workers).
SQLite's single-writer model means parallel workers racing on write
operations produce transient `500 {"message": "database is locked"}`
responses (SQLite error codes 5 / 517). These surface as flaky assertion
failures across many PRs.

## Fix

`retry_on_db_lock(fn)` wraps an HTTP call and retries up to 3 times with
exponential backoff (0.5 → 1 → 2 s) only when the response is `500` with
`"database is locked"` in the body. Parallelism is preserved; the brief
retry window absorbs the time the other writer needs to commit and
release the lock.

## Test plan

- [ ] OSS CI passes with this branch
- [ ] Enterprise PR with the same branch name picks up the new utility
and applies it in all RBAC entity base tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-06-03 12:23:48 +00:00
..
endpoints test: revamp api-testing suite (framework + 16 file rewrites + CI matrix) (#12372) 2026-06-01 07:19:48 +00:00
__init__.py test: revamp api-testing suite (framework + 16 file rewrites + CI matrix) (#12372) 2026-06-01 07:19:48 +00:00
client.py test: revamp api-testing suite (framework + 16 file rewrites + CI matrix) (#12372) 2026-06-01 07:19:48 +00:00
factories.py test: revamp api-testing suite (framework + 16 file rewrites + CI matrix) (#12372) 2026-06-01 07:19:48 +00:00
fixtures.py test: revamp api-testing suite (framework + 16 file rewrites + CI matrix) (#12372) 2026-06-01 07:19:48 +00:00
sse.py test: revamp api-testing suite (framework + 16 file rewrites + CI matrix) (#12372) 2026-06-01 07:19:48 +00:00
wait.py test: add retry_on_db_lock helper to support/wait.py (#12434) 2026-06-03 12:23:48 +00:00