Repository navigation
Description
Tests keep failing intermittently because background work the test never asked for lands inside the window it asserts on. Each one has been fixed one test at a time:
| Commit | What raced the test | Fix |
|---|---|---|
baa152750 |
Background index builds from the seeding client kept writing blobs under the old key, so the rotation sweep ended swept |
Indexing off in that test's config |
594d82c4d |
Another build's leaf writes were counted in a sketch-format test (128 vs 127) | Thresholds raised so test commits never trigger a build |
32acd8986 |
The indexer indexed before a tracing test's query, and the cache's event listener installed a root before a reload test's reload | Seed without indexing; reorder the steps |
c1db1a86a |
WAL thread flushes were counted in a test's flush count (15 for 1) | Test hook that pauses the WAL thread |
| #2277 | Key rotation status read completed while the sweep's task was still running (an engine bug; the test was right) |
Fixed in the engine |
Each fix is right for its test, but the defaults are unchanged, so the next test written on them inherits the race.
Cause
FlureeBuilder::file() and FlureeBuilder::from_json_ld turn background indexing on, and DEFAULT_REINDEX_MIN_BYTES is 100, so nearly every test commit queues a background build. FlureeBuilder::memory() leaves indexing off, which is why the in-memory tests don't hit this. Of the 131 test files in fluree-db-api/tests that build through file() or from_json_ld, 31 turn indexing off by hand. Tests that need an index mostly build it explicitly with support::build_and_publish_index already.
Proposal
- Background indexing off by default for test clients. Add a shared helper in
fluree-db-api/tests/supportthat builds file-backed and JSON-LD-config clients with indexing off, move the existing tests onto it, and have the tests that exercise background indexing turn it on explicitly. Production builder defaults stay as they are. - Deferred: one settle hook for background work a test starts. A single call that waits until the background tasks a test started have finished, instead of each test polling.
c1db1a86a's WAL pause hook andwait_for_key_rotationare one-off versions of this. A general one needs those tasks registered somewhere central, so it waits until a second case needs it.
Out of scope: 6290dedb7 (in-test deadlines too short for a loaded runner) is a timing problem, not background work, and neither item would have prevented it.
Activity