circuithub / rel8

Hey! Hey! Can u rel8?
https://rel8.readthedocs.io
Other
154 stars 39 forks source link

MaybeTable test is flaky #133

Open sternenseemann opened 3 years ago

sternenseemann commented 3 years ago

Observed this failure on x86_64-darwin, but re-running the test suite made it pass, so this test case may be flaky (or maybe have locale-specific edge cases as it involves sorting?).

  MaybeTable (<*>):                            FAIL (0.15s)
      ✗ MaybeTable (<*>) failed at tests/Main.hs:587:85
        after 84 tests.

            ┏━━ tests/Main.hs ━━━
        586 ┃ testMaybeTableApplicative :: IO TmpPostgres.DB -> TestTree
        587 ┃ testMaybeTableApplicative = databasePropertyTest "MaybeTable (<*>)" \transaction -> evalM do
        588 ┃   rows1 <- genRows
        589 ┃   rows2 <- genRows
        590 ┃ 
        591 ┃   transaction do
        592 ┃     selected <- lift do
        593 ┃       statement () $ Rel8.select do
        594 ┃         as <- Rel8.optional (Rel8.values (Rel8.lit <$> rows1))
        595 ┃         bs <- Rel8.optional (Rel8.values (Rel8.lit <$> rows2))
        596 ┃         pure $ liftA2 (,) as bs
        597 ┃ 
        598 ┃     case (rows1, rows2) of
        599 ┃       ([], []) -> selected === [Nothing]
        600 ┃       ([], bs) -> selected === (Nothing <$ bs)
        601 ┃       (as, []) -> selected === (Nothing <$ as)
        602 ┃       (as, bs) -> sort selected === sort (Just <$> liftA2 (,) as bs)
            ┃       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            ┃       │ ━━━ Exception (QueryError) ━━━
            ┃       │ QueryError "SELECT\nCAST(CASE WHEN ((\"rebind0_2\") IS NULL) OR ((\"rebind0_6\") IS NULL) THEN CAST(NULL AS bool) ELSE (\"rebind0_2\") AND (\"rebind0_6\") END AS bool) as \"isJust\",\nCAST(CASE WHEN (CASE WHEN ((\"rebind0_2\") IS NULL) OR ((\"rebind0_6\") IS NULL) THEN CAST(NULL AS bool) ELSE (\"rebind0_2\") AND (\"rebind0_6\") END) IS NOT NULL THEN \"values0_1\" ELSE NULL END AS text) as \"Just/_1/testTableColumn1\",\nCAST(CASE WHEN (CASE WHEN ((\"rebind0_2\") IS NULL) OR ((\"rebind0_6\") IS NULL) THEN CAST(NULL AS bool) ELSE (\"rebind0_2\") AND (\"rebind0_6\") END) IS NOT NULL THEN \"values1_1\" ELSE NULL END AS bool) as \"Just/_1/testTableColumn2\",\nCAST(CASE WHEN (CASE WHEN ((\"rebind0_2\") IS NULL) OR ((\"rebind0_6\") IS NULL) THEN CAST(NULL AS bool) ELSE (\"rebind0_2\") AND (\"rebind0_6\") END) IS NOT NULL THEN \"values0_5\" ELSE NULL END AS text) as \"Just/_2/testTableColumn1\",\nCAST(CASE WHEN (CASE WHEN ((\"rebind0_2\") IS NULL) OR ((\"rebind0_6\") IS NULL) THEN CAST(NULL AS bool) ELSE (\"rebind0_2\") AND (\"rebind0_6\") END) IS NOT NULL THEN \"values1_5\" ELSE NULL END AS bool) as \"Just/_2/testTableColumn2\"\nFROM (SELECT *\n      FROM\n      (SELECT *\n       FROM\n       (SELECT\n        0) as \"T1\"\n       LEFT OUTER JOIN\n       (SELECT\n        TRUE as \"rebind0_2\",\n        *\n        FROM (SELECT\n              *\n              FROM (SELECT \"column1\" as \"values0_1\",\n                           \"column2\" as \"values1_1\"\n                    FROM\n                    (VALUES\n                     (CAST(E'\\U0001287c\\U0008b520\\U0006181e\\U000b785e\240\176\128\142\\0\\U000ed9b7\\U0004b3ab\\U000ee815' AS text),CAST(TRUE AS bool)),\n                     (CAST(E'\240\165\163\153\\U00060715' AS text),CAST(TRUE AS bool)),\n                     (CAST(E'\230\142\137\\U0006233c\\U00051f8f\\U0004edf4\\U000c0800\\U0010e4e1' AS text),CAST(TRUE AS bool))) as \"V\") as \"T1\") as \"T1\") as \"T2\"\n       ON\n       TRUE) as \"T1\"\n      LEFT OUTER JOIN\n      LATERAL\n      (SELECT\n       TRUE as \"rebind0_6\",\n       *\n       FROM (SELECT\n             *\n             FROM (SELECT \"column1\" as \"values0_5\",\n                          \"column2\" as \"values1_5\"\n                   FROM\n                   (VALUES\n                    (CAST(E'\\U000a865a\\U00094a4a\\U0001e0c0\\U000569d1\\U000a8170' AS text),CAST(TRUE AS bool)),\n                    (CAST(E'\\U000b0a55\\U0003b46e\234\130\142\\U0006887f\\U0008a8e5\\U00046460\240\159\143\187\\U0004c6bf\\U000b987c' AS text),CAST(TRUE AS bool)),\n                    (CAST(E'\\U0009dd64\\U00055d18\\U0007d3dc\\U00095b3a\240\161\141\164' AS text),CAST(TRUE AS bool)),\n                    (CAST(E'\\U000ee282\\U000f25e8\240\162\134\146\\U0001ebe3\\U000d3641\\U0001966f\\U000914c5\\U0007c268\\U000342b9' AS text),CAST(TRUE AS bool)),\n                    (CAST(E'\\U000ea95f\\U00067448\240\172\172\149\\U00069cec' AS text),CAST(TRUE AS bool))) as \"V\") as \"T1\") as \"T1\") as \"T2\"\n      ON\n      TRUE) as \"T1\"" [] (ResultError (ServerError "22021" "invalid byte sequence for encoding \"UTF8\": 0x00" Nothing Nothing))
        603 ┃   where
        604 ┃     genRows :: PropertyT IO [TestTable Result]
        605 ┃     genRows = forAll do
        606 ┃       Gen.list (Range.linear 0 10) $ liftA2 TestTable (Gen.text (Range.linear 0 10) Gen.unicode) (pure True)

        This failure can be reproduced by running:
        > recheck (Size 83) (Seed 17452076655856458487 15436597684825125903) MaybeTable (<*>)

    Use '--hedgehog-replay "Size 83 Seed 17452076655856458487 15436597684825125903"' to reproduce.

    Use -p '/MaybeTable (<*>)/' to rerun this test only.
ocharles commented 3 years ago

Thanks - it's due to Gen.unicode - PostgreSQL doesn't support \0 as a Unicode character so we should filter those out!