1.8 KiB
PR#141: Slot Tests without Waiting
WARNING: This document describes only the change applied in this PR. It may already be outdated once the next PR is merged. Historic PR-documentation is not maintained along with new PRs — treat it as a snapshot, not as current documentation.
The Problem
BuildSlotsUnitTest shows that a build waits for a slot by trying to get its lease for 300 ms and expecting the time to run out.
Every test does that at least once, so the spec takes about 2.8 s, nearly all of it waiting.
PIT runs the spec again for every mutant of BuildSlots and BuildPool it covers, and a mutant that lets a build wait where it should not makes a later get wait up to five seconds.
Non-Goals
- No change to
BuildSlotsitself: PR#138 already gave itwaiting(), the number of builds waiting at its semaphores.
The Scenarios
The behaviour of the slots does not change, so their scenarios (Scenario#106.01 to Scenario#106.04, Scenario#119.01 to Scenario#119.04) stay as they are. Only how a test sees a waiting build changes: it waits until the build queues at a semaphore, or until it got through instead; when neither happens within five seconds, the test fails.
The Solution
isWaitingAt(slots)replaces the timedget: it pollsslots.waiting()and the future, and returns as soon as one of them says something.
The spec now takes 0.06 s instead of 2.8 s.
A local PIT run of BuildSlots and BuildPool, two minions, without history:
| Run | Duration | Mutants killed or timed out |
|---|---|---|
| Before | 223 s | 33 of 37 |
| With the PR | 139 s | 33 of 37 |
Prerequisite PRs
- PR#140, for the order of the versions; it also keeps
FailFastUnitTestout of PIT, without which no PIT run starts.