Skip to content

Commit d582af5

Browse files
authored
Annotate counterexample output of potentially flaky tests (#1511)
# Description Annotate known-flaky tests with counterexamples describing their flakiness (and their respective tickets about the flakiness) fixes #1443
2 parents 0554e5d + d269955 commit d582af5

File tree

6 files changed

+33
-11
lines changed
  • ouroboros-consensus
    • bench/mempool-bench
    • test
      • consensus-test/Test/Consensus/BlockchainTime
      • infra-test/Test/Ouroboros/Consensus/ChainGenerator/Tests
  • ouroboros-consensus-cardano/test
  • ouroboros-consensus-diffusion/test/mock-test/Test/ThreadNet

6 files changed

+33
-11
lines changed

ouroboros-consensus-cardano/test/byron-test/Test/ThreadNet/Byron.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ prop_simple_real_pbft_convergence TestSetup
862862
tabulate "Ref.PBFT result" [Ref.resultConstrName refResult] $
863863
tabulate "proposed protocol version was adopted" [show aPvuRequired] $
864864
tabulate "proposed software version was adopted" [show aSvuRequired] $
865+
counterexample flakyTestCopy $
865866
counterexample ("params: " <> show params) $
866867
counterexample ("Ref.PBFT result: " <> show refResult) $
867868
counterexample
@@ -1055,6 +1056,9 @@ prop_simple_real_pbft_convergence TestSetup
10551056
genesisSecrets :: Genesis.GeneratedSecrets
10561057
(genesisConfig, genesisSecrets) = generateGenesisConfig slotLength params
10571058

1059+
flakyTestCopy :: String
1060+
flakyTestCopy = "This test may be flaky, and its failure may not be indicative of an actual problem: see https://github.com/IntersectMBO/ouroboros-consensus/issues/1294 and / or https://github.com/IntersectMBO/ouroboros-consensus/issues/582"
1061+
10581062
byronForgeEbbEnv :: ForgeEbbEnv ByronBlock
10591063
byronForgeEbbEnv = ForgeEbbEnv
10601064
{ forgeEBB = Byron.forgeEBB . configBlock

ouroboros-consensus-cardano/test/cardano-test/Test/ThreadNet/Cardano.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ prop_simple_cardano_convergence TestSetup
176176
, setupTestConfig
177177
, setupVersion
178178
} =
179+
counterexample flakyTestCopy $
179180
prop_general_semisync pga testOutput .&&.
180181
prop_inSync testOutput .&&.
181182
prop_ReachesEra2 reachesEra2 .&&.
@@ -436,6 +437,9 @@ prop_simple_cardano_convergence TestSetup
436437
counterexample "CP violation in final chains!" $
437438
property $ unNonZero (maxRollbacks setupK) >= finalIntersectionDepth
438439

440+
flakyTestCopy :: String
441+
flakyTestCopy = "This test may be flaky, and its failure may not be indicative of an actual problem: see https://github.com/IntersectMBO/ouroboros-consensus/issues/545"
442+
439443
mkProtocolCardanoAndHardForkTxs ::
440444
forall c m. (IOLike m, c ~ StandardCrypto)
441445
-- Byron

ouroboros-consensus-diffusion/test/mock-test/Test/ThreadNet/Praos.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ prop_simple_praos_convergence TestSetup
108108
, setupTestConfig = testConfig
109109
, setupEvolvingStake = evolvingStake
110110
} =
111+
counterexample flakyTestCopy $
111112
counterexample (tracesToDot testOutputNodes) $
112113
prop_general PropGeneralArgs
113114
{ pgaBlockProperty = prop_validSimpleBlock
@@ -155,3 +156,5 @@ prop_simple_praos_convergence TestSetup
155156
(blockForgingPraos numCoreNodes nid)
156157
, mkRekeyM = Nothing
157158
}
159+
160+
flakyTestCopy = "This test may be flaky, and its failure may not be indicative of an actual problem: see https://github.com/IntersectMBO/ouroboros-consensus/issues/1105"

