diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b957b5aab..33309c0ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,6 +106,7 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + --shm-size 1g ports: # Maps tcp port 5432 on service container to the host - 5432:5432 @@ -131,6 +132,7 @@ jobs: runner: "ubuntu-24.04" ghc: "9.6.3" should_run: true + client_postgres: true - os: 22.04 os_underscore: 22_04 arch: aarch64 @@ -246,6 +248,7 @@ jobs: path: | dist-newstyle dist-postgres + dist-client-postgres key: ${{ steps.keys.outputs.dist }}-${{ env.opt }}-${{ env.branch }}-${{ github.sha }} restore-keys: | ${{ steps.keys.outputs.dist }}-${{ env.opt }}-${{ env.branch }}- @@ -264,8 +267,8 @@ jobs: if: matrix.should_run == true shell: docker exec -t builder sh -eu {0} run: | - chmod -fR 777 ~/.cabal ./dist-newstyle ./dist-postgres || :; git config --global --add safe.directory '*' - scripts/ci/prune-old-builds.sh dist-newstyle dist-postgres + chmod -fR 777 ~/.cabal ./dist-newstyle ./dist-postgres ./dist-client-postgres || :; git config --global --add safe.directory '*' + scripts/ci/prune-old-builds.sh dist-newstyle dist-postgres dist-client-postgres cabal update cabal build --builddir=${{ env.postgres_dist }} --jobs=$(nproc) --enable-tests -fserver_postgres ${{ env.ghc_options }} mkdir -p /out @@ -282,6 +285,21 @@ jobs: run: | docker cp builder:/out/simplexmq-test . + - name: Build tests with PostgreSQL agent store + id: build-client-postgres + if: matrix.should_run == true && matrix.client_postgres == true + shell: docker exec -t builder sh -eu {0} + run: | + cabal build --builddir=dist-client-postgres --jobs=$(nproc) --enable-tests -fserver_postgres -fclient_postgres -fslow_servers ${{ env.ghc_options }} simplexmq-test + bin=$(find /project/dist-client-postgres -name simplexmq-test -type f -executable) + cp "$bin" /out/simplexmq-test-client-postgres + + - name: Copy simplexmq-test-client-postgres from container + if: matrix.should_run == true && matrix.client_postgres == true + shell: bash + run: | + docker cp builder:/out/simplexmq-test-client-postgres . + - name: Copy smp-server, xftp-server (postgresql) from container and prepare it if: startsWith(github.ref, 'refs/tags/v') && matrix.should_run == true id: prepare-postgres @@ -387,6 +405,7 @@ jobs: path: | dist-newstyle dist-postgres + dist-client-postgres key: ${{ steps.keys.outputs.dist }}-${{ env.opt }}-${{ env.branch }}-${{ github.sha }} - name: Increase PostgreSQL connection limit @@ -405,11 +424,25 @@ jobs: sudo mount -t tmpfs -o size=2G tmpfs tests/tmp sudo chown $(id -u):$(id -g) tests/tmp + - name: Setup Node.js + if: matrix.should_run == true && matrix.arch == 'x86-64' + uses: actions/setup-node@v7 + with: + node-version: 22 + + - name: Build xftp-web for tests + if: matrix.should_run == true && matrix.arch == 'x86-64' + working-directory: xftp-web + run: | + npm install + ln -sf ../../../libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs node_modules/libsodium-wrappers-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs + npm run build + - name: Test if: matrix.should_run == true && matrix.arch == 'x86-64' timeout-minutes: 120 shell: bash - env: + env: &test-env PGHOST: localhost REDUCED: ${{ needs.maybe-release.outputs.reduced }} TESTS: ${{ github.event_name == 'workflow_dispatch' && inputs.tests || '' }} @@ -417,11 +450,23 @@ jobs: ATTEMPTS: ${{ (github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) && 3 || 1 }} run: scripts/ci/run-tests.sh ./simplexmq-test + - name: Test with PostgreSQL agent store + if: ${{ !cancelled() && steps.build-client-postgres.outcome == 'success' }} + timeout-minutes: 120 + shell: bash + env: *test-env + run: scripts/ci/run-tests.sh ./simplexmq-test-client-postgres + + - name: Check generated files + if: ${{ !cancelled() && matrix.should_run == true && matrix.arch == 'x86-64' }} + shell: bash + run: git diff --exit-code + - name: Remove -O2 build directories id: remove-o2 if: env.cache_o0 == 'true' && !cancelled() && steps.build-postgres.outcome == 'success' && steps.build-standard.outcome != 'failure' shell: docker exec -t builder sh -eu {0} - run: rm -rf dist-newstyle dist-postgres + run: rm -rf dist-newstyle dist-postgres dist-client-postgres - name: Restore -O0 build directories from cache id: restore-build-o0 @@ -431,6 +476,7 @@ jobs: path: | dist-newstyle dist-postgres + dist-client-postgres key: ${{ steps.keys.outputs.dist }}-O0-${{ env.branch }}-${{ github.sha }} restore-keys: | ${{ steps.keys.outputs.dist }}-O0-${{ env.branch }}- @@ -445,9 +491,12 @@ jobs: if: ${{ !cancelled() && steps.remove-o2.outcome == 'success' }} shell: docker exec -t builder sh -eu {0} run: | - scripts/ci/prune-old-builds.sh dist-newstyle dist-postgres + scripts/ci/prune-old-builds.sh dist-newstyle dist-postgres dist-client-postgres cabal build --builddir=dist-postgres --jobs=$(nproc) --enable-tests -fserver_postgres --ghc-options=-O0 cabal build --jobs=$(nproc) --ghc-options=-O0 + if [ "${{ matrix.client_postgres }}" = true ]; then + cabal build --builddir=dist-client-postgres --jobs=$(nproc) --enable-tests -fserver_postgres -fclient_postgres -fslow_servers --ghc-options=-O0 simplexmq-test + fi - name: Record source hashes for -O0 build (GHC 8.10.7) if: ${{ !cancelled() && matrix.ghc == '8.10.7' && steps.build-o0.outcome == 'success' }} @@ -461,6 +510,7 @@ jobs: path: | dist-newstyle dist-postgres + dist-client-postgres key: ${{ steps.keys.outputs.dist }}-O0-${{ env.branch }}-${{ github.sha }} build-reduced: @@ -482,6 +532,7 @@ jobs: runner: "ubuntu-24.04" ghc: "9.6.3" should_run: true + client_postgres: true steps: *build-steps # ============================= diff --git a/scripts/ci/README.md b/scripts/ci/README.md index 60287eae9..dd57e687d 100644 --- a/scripts/ci/README.md +++ b/scripts/ci/README.md @@ -9,7 +9,7 @@ | a push to a draft pull request
a manual run (workflow_dispatch)
a push to master or stable in a fork | reduced | build-reduced: ubuntu-24.04 x86-64, GHC 9.6.3, at -O0 (-O2 on pushes), without the standard build | | a pull request marked ready for review, and later pushes to it
a push to master or stable in simplex-chat/simplexmq
a push of a v* tag | full | build: 5 entries (GHC 8.10.7 and 9.6.3, x86-64 and aarch64), at -O0 on pull requests and -O2 on pushes | -Both builds also run maybe-release and resolver (python). Tests run on the x86-64 entries. The reduced build restores the -O0 build caches saved by master pushes; the Docker image cache is tagged by ISO week, so the first run of a week rebuilds the image. +Both builds also run maybe-release and resolver (python). Tests run on the x86-64 entries, after xftp-web is built with Node.js 22 (`npm install`, `npm run build`) for the XFTP Web Client tests. The ubuntu-24.04 x86-64 entry also runs the tests built with `-fclient_postgres -fslow_servers` (agent with the PostgreSQL store, and XFTP servers that delay responses for the slow-server test, which the other builds skip), in the build directory dist-client-postgres, in step "Test with PostgreSQL agent store". After the tests, step "Check generated files" fails if a test changed a tracked file: the schema dump and query plan tests overwrite their files, so a stale file fails here even when the test passes on retry. The reduced build restores the -O0 build caches saved by master pushes; the Docker image cache is tagged by ISO week, so the first run of a week rebuilds the image. ## Test selection diff --git a/simplexmq.cabal b/simplexmq.cabal index afd7c0cd1..e2b208997 100644 --- a/simplexmq.cabal +++ b/simplexmq.cabal @@ -84,6 +84,11 @@ flag client_postgres manual: True default: False +flag slow_servers + description: Delay XFTP server responses by responseDelay, for tests. + manual: True + default: False + flag server_postgres description: Build server with support of PostgreSQL. manual: True @@ -402,6 +407,8 @@ library default-language: Haskell2010 if flag(swift) cpp-options: -DswiftJSON + if flag(slow_servers) + cpp-options: -Dslow_servers if !flag(client_library) build-depends: case-insensitive ==1.2.* @@ -653,6 +660,8 @@ test-suite simplexmq-test default-language: Haskell2010 if flag(server_postgres) cpp-options: -DdbServerPostgres + if flag(slow_servers) + cpp-options: -Dslow_servers if flag(client_postgres) cpp-options: -DdbPostgres else diff --git a/src/Simplex/Messaging/Agent/Store/Postgres/Migrations/agent_postgres_schema.sql b/src/Simplex/Messaging/Agent/Store/Postgres/Migrations/agent_postgres_schema.sql index bbcacfd01..33de2a8de 100644 --- a/src/Simplex/Messaging/Agent/Store/Postgres/Migrations/agent_postgres_schema.sql +++ b/src/Simplex/Messaging/Agent/Store/Postgres/Migrations/agent_postgres_schema.sql @@ -177,7 +177,7 @@ CREATE TABLE smp_agent_test_protocol_schema.commands ( command bytea NOT NULL, agent_version integer DEFAULT 1 NOT NULL, server_key_hash bytea, - created_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+01'::timestamp with time zone NOT NULL, + created_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+00'::timestamp with time zone NOT NULL, failed smallint DEFAULT 0 ); @@ -240,7 +240,7 @@ CREATE TABLE smp_agent_test_protocol_schema.connections ( ratchet_sync_state text DEFAULT 'ok'::text NOT NULL, deleted_at_wait_delivery timestamp with time zone, pq_support smallint DEFAULT 0 NOT NULL, - created_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+01'::timestamp with time zone NOT NULL, + created_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+00'::timestamp with time zone NOT NULL, service_request_expires_at timestamp with time zone ); diff --git a/tests/AgentTests/FunctionalAPITests.hs b/tests/AgentTests/FunctionalAPITests.hs index c7e4443aa..18ee7dd8a 100644 --- a/tests/AgentTests/FunctionalAPITests.hs +++ b/tests/AgentTests/FunctionalAPITests.hs @@ -359,9 +359,9 @@ functionalAPITests ps = do withSmpServer ps testX25519SndKeys describe "Duplex connection - delivery stress test" $ do describe "one way (50)" $ testMatrix2Stress ps $ runAgentClientStressTestOneWay 50 - xdescribe "one way (1000)" $ testMatrix2Stress ps $ runAgentClientStressTestOneWay 1000 + describe "one way (200)" $ testMatrix2Stress ps $ runAgentClientStressTestOneWay 200 describe "two way concurrently (50)" $ testMatrix2Stress ps $ runAgentClientStressTestConc 50 - xdescribe "two way concurrently (1000)" $ testMatrix2Stress ps $ runAgentClientStressTestConc 1000 + describe "two way concurrently (200)" $ testMatrix2Stress ps $ runAgentClientStressTestConc 200 describe "Establishing duplex connection, different PQ settings" $ do testPQMatrix2 ps $ runAgentClientTestPQ True describe "Establishing duplex connection v2, different Ratchet versions" $ @@ -530,12 +530,10 @@ functionalAPITests ps = do it "should send messages queued after file is sent before agent is suspended" $ testSuspendingAgentCompleteSendingFile ps describe "Batching SMP commands" $ do - -- disable this and enable the following test to run tests with coverage it "should subscribe to multiple (200) subscriptions with batching" $ testBatchedSubscriptions 200 20 ps - skip "faster version of the previous test (200 subscriptions gets very slow with test coverage)" $ - it "should subscribe to multiple (6) subscriptions with batching" $ - testBatchedSubscriptions 6 3 ps + it "should subscribe to multiple (6) subscriptions with batching" $ + testBatchedSubscriptions 6 3 ps it "should subscribe to multiple connections with pending messages" $ withSmpServer ps $ testBatchedPendingMessages 10 5 @@ -668,10 +666,11 @@ functionalAPITimingTests ps = do describe "SMP queue info" $ do it "server should respond with queue and subscription information" $ withSmpServer ps testServerQueueInfo -#if !defined(dbServerPostgres) - describe "Client notices" $ do - it "should create client notice" $ testClientNotice ps -#endif + case ps of + (_, ASType SQSMemory _) -> + describe "Client notices" $ do + it "should create client notice" $ testClientNotice ps + _ -> pure () testBasicAuth :: HasTestEnv => (ASrvTransport, AStoreType) -> Bool -> (Maybe BasicAuth, VersionSMP) -> (Maybe BasicAuth, VersionSMP) -> (Maybe BasicAuth, VersionSMP) -> SndQueueSecured -> AgentMsgId -> IO Int testBasicAuth (t, msType) allowNewQueues srv@(srvAuth, srvVersion) clnt1 clnt2 sqSecured baseId = do @@ -3394,14 +3393,20 @@ testBatchedSubscriptions nCreate nDel ps@(t, ASType qsType _) = do deleteFail a bIds' deleteFail b aIds' where - down c cs = do - ("", "", DOWN _ cs1) <- nGet c - ("", "", DOWN _ cs2) <- nGet c - liftIO $ S.fromList (cs1 ++ cs2) `shouldBe` S.fromList cs - up c cs = do - ("", "", UP _ cs1) <- nGet c - ("", "", UP _ cs2) <- nGet c - liftIO $ S.fromList (cs1 ++ cs2) `shouldBe` S.fromList cs + down c = receivedFor $ do + ("", "", DOWN _ cs') <- nGet c + pure cs' + up c = receivedFor $ do + ("", "", UP _ cs') <- nGet c + pure cs' + receivedFor getConns cs = go S.empty + where + go received + | received == S.fromList cs = pure () + | otherwise = do + cs' <- getConns + liftIO $ S.fromList cs' `S.isSubsetOf` S.fromList cs `shouldBe` True + go $ received <> S.fromList cs' subscribe :: AgentClient -> [ConnId] -> ExceptT AgentErrorType IO () subscribe c cs = do subscribeAllConnections c False Nothing diff --git a/tests/README.md b/tests/README.md index 2a51e23cd..b9922ae53 100644 --- a/tests/README.md +++ b/tests/README.md @@ -2,6 +2,6 @@ 1. Uncomment coverage sections in cabal.project file. 2. Add `-fhpc` to ghc-options of simplexmq-test in simplexmq.cabal file. -3. Disable (`xit`) test "should subscribe to multiple (200) subscriptions with batching", enable (comment `skip`) the next test instead. +3. Disable (`xit`) test "should subscribe to multiple (200) subscriptions with batching". 4. Run `cabal test`. 5. Open generated coverage report in the browser. diff --git a/tests/SMPClient.hs b/tests/SMPClient.hs index 9ca5f764c..1dd2b3636 100644 --- a/tests/SMPClient.hs +++ b/tests/SMPClient.hs @@ -39,10 +39,9 @@ import Simplex.Messaging.Transport import Simplex.Messaging.Transport.Client import Simplex.Messaging.Transport.Server import Simplex.Messaging.Transport.Shared (ChainCertificates (..), chainIdCaCerts) -import Simplex.Messaging.Util (ifM, unlessM) +import Simplex.Messaging.Util (unlessM) import Simplex.Messaging.Version import Simplex.Messaging.Version.Internal -import System.Info (os) import Test.Hspec hiding (fit, it) import UnliftIO.Concurrent import qualified UnliftIO.Exception as E @@ -140,15 +139,6 @@ testPrometheusMetricsFile = testPath "smp-server-metrics.txt" testServerStatsBackupFile :: HasTestEnv => FilePath testServerStatsBackupFile = testPath "smp-server-stats.log" -xit' :: (HasCallStack, Example a) => String -> (HasTestEnv => a) -> SpecWith (Arg a) -xit' d t = if os == "linux" then skip "skipped on Linux" $ it d t else it d t - -xit'' :: (HasCallStack, Example a) => String -> (HasTestEnv => a) -> SpecWith (Arg a) -xit'' d t = skipOnCI $ it d t - -skipOnCI :: SpecWith a -> SpecWith a -skipOnCI t = ifM (runIO envCI) (skip "skipped on CI" t) t - testSMPClient :: (HasTestEnv, Transport c) => (THandleSMP c 'TClient -> IO a) -> IO a testSMPClient = testSMPClientVR supportedClientSMPRelayVRange diff --git a/tests/SMPProxyTests.hs b/tests/SMPProxyTests.hs index e60631b20..59bb14b53 100644 --- a/tests/SMPProxyTests.hs +++ b/tests/SMPProxyTests.hs @@ -76,12 +76,6 @@ smpProxyTests = do it "reconnects after a connect is cancelled mid-flight" $ \_ -> testAgentClientReconnectAfterCancel describe "proxy requests" $ do - describe "bad relay URIs" $ do - xit "host not resolved" todo - xit "when SMP port blackholed" todo - xit "no SMP service at host/port" todo - xit "bad SMP fingerprint" todo - xit "batching proxy requests" todo it "relay rejects forwarded command with changed version" $ \_ -> testChangedFwdVersion it "proxy rejects forwarded correlation ID that is not 24 bytes" $ \_ -> @@ -122,21 +116,16 @@ smpProxyTests = do it "1x1000" $ twoServersFirstProxy $ deliver 1000 it "5x200" $ twoServersFirstProxy $ 5 `inParrallel` deliver 200 it "10x100" $ twoServersFirstProxy $ 10 `inParrallel` deliver 100 + it "100x10 N1" $ twoServersFirstProxy $ withNumCapabilities 1 $ 100 `inParrallel` deliver 10 + it "100x10 N4 C1" $ twoServersNoConc $ withNumCapabilities 4 $ 100 `inParrallel` deliver 10 + it "100x10 N4 C2" $ twoServersFirstProxy $ withNumCapabilities 4 $ 100 `inParrallel` deliver 10 + it "100x10 N4 C16" $ twoServersMoreConc $ withNumCapabilities 4 $ 100 `inParrallel` deliver 10 + it "100x10 N" $ twoServersFirstProxy $ withNCPUCapabilities $ 100 `inParrallel` deliver 10 it "500x20" $ twoServersFirstProxy $ 500 `inParrallel` deliver 20 describe "stress test - no host" $ do it "1x1000, no delay" $ oneServer $ proxyConnectDeadRelay 1000 0 srv1 - xit "1x1000, 100ms" $ oneServer $ proxyConnectDeadRelay 1000 100000 srv1 - xit "100x1000, 100ms" $ oneServer $ 100 `inParrallel` (randomRIO (0, 1000000) >>= threadDelay >> proxyConnectDeadRelay 1000 100000 srv1) - xdescribe "stress test 10k" $ do - let deliver n = deliverMessagesViaProxy srv1 srv2 C.SEd448 [] (map bshow [1 :: Int .. n]) - it "1x10000" $ twoServersFirstProxy $ deliver 10000 - it "5x2000" $ twoServersFirstProxy $ 5 `inParrallel` deliver 2000 - it "10x1000" $ twoServersFirstProxy $ 10 `inParrallel` deliver 1000 - it "100x100 N1" $ twoServersFirstProxy $ withNumCapabilities 1 $ 100 `inParrallel` deliver 100 - it "100x100 N4 C1" $ twoServersNoConc $ withNumCapabilities 4 $ 100 `inParrallel` deliver 100 - it "100x100 N4 C2" $ twoServersFirstProxy $ withNumCapabilities 4 $ 100 `inParrallel` deliver 100 - it "100x100 N4 C16" $ twoServersMoreConc $ withNumCapabilities 4 $ 100 `inParrallel` deliver 100 - it "100x100 N" $ twoServersFirstProxy $ withNCPUCapabilities $ 100 `inParrallel` deliver 100 + it "1x100, 100ms" $ oneServer $ proxyConnectDeadRelay 100 100000 srv1 + it "100x100, 100ms" $ oneServer $ 100 `inParrallel` (randomRIO (0, 1000000) >>= threadDelay >> proxyConnectDeadRelay 100 100000 srv1) describe "agent API" $ do describe "one server" $ do it "always via proxy" $ oneServer $ @@ -166,9 +155,7 @@ smpProxyTests = do describe "stress test 1k" $ do let deliver nAgents nMsgs = agentDeliverMessagesViaProxyConc (replicate nAgents [srv1]) (map bshow [1 :: Int .. nMsgs]) it "2 agents, 250 messages" $ oneServer $ deliver 2 250 - xdescribe "stress test 10k" $ do - let deliver nAgents nMsgs = agentDeliverMessagesViaProxyConc (replicate nAgents [srv1]) (map bshow [1 :: Int .. nMsgs]) - it "25 agents, 300 pairs, 17 messages" $ oneServer $ withNumCapabilities 4 $ deliver 25 17 + it "10 agents, 45 pairs, 11 messages" $ oneServer $ withNumCapabilities 4 $ deliver 10 11 where twoServers test msType = twoServers_ (proxyCfgMS msType) (proxyCfgMS msType) test msType twoServersFirstProxy test msType = twoServers_ (proxyCfgMS msType) (updateCfg (cfgMS msType) $ \cfg_ -> cfg_ {msgQueueQuota = 128}) test msType @@ -666,9 +653,6 @@ testAgentClientReconnectAfterCancel = netCfg = (netCfg initAgentServers) {tcpConnectTimeout = NetworkTimeout 4000000 4000000} } -todo :: AStoreType -> IO () -todo _ = fail "TODO" - runExceptT' :: Exception e => ExceptT e IO a -> IO a runExceptT' a = runExceptT a >>= either throwIO pure diff --git a/tests/ServerTests.hs b/tests/ServerTests.hs index 11928e29b..59ed02c1a 100644 --- a/tests/ServerTests.hs +++ b/tests/ServerTests.hs @@ -53,7 +53,6 @@ import Simplex.Messaging.Server.Expiration import Simplex.Messaging.Server.MsgStore.Types (SMSType (..), SQSType (..)) import Simplex.Messaging.Server.QueueStore.QueueInfo (QSub (..), QSubThread (..), QueueInfo (..)) import Simplex.Messaging.Server.Stats (PeriodStatsData (..), ServerStatsData (..)) -import Simplex.Messaging.Server.StoreLog (StoreLogRecord (..)) import Simplex.Messaging.Transport import Simplex.Messaging.Transport.Credentials import System.Directory (doesFileExist, removeFile) @@ -2112,18 +2111,18 @@ testMsgNOTExpireOnInterval = testBlockMessageQueue :: SpecWith (ASrvTransport, AStoreType) testBlockMessageQueue = - -- TODO [postgres] - xit "should return BLOCKED error when queue is blocked" $ \ps@(ATransport (t :: TProxy c 'TServer), _) -> do + it "should return BLOCKED error when queue is blocked" $ \ps@(at@(ATransport (t :: TProxy c 'TServer)), msType) -> do g <- C.newRandom - (rId, sId) <- withSmpServerStoreLogOn ps testPort $ runTest t $ \h -> do + let cpPort = testServerPort 8 + cfg' = updateCfg (cfgMS msType) $ \cfg_ -> cfg_ {controlPort = Just cpPort, controlPortAdminAuth = Just "admin"} + sId <- withSmpServerConfigOn at cfg' testPort $ runTest t $ \h -> do (rPub, rKey) <- atomically $ C.generateAuthKeyPair C.SEd448 g (dhPub, _dhPriv :: C.PrivateKeyX25519) <- atomically $ C.generateKeyPair g - Resp "abcd" rId1 (Ids rId sId _srvDh) <- signSendRecv h rKey ("abcd", NoEntity, New rPub dhPub) + Resp "abcd" rId1 (Ids _rId sId _srvDh) <- signSendRecv h rKey ("abcd", NoEntity, New rPub dhPub) (rId1, NoEntity) #== "creates queue" - pure (rId, sId) - - -- TODO [postgres] block via control port - withFile testStoreLogFile AppendMode $ \h -> B.hPutStrLn h $ strEncode $ BlockQueue rId $ BlockingInfo BRContent Nothing + [_, blocked] <- controlPortCommands cpPort ["auth admin", "block " <> B.unpack (strEncode sId) <> " " <> B.unpack (strEncode $ BlockingInfo BRContent Nothing)] + blocked `shouldStartWith` "ok, queue blocked" + pure sId withSmpServerStoreLogOn ps testPort $ runTest t $ \h -> do (sPub, sKey) <- atomically $ C.generateAuthKeyPair C.SEd448 g diff --git a/tests/Util.hs b/tests/Util.hs index 011dea238..41361af51 100644 --- a/tests/Util.hs +++ b/tests/Util.hs @@ -31,9 +31,6 @@ import Test.Hspec hiding (fit, it, xit) import qualified Test.Hspec as Hspec import Test.Hspec.Core.Spec (Example (..), Result (..), ResultStatus (..)) -skip :: String -> SpecWith a -> SpecWith a -skip = before_ . pendingWith - withNumCapabilities :: Int -> IO a -> IO a withNumCapabilities new a = getNumCapabilities >>= \old -> bracket_ (setNumCapabilities new) (setNumCapabilities old) a diff --git a/tests/XFTPAgent.hs b/tests/XFTPAgent.hs index 5c7d50ce1..8dc8c0bb7 100644 --- a/tests/XFTPAgent.hs +++ b/tests/XFTPAgent.hs @@ -28,7 +28,6 @@ import qualified Data.Set as S import Data.Time.Clock (addUTCTime, getCurrentTime, nominalDay) import Data.Time.Clock.System (getSystemTime, systemSeconds) import SMPAgentClient (agentCfg, initAgentServers, testDB, testDB2, testDB3) -import SMPClient (xit'') import Simplex.FileTransfer.Client (XFTPClientConfig (..)) import Simplex.FileTransfer.Description (FileChunk (..), FileDescription (..), FileDescriptionURI (..), ValidFileDescription, fileDescriptionURI, kb, mb, qrSizeLimit, pattern ValidFileDescription) import Simplex.FileTransfer.Protocol (FileParty (..), GrantedStorageTime (..)) @@ -74,8 +73,11 @@ xftpAgentTests :: SpecWith AFStoreType xftpAgentTests = describe "agent XFTP API" $ do it "should send and receive file" $ withXFTPServer testXFTPAgentSendReceive - -- uncomment CPP option slow_servers and run hpack to run this test +#ifdef slow_servers + it "should send and receive file with slow server responses" $ \_ -> +#else xit "should send and receive file with slow server responses" $ \_ -> +#endif withXFTPServerCfg testXFTPServerConfig {responseDelay = 500000} $ \_ -> testXFTPAgentSendReceive it "should send and receive with encrypted local files" testXFTPAgentSendReceiveEncrypted @@ -90,7 +92,7 @@ xftpAgentTests = it "should cleanup rcv tmp path after permanent error" $ \_ -> testXFTPAgentReceiveCleanup it "should report permanent error even when rcv tmp path cannot be removed" $ \_ -> testXFTPAgentReceiveCleanupError it "should resume sending file after restart" $ \_ -> testXFTPAgentSendRestore - xit'' "should cleanup snd prefix path after permanent error" $ \_ -> testXFTPAgentSendCleanup + it "should cleanup snd prefix path after permanent error" $ \_ -> testXFTPAgentSendCleanup it "should delete sent file on server" testXFTPAgentDelete it "should resume deleting file after restart" $ \_ -> testXFTPAgentDeleteRestore -- TODO when server is fixed to correctly send AUTH error, this test has to be modified to expect AUTH error