diff --git a/tests/AgentTests/NotificationTests.hs b/tests/AgentTests/NotificationTests.hs index 10c5da99a..7ad997aea 100644 --- a/tests/AgentTests/NotificationTests.hs +++ b/tests/AgentTests/NotificationTests.hs @@ -157,10 +157,10 @@ notificationTests ps@(t, _) = do it "should resume subscriptions after SMP server is restarted" $ withAPNSMockServer $ \apns -> withNtfServer t $ testNotificationsSMPRestart ps apns - describe "Notifications after SMP server restart" $ + describe "Notifications after SMP server restart (batched)" $ it "should resume batched subscriptions after SMP server is restarted" $ withAPNSMockServer $ \apns -> - withNtfServer t $ testNotificationsSMPRestartBatch 100 ps apns + withNtfServer t $ testNotificationsSMPRestartBatch 50 ps apns describe "should switch notifications to the new queue" $ testServerMatrix2 ps $ \servers -> withAPNSMockServer $ \apns -> @@ -228,8 +228,6 @@ v .-> key = do testNtfTokenRepeatRegistration :: APNSMockServer -> IO () testNtfTokenRepeatRegistration apns = do - -- setLogLevel LogError -- LogDebug - -- withGlobalLogging logCfg $ do withAgent 1 agentCfg initAgentServers testDB $ \a -> runRight_ $ do let tkn = DeviceToken PPApnsTest "abcd" NTRegistered <- registerNtfToken a tkn NMPeriodic @@ -249,8 +247,6 @@ testNtfTokenRepeatRegistration apns = do testNtfTokenSecondRegistration :: APNSMockServer -> IO () testNtfTokenSecondRegistration apns = - -- setLogLevel LogError -- LogDebug - -- withGlobalLogging logCfg $ do withAgentClients2 $ \a a' -> runRight_ $ do let tkn = DeviceToken PPApnsTest "abcd" NTRegistered <- registerNtfToken a tkn NMPeriodic diff --git a/tests/SMPClient.hs b/tests/SMPClient.hs index 66fb894a5..69e670b06 100644 --- a/tests/SMPClient.hs +++ b/tests/SMPClient.hs @@ -14,7 +14,6 @@ module SMPClient where -import Control.Logger.Simple (LogLevel (..)) import Control.Monad.Except (runExceptT) import Data.ByteString.Char8 (ByteString) import Data.List.NonEmpty (NonEmpty) @@ -228,7 +227,7 @@ cfgMS msType = } defaultStartOptions :: StartOptions -defaultStartOptions = StartOptions {maintenance = False, compactLog = False, logLevel = LogError, skipWarnings = False, confirmMigrations = MCYesUp} +defaultStartOptions = StartOptions {maintenance = False, compactLog = False, logLevel = testLogLevel, skipWarnings = False, confirmMigrations = MCYesUp} serverStoreConfig :: AStoreType -> AServerStoreCfg serverStoreConfig = serverStoreConfig_ False diff --git a/tests/Test.hs b/tests/Test.hs index f1f26133e..06c627514 100644 --- a/tests/Test.hs +++ b/tests/Test.hs @@ -31,6 +31,7 @@ import Simplex.Messaging.Transport (TLS, Transport (..)) import System.Directory (createDirectoryIfMissing, removeDirectoryRecursive) import System.Environment (setEnv) import Test.Hspec hiding (fit, it) +import Util import XFTPAgent import XFTPCLI import XFTPServerTests (xftpServerTests) @@ -59,8 +60,7 @@ logCfg = LogConfig {lc_file = Nothing, lc_stderr = True} main :: IO () main = do - -- TODO [ntfdb] running wiht LogWarn level shows potential issue "Queue count differs" - setLogLevel LogError -- LogInfo -- also change in Util.hs (it) and SMPClient.hs (defaultStartOptions) + setLogLevel testLogLevel withGlobalLogging logCfg $ do setEnv "APNS_KEY_ID" "H82WD9K9AQ" setEnv "APNS_KEY_FILE" "./tests/fixtures/AuthKey_H82WD9K9AQ.p8" diff --git a/tests/Util.hs b/tests/Util.hs index b97e284bc..75d596642 100644 --- a/tests/Util.hs +++ b/tests/Util.hs @@ -44,17 +44,22 @@ removeFileIfExists filePath = do newtype TestWrapper a = TestWrapper a +-- TODO [ntfdb] running wiht LogWarn level shows potential issue "Queue count differs" +testLogLevel :: LogLevel +testLogLevel = LogError + instance Example a => Example (TestWrapper a) where type Arg (TestWrapper a) = Arg a evaluateExample (TestWrapper action) params hooks state = do - let runTest = - timeout 60000000 (evaluateExample action params hooks state) >>= \case + let tt = 120 + runTest = + timeout (tt * 1000000) (evaluateExample action params hooks state) >>= \case Just r -> pure r - Nothing -> throwIO $ userError "test timed out after 60 seconds" + Nothing -> throwIO $ userError $ "test timed out after " <> show tt <> " seconds" retryTest = do - putStrLn "Retrying with Debug logging..." - setLogLevel LogDebug - runTest `finally` setLogLevel LogError -- change this to match log level in Test.hs + putStrLn "Retrying with more logs..." + setLogLevel LogNote + runTest `finally` setLogLevel testLogLevel -- change this to match log level in Test.hs E.try runTest >>= \case Right r -> case resultStatus r of Failure loc_ reason -> do