ouroboros-consensus/bench/mempool-bench/Main.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Main.Utf8 (withStdTerminalHandles)
2323
import Ouroboros.Consensus.Ledger.SupportsMempool (ByteSize32)
2424
import qualified Ouroboros.Consensus.Mempool.Capacity as Mempool
2525
import System.Exit (die, exitFailure)
26+
import System.IO (hPutStrLn, stderr)
2627
import qualified Test.Consensus.Mempool.Mocked as Mocked
2728
import Test.Consensus.Mempool.Mocked (MockedMempool)
2829
import Test.Tasty (withResource)
@@ -46,7 +47,9 @@ main = withStdTerminalHandles $ do
4647
Nothing -> exitFailure
4748
Just runIngredient -> do
4849
success <- runIngredient
49-
unless success exitFailure
50+
unless success $ do
51+
hPutStrLn stderr "This benchmark is flaky in GitHub Actions due to CI runner load, which can it to run significantly slower than expected. It may be useful to try to re-run the job if it fails. See https://github.com/IntersectMBO/ouroboros-consensus/issues/313"
52+
exitFailure
5053
where
5154
benchmarkJustAddingTransactions =
5255
bgroup "Just adding" $

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ instance Arbitrary TestDelayIO where
112112
-- test gives us a more useful property. Also see issue #3894.
113113
prop_delayNextSlot :: TestDelayIO -> Property
114114
prop_delayNextSlot TestDelayIO{..} =
115-
ioProperty test
115+
counterexample flakyTestCopy $ ioProperty test
116116
where
117117
test :: IO Property
118118
test = do
@@ -261,6 +261,7 @@ instance Arbitrary Schedule where
261261

262262
prop_delayClockShift :: Schedule -> Property
263263
prop_delayClockShift schedule =
264+
counterexample flakyTestCopy $
264265
tabulate "schedule length" [show $ range (length (getSchedule schedule))] $
265266
tabulate "schedule goes back" [show $ scheduleGoesBack schedule] $
266267
tabulate "schedule skips" [show $ range (scheduleCountSkips schedule)] $
@@ -312,15 +313,16 @@ prop_delayClockShift schedule =
312313
-- | Just as a sanity check, verify that this works in IO
313314
prop_delayNoClockShift :: Property
314315
prop_delayNoClockShift =
315-
ioProperty $ do
316-
now <- getCurrentTime
317-
slots <- originalDelay $
318-
testOverrideDelay
319-
(SystemStart now)
320-
(slotLengthFromMillisec 100)
321-
(secondsToNominalDiffTime 20)
322-
5
323-
pure $ slots === [SlotNo n | n <- [0..4]]
316+
counterexample flakyTestCopy $
317+
ioProperty $ do
318+
now <- getCurrentTime
319+
slots <- originalDelay $
320+
testOverrideDelay
321+
(SystemStart now)
322+
(slotLengthFromMillisec 100)
323+
(secondsToNominalDiffTime 20)
324+
5
325+
pure $ slots === [SlotNo n | n <- [0..4]]
324326

325327
-- | Note that that under load, the returned list could be missing certain slots
326328
-- or contain more slots than requested. This means that tests using this
@@ -624,3 +626,6 @@ overrideDelay start schedule ma = runSim $ do
624626

625627
originalDelay :: OverrideDelay IO a -> IO a
626628
originalDelay ma = runReaderT (unOverrideDelay ma) (error "schedule unused")
629+
630+
flakyTestCopy :: String
631+
flakyTestCopy = "This test may be flaky, and its failure may not be indicative of an actual problem: see https://github.com/IntersectMBO/ouroboros-consensus/issues/567"

ouroboros-consensus/test/infra-test/Test/Ouroboros/Consensus/ChainGenerator/Tests/Adversarial.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ instance QC.Arbitrary SomeTestAdversarialMutation where
459459
-- TODO this did fail after >500,000 tests. Is that amount of flakiness acceptable?
460460
prop_adversarialChainMutation :: SomeTestAdversarialMutation -> QCGen -> QC.Property
461461
prop_adversarialChainMutation (SomeTestAdversarialMutation Proxy Proxy testAdversarialMut) testSeedAsSeed0 =
462+
TT.counterexample flakyTestCopy $
462463
QC.ioProperty $ do
463464
A.SomeCheckedAdversarialRecipe Proxy recipeA' <- pure someRecipeA'
464465

@@ -507,6 +508,8 @@ prop_adversarialChainMutation (SomeTestAdversarialMutation Proxy Proxy testAdver
507508
A.BadDensity{} -> pure $ QC.property ()
508509
A.BadRace{} -> pure $ QC.property ()
509510

511+
flakyTestCopy = "This test may be flaky, and its failure may not be indicative of an actual problem: see https://github.com/IntersectMBO/ouroboros-consensus/issues/1442"
512+
510513
-----
511514

512515
-- | A nice rendering for failures of 'prop_adversarialChainMutation'

0 commit comments

Comments
 (0)