Soostone / retry

Retry combinators for monadic actions that may fail
BSD 3-Clause "New" or "Revised" License
112 stars 36 forks source link

Test failure on policy transformers #78

Open paulvictor opened 2 years ago

paulvictor commented 2 years ago

I am trying to build retry, and I ended up with a test failure

   policy transformers
      always produces positive delay with positive constants (no rollover):          FAIL (0.69s)
          ✗ always produces positive delay with positive constants (no rollover) failed at test/Tests/Control/Retry.hs:221:11
            after 2 tests and 57 shrinks.

                ┏━━ test/Tests/Control/Retry.hs ━━━
            208 ┃ policyTransformersTests :: TestTree
            209 ┃ policyTransformersTests = testGroup "policy transformers"
            210 ┃   [ testProperty "always produces positive delay with positive constants (no rollover)" $ property $ do
            211 ┃       delay <- forAll (Gen.int (Range.linear 0 maxBound))
                ┃       │ 1
            212 ┃       let res = runIdentity (simulatePolicy 1000 (exponentialBackoff delay))
            213 ┃           delays = catMaybes (snd <$> res)
            214 ┃           mnDelay = if null delays
            215 ┃                       then Nothing
            216 ┃                       else Just (minimum delays)
            217 ┃       case mnDelay of
            218 ┃         Nothing -> return ()
            219 ┃         Just n -> do
            220 ┃           footnote (show n ++ " is not >= 0")
            221 ┃           HH.assert (n >= 0)
                ┃           ^^^^^^^^^^^^^^^^^^
            222 ┃   , testProperty "positive, nonzero exponential backoff is always incrementing" $ property $ do
            223 ┃      delay <- forAll (Gen.int (Range.linear 1 maxBound))
            224 ┃      let res = runIdentity (simulatePolicy 1000 (limitRetriesByDelay maxBound (exponentialBackoff delay)))
            225 ┃          delays = catMaybes (snd <$> res)
            226 ┃      sort delays === delays
            227 ┃      length (group delays) === length delays
            228 ┃   ]

            -9223372036854775808 is not >= 0

            This failure can be reproduced by running:
            > recheck (Size 1) (Seed 17647478776705613149 5015347513854265309) always produces positive delay with positive constants (no rollover)

        Use '--hedgehog-replay "Size 1 Seed 17647478776705613149 5015347513854265309"' to reproduce.

        Use -p '/always produces positive delay with positive constants (no rollover)/' to rerun this test only.
      positive, nonzero exponential backoff is always incrementing:                  FAIL (0.41s)
          ✗ positive, nonzero exponential backoff is always incrementing failed at test/Tests/Control/Retry.hs:226:18
            after 1 test.

                ┏━━ test/Tests/Control/Retry.hs ━━━
            208 ┃ policyTransformersTests :: TestTree
            209 ┃ policyTransformersTests = testGroup "policy transformers"
            210 ┃   [ testProperty "always produces positive delay with positive constants (no rollover)" $ property $ do
            211 ┃       delay <- forAll (Gen.int (Range.linear 0 maxBound))
            212 ┃       let res = runIdentity (simulatePolicy 1000 (exponentialBackoff delay))
            213 ┃           delays = catMaybes (snd <$> res)
            214 ┃           mnDelay = if null delays
            215 ┃                       then Nothing
            216 ┃                       else Just (minimum delays)
            217 ┃       case mnDelay of
            218 ┃         Nothing -> return ()
            219 ┃         Just n -> do
            220 ┃           footnote (show n ++ " is not >= 0")
            221 ┃           HH.assert (n >= 0)
            222 ┃   , testProperty "positive, nonzero exponential backoff is always incrementing" $ property $ do
            223 ┃      delay <- forAll (Gen.int (Range.linear 1 maxBound))
                ┃      │ 1
            224 ┃      let res = runIdentity (simulatePolicy 1000 (limitRetriesByDelay maxBound (exponentialBackoff delay)))
            225 ┃          delays = catMaybes (snd <$> res)
            226 ┃      sort delays === delays
                ┃      ^^^^^^^^^^^^^^^^^^^^^^
... with a very big array
... followed by

           This failure can be reproduced by running:
            > recheck (Size 2) (Seed 10571801305957791816 9377426414140356069) never exceeds the given cumulative delay

        Use '--hedgehog-replay "Size 2 Seed 10571801305957791816 9377426414140356069"' to reproduce.

        Use -p '/never exceeds the given cumulative delay/' to rerun this test only.
natsukagami commented 2 years ago

This is related to https://gitlab.haskell.org/ghc/ghc/-/issues/21624, a compiler backend bug.

MichaelXavier commented 2 years ago

Maybe @paulvictor can keep an eye on the GHC bug and try again when the fix is available. Or we could close the ticket.

pwm commented 1 year ago

This seems to be fixed now?