From b5e8a4b8cc120481b7c701f63faed0e3a6a36f9b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 11 Oct 2026 20:36:51 +0100 Subject: [PATCH] fix tests on ghc 8.10.7 (#1939) * fix tests on ghc 8.10.7 * fix test * fix schema dump test --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> --- simplexmq.cabal | 2 +- .../Notifications/Server/Store/ntf_server_schema.sql | 2 ++ .../Messaging/Server/QueueStore/Postgres/server_schema.sql | 2 ++ tests/AgentTests/FunctionalAPITests.hs | 2 +- tests/PostgresSchemaDump.hs | 4 ++-- tests/ServerTests.hs | 4 ++-- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/simplexmq.cabal b/simplexmq.cabal index 11384f5ae..b70911391 100644 --- a/simplexmq.cabal +++ b/simplexmq.cabal @@ -602,7 +602,7 @@ test-suite simplexmq-test default-extensions: StrictData -- add -fhpc to ghc-options to run tests with coverage - ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-kind-signatures -Wno-missing-deriving-strategies -Wno-monomorphism-restriction -Wno-prepositive-qualified-module -Wno-implicit-prelude -Wno-missing-safe-haskell-mode -Wno-missing-export-lists -Wno-partial-fields -Wcompat -Werror=incomplete-record-updates -Werror=incomplete-patterns -Werror=incomplete-uni-patterns -Werror=missing-methods -Werror=tabs -Wredundant-constraints -Wincomplete-record-updates -Wunused-type-patterns -O2 -threaded -rtsopts -with-rtsopts=-A64M -with-rtsopts=-N1 + ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-kind-signatures -Wno-missing-deriving-strategies -Wno-monomorphism-restriction -Wno-prepositive-qualified-module -Wno-implicit-prelude -Wno-missing-safe-haskell-mode -Wno-missing-export-lists -Wno-partial-fields -Wcompat -Werror=incomplete-record-updates -Werror=incomplete-patterns -Werror=incomplete-uni-patterns -Werror=missing-methods -Werror=tabs -Wredundant-constraints -Wincomplete-record-updates -Wunused-type-patterns -O2 -threaded -rtsopts "-with-rtsopts=-A64M -N1" build-depends: base , aeson diff --git a/src/Simplex/Messaging/Notifications/Server/Store/ntf_server_schema.sql b/src/Simplex/Messaging/Notifications/Server/Store/ntf_server_schema.sql index 801208aaa..35e4ff47f 100644 --- a/src/Simplex/Messaging/Notifications/Server/Store/ntf_server_schema.sql +++ b/src/Simplex/Messaging/Notifications/Server/Store/ntf_server_schema.sql @@ -1,5 +1,6 @@ + SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -312,3 +313,4 @@ ALTER TABLE ONLY ntf_server.subscriptions + diff --git a/src/Simplex/Messaging/Server/QueueStore/Postgres/server_schema.sql b/src/Simplex/Messaging/Server/QueueStore/Postgres/server_schema.sql index fcaaf7257..c39b82990 100644 --- a/src/Simplex/Messaging/Server/QueueStore/Postgres/server_schema.sql +++ b/src/Simplex/Messaging/Server/QueueStore/Postgres/server_schema.sql @@ -1,5 +1,6 @@ + SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -554,3 +555,4 @@ ALTER TABLE ONLY smp_server.msg_queues + diff --git a/tests/AgentTests/FunctionalAPITests.hs b/tests/AgentTests/FunctionalAPITests.hs index 090e8b2f3..ebcd8d7d1 100644 --- a/tests/AgentTests/FunctionalAPITests.hs +++ b/tests/AgentTests/FunctionalAPITests.hs @@ -5052,9 +5052,9 @@ testServerQueueInfo = do get bob =##> \case ("", c, Msg' mId PQEncOn "hello 4") -> c == aliceId && mId == msgId4; _ -> False ackMessage bob aliceId msgId4 Nothing liftIO $ threadDelay 200000 - Just _ <- checkMsgQ bob aliceId 1 -- the one that did not fit now accepted get alice ##> ("", bobId, QCONT) get alice ##> ("", bobId, SENT msgId5) + Just _ <- checkMsgQ bob aliceId 1 -- the one that did not fit now accepted liftIO $ threadDelay 200000 Just _srvMsgId <- checkQ bob aliceId True (Just QNoSub) 1 (Just MTMessage) get bob =##> \case ("", c, Msg' mId PQEncOn "hello: quota exceeded") -> c == aliceId && mId == msgId5 + 1; _ -> False diff --git a/tests/PostgresSchemaDump.hs b/tests/PostgresSchemaDump.hs index 3aa0a18c6..a0f3fe45b 100644 --- a/tests/PostgresSchemaDump.hs +++ b/tests/PostgresSchemaDump.hs @@ -15,6 +15,7 @@ import qualified Simplex.Messaging.Agent.Store.Postgres.Migrations as Migrations import Simplex.Messaging.Agent.Store.Shared (Migration (..), MigrationConfig (..), MigrationConfirmation (..), MigrationsToRun (..), toDownMigration) import Simplex.Messaging.Util (ifM, whenM) import System.Directory (doesFileExist, removeFile) +import System.Info (os) import System.Process (readCreateProcess, shell) import Test.Hspec hiding (fit, it) import Util @@ -57,14 +58,13 @@ postgresSchemaDumpTest migrations skipComparisonForDownMigrations testDBOpts@DBO getSchema :: FilePath -> IO String getSchema schemaPath = do - ci <- envCI let cmd = ("pg_dump " <> B.unpack connstr <> " --schema " <> B.unpack testDBSchema) <> " --schema-only --no-owner --no-privileges --no-acl --no-subscriptions --no-tablespaces > " <> schemaPath void $ readCreateProcess (shell cmd) "" threadDelay 20000 - let sed = (if ci then "sed -i" else "sed -i ''") + let sed = (if os == "linux" then "sed -i" else "sed -i ''") void $ readCreateProcess (shell $ sed <> " '/^--/d; /^\\\\restrict/d; /^\\\\unrestrict/d' " <> schemaPath) "" sch <- readFile schemaPath sch `deepseq` pure sch diff --git a/tests/ServerTests.hs b/tests/ServerTests.hs index 89ac46144..aff1fdbe0 100644 --- a/tests/ServerTests.hs +++ b/tests/ServerTests.hs @@ -905,7 +905,7 @@ testServiceSubsTotalCount = _ -> pure Nothing ] threadDelay 1500000 - readFile testPrometheusMetricsFile >>= \m -> readServiceSubsMetric m `shouldBe` Just 2 + B.readFile testPrometheusMetricsFile >>= \m -> readServiceSubsMetric (B.unpack m) `shouldBe` Just 2 -- Phase 2: associate 1 more queue via SUB, reconnect with SUBS 3, check metric = 3 (rPub3, rKey3) <- atomically $ C.generateAuthKeyPair C.SEd25519 g @@ -935,7 +935,7 @@ testServiceSubsTotalCount = _ -> pure Nothing ] threadDelay 1500000 - readFile testPrometheusMetricsFile >>= \m -> readServiceSubsMetric m `shouldBe` Just 3 + B.readFile testPrometheusMetricsFile >>= \m -> readServiceSubsMetric (B.unpack m) `shouldBe` Just 3 readServiceSubsMetric :: String -> Maybe Int readServiceSubsMetric content =