Skip to content

Commit 4000216

Browse files
Merge #3893
3893: Document flakiness of WallClock tests r=amesgen a=amesgen # Description Reported by `@coot` (found in #3785 (comment)), thanks! Co-authored-by: Alexander Esgen <[email protected]>
2 parents e600042 + f65d909 commit 4000216

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Sadly, some CI checks are currently flaky. Right now, this includes:
88
99
- The Hydra check for test-storage on Windows (mingwW64) fails with inscrutable malloc-related error messages: https://hydra.iohk.io/build/16260881/nixlog/1
1010
11+
- The tests in WallClock.delay* can fail under load (quite rarely): https://hydra.iohk.io/build/16723452/nixlog/76
12+
1113
If you encounter one of these, try restarting the job to see if the failure vanishes. If it does not or when in doubt, consider posting in the #network or #consensus channels on Slack.
1214
-->
1315

ouroboros-consensus-test/test-consensus/Test/Consensus/BlockchainTime/Simple.hs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import qualified Data.Time.Clock as Time
2222
import NoThunks.Class (AllowThunk (..))
2323
import Test.QuickCheck hiding (Fixed)
2424
import Test.Tasty hiding (after)
25-
import Test.Tasty.HUnit
2625
import Test.Tasty.QuickCheck hiding (Fixed)
2726

2827
import qualified Control.Monad.Class.MonadSTM as LazySTM
@@ -80,20 +79,22 @@ instance Arbitrary TestDelayIO where
8079
-- NOTE: If the system is under very heavy load, this test /could/ fail:
8180
-- the slot number after the delay could be later than the one we expect.
8281
-- We don't relax the test because this is highly unlikely, and the stronger
83-
-- test gives us a more useful property.
82+
-- test gives us a more useful property. Also see issue #3894.
8483
prop_delayNextSlot :: TestDelayIO -> Property
8584
prop_delayNextSlot TestDelayIO{..} =
8685
withMaxSuccess 10 $ ioProperty test
8786
where
88-
test :: IO ()
87+
test :: IO Property
8988
test = do
9089
tdioStart <- pickSystemStart
9190
let time = defaultSystemTime tdioStart nullTracer
9291
atStart <- fst <$> getWallClockSlot time tdioSlotLen
9392
nextSlot <- waitUntilNextSlot time tdioSlotLen maxClockRewind atStart
9493
afterDelay <- fst <$> getWallClockSlot time tdioSlotLen
95-
assertEqual "atStart + 1" (atStart + 1) afterDelay
96-
assertEqual "nextSlot" nextSlot afterDelay
94+
pure $ conjoin
95+
[ counterexample "atStart + 1" $ atStart + 1 === afterDelay
96+
, counterexample "nextSlot" $ nextSlot === afterDelay
97+
]
9798

9899
pickSystemStart :: IO SystemStart
99100
pickSystemStart = pick <$> getCurrentTime
@@ -288,8 +289,11 @@ prop_delayNoClockShift =
288289
(slotLengthFromMillisec 100)
289290
(secondsToNominalDiffTime 20)
290291
5
291-
assertEqual "slots" slots [SlotNo n | n <- [0..4]]
292+
pure $ slots === [SlotNo n | n <- [0..4]]
292293

294+
-- | Note that that under load, the returned list could be missing certain slots
295+
-- or contain more slots than requested. This means that tests using this
296+
-- function can fail, also see issue #3894.
293297
testOverrideDelay :: forall m. (IOLike m, MonadTime m, MonadDelay (OverrideDelay m))
294298
=> SystemStart
295299
-> SlotLength

0 commit comments

Comments
 (0)