Commit b466e791 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Replicate the issue (tsv silently imports empty ngrams)

parent 17a4f03a
Pipeline #7476 failed with stages
in 43 minutes and 28 seconds
...@@ -39,7 +39,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do ...@@ -39,7 +39,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
describe "Importing terms as TSV" $ do describe "Importing terms as TSV" $ do
it "[#381] should work" $ \(SpecContext testEnv port app _) -> do it "[#381] should work (and return a non-empty list of ngrams" $ \(SpecContext testEnv port app _) -> do
cId <- newCorpusForUser testEnv "alice" cId <- newCorpusForUser testEnv "alice"
let log_cfg = (test_config testEnv) ^. gc_logging let log_cfg = (test_config testEnv) ^. gc_logging
withApplication app $ do withApplication app $ do
...@@ -53,7 +53,8 @@ tests = sequential $ aroundAll withTestDBAndPort $ do ...@@ -53,7 +53,8 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
ji <- checkEither $ liftIO $ runClientM (add_tsv_to_list token listId params) clientEnv ji <- checkEither $ liftIO $ runClientM (add_tsv_to_list token listId params) clientEnv
_ <- pollUntilWorkFinished log_cfg port ji _ <- pollUntilWorkFinished log_cfg port ji
-- Now check that we can retrieve the ngrams -- Now check that we can retrieve the ngrams, and the ngrams list is not empty!
liftIO $ do liftIO $ do
eRes <- runClientM (get_table_ngrams token cId APINgrams.Terms listId 50 Nothing (Just MapTerm) Nothing Nothing Nothing Nothing) clientEnv eRes <- checkEither $ runClientM (get_table_ngrams token cId APINgrams.Terms listId 50 Nothing (Just MapTerm) Nothing Nothing Nothing Nothing) clientEnv
eRes `shouldSatisfy` isRight let (APINgrams.NgramsTable terms) = APINgrams._vc_data eRes
length terms `shouldSatisfy` (>= 1)
...@@ -7,11 +7,11 @@ module Test.API.Private.Remote ( ...@@ -7,11 +7,11 @@ module Test.API.Private.Remote (
) where ) where
import Control.Lens import Control.Lens
import Gargantext.API.Admin.EnvTypes (Mode(..))
import Gargantext.API.Errors import Gargantext.API.Errors
import Gargantext.API (makeApp) import Gargantext.API (makeApp)
import Gargantext.API.Routes.Client (remoteExportClient) import Gargantext.API.Routes.Client (remoteExportClient)
import Gargantext.API.Routes.Named.Remote (RemoteExportRequest(..)) import Gargantext.API.Routes.Named.Remote (RemoteExportRequest(..))
import Gargantext.Core.Config
import Gargantext.Core.Types.Individu import Gargantext.Core.Types.Individu
import Gargantext.Core.Types (NodeId(UnsafeMkNodeId)) import Gargantext.Core.Types (NodeId(UnsafeMkNodeId))
import Gargantext.Prelude import Gargantext.Prelude
...@@ -32,10 +32,10 @@ withTwoServerInstances :: (SpecContext (TestEnv,Wai.Application,Warp.Port) -> IO ...@@ -32,10 +32,10 @@ withTwoServerInstances :: (SpecContext (TestEnv,Wai.Application,Warp.Port) -> IO
withTwoServerInstances action = withTwoServerInstances action =
withTestDB $ \testEnv1 -> do withTestDB $ \testEnv1 -> do
withTestDB $ \testEnv2 -> do withTestDB $ \testEnv2 -> do
garg1App <- withLoggerIO Mock $ \ioLogger -> do garg1App <- withLoggerIO (log_cfg testEnv1) $ \ioLogger -> do
env <- newTestEnv testEnv1 ioLogger server1Port env <- newTestEnv testEnv1 ioLogger server1Port
makeApp env makeApp env
garg2App <- withLoggerIO Mock $ \ioLogger -> do garg2App <- withLoggerIO (log_cfg testEnv2) $ \ioLogger -> do
env <- newTestEnv testEnv2 ioLogger server2Port env <- newTestEnv testEnv2 ioLogger server2Port
makeApp env makeApp env
...@@ -45,6 +45,7 @@ withTwoServerInstances action = ...@@ -45,6 +45,7 @@ withTwoServerInstances action =
where where
server1Port = 8008 server1Port = 8008
server2Port = 9008 server2Port = 9008
log_cfg te = (test_config te) ^. gc_logging
tests :: Spec tests :: Spec
tests = sequential $ aroundAll withTwoServerInstances $ do tests = sequential $ aroundAll withTwoServerInstances $ do
......
...@@ -20,7 +20,7 @@ import Control.Monad.Reader ...@@ -20,7 +20,7 @@ import Control.Monad.Reader
import Data.ByteString.Lazy.Char8 qualified as C8L import Data.ByteString.Lazy.Char8 qualified as C8L
import Data.Cache qualified as InMemory import Data.Cache qualified as InMemory
import Data.Streaming.Network (bindPortTCP) import Data.Streaming.Network (bindPortTCP)
import Gargantext.API.Admin.EnvTypes (Mode(Mock), Env (..), env_dispatcher) import Gargantext.API.Admin.EnvTypes (Env (..), env_dispatcher)
import Gargantext.API.Errors.Types import Gargantext.API.Errors.Types
import Gargantext.API (makeApp) import Gargantext.API (makeApp)
import Gargantext.API.Prelude import Gargantext.API.Prelude
...@@ -112,7 +112,7 @@ nc = NotificationsConfig { _nc_central_exchange_bind = "tcp://*:15560" ...@@ -112,7 +112,7 @@ nc = NotificationsConfig { _nc_central_exchange_bind = "tcp://*:15560"
withTestDBAndPort :: (SpecContext () -> IO ()) -> IO () withTestDBAndPort :: (SpecContext () -> IO ()) -> IO ()
withTestDBAndPort action = withTestDB $ \testEnv -> do withTestDBAndPort action = withTestDB $ \testEnv -> do
withNotifications (cfg testEnv) $ \dispatcher -> do withNotifications (cfg testEnv) $ \dispatcher -> do
withLoggerIO Mock $ \ioLogger -> do withLoggerIO (log_cfg testEnv) $ \ioLogger -> do
env <- newTestEnv testEnv ioLogger 8080 env <- newTestEnv testEnv ioLogger 8080
<&> env_dispatcher .~ dispatcher <&> env_dispatcher .~ dispatcher
app <- makeApp env app <- makeApp env
...@@ -147,11 +147,11 @@ withTestDBAndPort action = withTestDB $ \testEnv -> do ...@@ -147,11 +147,11 @@ withTestDBAndPort action = withTestDB $ \testEnv -> do
withBackendServerAndProxy :: (((TestEnv, Warp.Port, Warp.Port)) -> IO ()) -> IO () withBackendServerAndProxy :: (((TestEnv, Warp.Port, Warp.Port)) -> IO ()) -> IO ()
withBackendServerAndProxy action = withBackendServerAndProxy action =
withTestDB $ \testEnv -> do withTestDB $ \testEnv -> do
gargApp <- withLoggerIO Mock $ \ioLogger -> do gargApp <- withLoggerIO (log_cfg testEnv) $ \ioLogger -> do
env <- newTestEnv testEnv ioLogger 8080 env <- newTestEnv testEnv ioLogger 8080
makeApp env makeApp env
proxyCache <- InMemory.newCache Nothing proxyCache <- InMemory.newCache Nothing
proxyApp <- withLoggerIO Mock $ \ioLogger -> do proxyApp <- withLoggerIO (log_cfg testEnv) $ \ioLogger -> do
env <- newTestEnv testEnv ioLogger 8080 env <- newTestEnv testEnv ioLogger 8080
pure $ microServicesProxyApp proxyCache env pure $ microServicesProxyApp proxyCache env
...@@ -160,6 +160,8 @@ withBackendServerAndProxy action = ...@@ -160,6 +160,8 @@ withBackendServerAndProxy action =
action (testEnv, serverPort, proxyPort) action (testEnv, serverPort, proxyPort)
where where
proxyPort = 8090 proxyPort = 8090
cfg te = test_config te
log_cfg te = (cfg te) ^. gc_logging
setupEnvironment :: TestEnv -> IO () setupEnvironment :: TestEnv -> IO ()
setupEnvironment env = flip runReaderT env $ runTestMonad $ do setupEnvironment env = flip runReaderT env $ runTestMonad $ do
......
...@@ -18,7 +18,6 @@ import Database.PostgreSQL.Simple qualified as PG ...@@ -18,7 +18,6 @@ import Database.PostgreSQL.Simple qualified as PG
import Database.PostgreSQL.Simple.Options qualified as Client import Database.PostgreSQL.Simple.Options qualified as Client
import Database.PostgreSQL.Simple.Options qualified as Opts import Database.PostgreSQL.Simple.Options qualified as Opts
import Database.Postgres.Temp qualified as Tmp import Database.Postgres.Temp qualified as Tmp
import Gargantext.API.Admin.EnvTypes (Mode(Mock))
import Gargantext.Core.Config import Gargantext.Core.Config
import Gargantext.Core.Config.Types (SettingsFile(..)) import Gargantext.Core.Config.Types (SettingsFile(..))
import Gargantext.Core.Config.Utils (readConfig) import Gargantext.Core.Config.Utils (readConfig)
...@@ -88,6 +87,7 @@ setup = do ...@@ -88,6 +87,7 @@ setup = do
<&> (gc_worker . wsDatabase .~ (connInfo { PG.connectDatabase = "pgmq_test" })) <&> (gc_worker . wsDatabase .~ (connInfo { PG.connectDatabase = "pgmq_test" }))
-- putText $ "[setup] database: " <> show (gargConfig ^. gc_database_config) -- putText $ "[setup] database: " <> show (gargConfig ^. gc_database_config)
-- putText $ "[setup] worker db: " <> show (gargConfig ^. gc_worker . wsDatabase) -- putText $ "[setup] worker db: " <> show (gargConfig ^. gc_worker . wsDatabase)
let log_cfg = gargConfig ^. gc_logging
let idleTime = 60.0 let idleTime = 60.0
let maxResources = 2 let maxResources = 2
let poolConfig = defaultPoolConfig (PG.connectPostgreSQL (Tmp.toConnectionString db)) let poolConfig = defaultPoolConfig (PG.connectPostgreSQL (Tmp.toConnectionString db))
...@@ -98,7 +98,7 @@ setup = do ...@@ -98,7 +98,7 @@ setup = do
bootstrapDB db pool gargConfig bootstrapDB db pool gargConfig
ugen <- emptyCounter ugen <- emptyCounter
test_nodeStory <- fromDBNodeStoryEnv pool test_nodeStory <- fromDBNodeStoryEnv pool
withLoggerIO Mock $ \logger -> do withLoggerIO log_cfg $ \logger -> do
let wPoolConfig = defaultPoolConfig (PG.connectPostgreSQL (Tmp.toConnectionString db)) let wPoolConfig = defaultPoolConfig (PG.connectPostgreSQL (Tmp.toConnectionString db))
PG.close PG.close
...@@ -107,7 +107,7 @@ setup = do ...@@ -107,7 +107,7 @@ setup = do
wPool <- newPool (setNumStripes (Just 2) wPoolConfig) wPool <- newPool (setNumStripes (Just 2) wPoolConfig)
wNodeStory <- fromDBNodeStoryEnv wPool wNodeStory <- fromDBNodeStoryEnv wPool
_w_env_job_state <- newTVarIO Nothing _w_env_job_state <- newTVarIO Nothing
withLoggerIO Mock $ \wioLogger -> do withLoggerIO log_cfg $ \wioLogger -> do
let wEnv = WorkerEnv { _w_env_config = gargConfig let wEnv = WorkerEnv { _w_env_config = gargConfig
, _w_env_logger = wioLogger , _w_env_logger = wioLogger
, _w_env_pool = wPool , _w_env_pool = wPool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment