Skip to content

Commit af75859

Browse files
authored
worker/tests: Fix flaky deduplication test (#9865)
The second `assert_none!()` in this test was occasionally failing due to a race condition. The `TestJob` that was enqueued right before this one would sometimes already be processed before we enqueue this one, leading to this one being actually enqueued instead of being deduplicated. The reason for this was that the `runner()` fn builds a `Runner` with two workers for the default queue. This commit changes the runner to only use a single worker, which avoids the race condition.
1 parent b51da84 commit af75859

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crates/crates_io_worker/tests/runner.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ async fn jobs_can_be_deduplicated() -> anyhow::Result<()> {
277277
let pool = pool(test_database.url())?;
278278
let mut conn = pool.get().await?;
279279

280-
let runner = runner(pool, test_context.clone()).register_job_type::<TestJob>();
280+
let runner = Runner::new(pool, test_context.clone())
281+
.register_job_type::<TestJob>()
282+
.shutdown_when_queue_empty();
281283

282284
// Enqueue first job
283285
assert_some!(TestJob::new("foo").async_enqueue(&mut conn).await?);

0 commit comments

Comments
 (0)