mirror of
https://github.com/lexmount/moli.git
synced 2026-11-18 00:09:07 +00:00
test(indexeddb): keep held database barriers under guard control
Release synthetic blocking work only when its guard is dropped, including during unwinding. Exercise real maintenance timers with flat SQLite files so unrelated catalog publication does not consume the observation window, and assert that the held owner remains live.
This commit is contained in:
@@ -1418,7 +1418,10 @@ fn hold_database(client: &DatabaseClient) -> HeldDatabase {
|
||||
.submit(
|
||||
move |_| {
|
||||
entered.send(()).unwrap();
|
||||
blocked.recv_timeout(Duration::from_secs(10)).unwrap();
|
||||
// The guard owns this barrier. A watchdog here could release
|
||||
// the owner while a slow test still relies on it being held.
|
||||
// Callers bound their observations and release on unwind.
|
||||
blocked.recv().unwrap();
|
||||
Ok(())
|
||||
},
|
||||
|_| {},
|
||||
|
||||
@@ -414,8 +414,11 @@ fn completed_maintenance_before_blocking_does_not_count_as_pending() {
|
||||
|
||||
fn assert_later_rounds_progress_with_blocked_database(prior_check: bool) {
|
||||
let directory = Directory::new();
|
||||
let mut service = Service::on_disk(directory.0.join("idb-lite"), config()).unwrap();
|
||||
let slow = resolve(&service, OWNER, "a-held");
|
||||
// This checks the real maintenance timer and per-database FIFOs. Flat disk
|
||||
// files avoid putting unrelated catalog directory syncs inside the held
|
||||
// interval; catalog publication and recovery have their own tests.
|
||||
let mut service = Service::new(config()).unwrap();
|
||||
let slow = open(&service, "a-held", directory.location("a-held.sqlite"));
|
||||
if prior_check {
|
||||
slow.owner
|
||||
.maintain(Instant::now())
|
||||
@@ -452,7 +455,7 @@ fn assert_later_rounds_progress_with_blocked_database(prior_check: bool) {
|
||||
}
|
||||
// This database did not exist in the blocked round. Its reclamation must
|
||||
// come from a subsequent real timer round, with no manual clock advance.
|
||||
let fast = resolve(&service, OWNER, "b-later");
|
||||
let fast = open(&service, "b-later", directory.location("b-later.sqlite"));
|
||||
let deadline = Instant::now() + Duration::from_secs(6);
|
||||
while physical_connection(&fast) {
|
||||
assert!(
|
||||
@@ -466,5 +469,9 @@ fn assert_later_rounds_progress_with_blocked_database(prior_check: bool) {
|
||||
initial_submissions + 1,
|
||||
"only one check may wait behind held SQL"
|
||||
);
|
||||
assert!(
|
||||
!slow.is_closed(),
|
||||
"the held owner must remain live until the test releases it"
|
||||
);
|
||||
drop(held);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user