Skip to content

Commit

Permalink
Use custom timeout of 120s for SETTINGS_02 test; slightly rise global…
Browse files Browse the repository at this point in the history
… timeout for eventually to 100s
  • Loading branch information
Piotr Stachyra committed Oct 13, 2020
1 parent d6297aa commit e479aac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
29 changes: 16 additions & 13 deletions lib/core-integration/src/Test/Integration/Framework/DSL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -659,36 +659,39 @@ a .<= b
-- has been retried enough.
--
-- It is like 'eventuallyUsingDelay', but with the default delay of 500 ms
-- between retries.
-- and timeout of 100s between retries.
-- NOTE
-- This __100s__ is mostly justified by the parameters in the shelley
-- genesis. The longest action we have two wait for are about 2 epochs,
-- which corresponds to 80s with the current parameters. Using something
-- much longer than that isn't really useful (in particular, this doesn't
-- depend on the host machine running the test, because the protocol moves
-- forward at the same speed regardless...)
eventually :: String -> IO a -> IO a
eventually = eventuallyUsingDelay (500 * ms)
eventually = eventuallyUsingDelay (500 * ms) 100
where
ms = 1000

-- Retry the given action a couple of time until it doesn't throw, or until it
-- has been retried enough.
--
-- It sleeps for a specified delay between retries.
-- It sleeps for a specified delay between retries and fails after timeout.
eventuallyUsingDelay
:: Int -- ^ Delay in microseconds
-> Int -- ^ Timeout in seconds
-> String -- ^ Brief description of the IO action
-> IO a
-> IO a
eventuallyUsingDelay delay desc io = do
eventuallyUsingDelay delay timeout desc io = do
lastErrorRef <- newIORef Nothing
-- NOTE
-- This __90s__ is mostly justified by the parameters in the shelley
-- genesis. The longest action we have two wait for are about 2 epochs,
-- which corresponds to 80s with the current parameters. Using something
-- much longer than that isn't really useful (in particular, this doesn't
-- depend on the host machine running the test, because the protocol moves
-- forward at the same speed regardless...)
winner <- race (threadDelay $ 90 * oneSecond) (trial lastErrorRef)
winner <- race (threadDelay $ timeout * oneSecond) (trial lastErrorRef)
case winner of
Left () -> do
lastError <- readIORef lastErrorRef
fail $ mconcat
[ "Waited longer than 90s (more than 2 epochs) for an action to resolve. "
[ "Waited longer than "
, show timeout
,"s for an action to resolve. "
, "Action: "
, show desc
, ". Error condition: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Test.Integration.Framework.DSL
, Headers (..)
, Payload (..)
, eventually
, eventuallyUsingDelay
, expectField
, expectResponseCode
, json
Expand Down Expand Up @@ -88,17 +89,19 @@ spec = describe "SHELLEY_SETTINGS" $ do
toDirect = "direct"
getMetadata = fmap (view #metadata) . snd <$> unsafeRequest
@[ApiStakePool] ctx (Link.listStakePools arbitraryStake) Empty
delay = 500 * 1000
timeout = 120

updateMetadataSource ctx toNone
eventually "1. There is no metadata" $
eventuallyUsingDelay delay timeout "1. There is no metadata" $
getMetadata >>= (`shouldSatisfy` all isNothing)

updateMetadataSource ctx toDirect
eventually "2. There is metadata" $
eventuallyUsingDelay delay timeout "2. There is metadata" $
getMetadata >>= (`shouldSatisfy` all isJust)

updateMetadataSource ctx toNone
eventually "3. There is no metadata" $
eventuallyUsingDelay delay timeout "3. There is no metadata" $
getMetadata >>= (`shouldSatisfy` all isNothing)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ spec = do
-- This might take a few tries (epoch changes), so it is only feasible
-- to test with very short epochs.
let ms = 1000
eventuallyUsingDelay (50*ms)
eventuallyUsingDelay (50*ms) 100
"Shows error when listing stake pools on epoch boundaries"
$ do
r <- request @[ApiStakePool] ctx Link.listJormungandrStakePools Default Empty
Expand Down

0 comments on commit e479aac

Please sign in to comment.