From b37293fa683c87d70742c654d2c8ee56fbf752c7 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 24 Nov 2023 12:33:32 +0900 Subject: [PATCH] tests: add upper bound to test_concurrent_read_write_commit() loop Hopefully this will fix the unfinished Windows CI issue. A possible scenario is that recent migration to gitoxide made this test flaky on Windows. For example, gitoxide might have in-memory object cache that relies on file mtime, and occasionally fails to detect new object on Windows. --- lib/tests/test_git.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index 8aa44ecc6..1885fb973 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -2909,7 +2909,12 @@ fn test_concurrent_read_write_commit() { pending_commit_ids.rotate_left(i); // start lookup from different place s.spawn(move || { barrier.wait(); - while !pending_commit_ids.is_empty() { + // This loop should finish within a couple of retries, but terminate in case + // it doesn't. + for _ in 0..100 { + if pending_commit_ids.is_empty() { + break; + } repo = repo.reload_at_head(settings).unwrap(); let git_backend = get_git_backend(&repo); let mut tx = repo.start_transaction(settings, &format!("reader {i}")); @@ -2936,6 +2941,15 @@ fn test_concurrent_read_write_commit() { } thread::yield_now(); } + if !pending_commit_ids.is_empty() { + // It's not an error if some of the readers couldn't observe the commits. It's + // unlikely, but possible if the git backend had strong negative object cache + // for example. + eprintln!( + "reader {i} couldn't observe the following commits: \ + {pending_commit_ids:#?}" + ); + } }); } });