diff --git a/services/gundeck/test/integration/API.hs b/services/gundeck/test/integration/API.hs index b1cc4e48a46..bc1f4486a68 100644 --- a/services/gundeck/test/integration/API.hs +++ b/services/gundeck/test/integration/API.hs @@ -1,6 +1,6 @@ {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} -module API (TestSetup(..), tests) where +module API (tests) where import Bilge import Bilge.Assert @@ -24,7 +24,7 @@ import System.Random (randomIO) import System.Timeout (timeout) import Test.Tasty import Test.Tasty.HUnit -import Types +import TestSetup import qualified Cassandra as Cql import qualified Data.Aeson.Types as Aeson @@ -45,15 +45,6 @@ import qualified Prelude appName :: AppName appName = AppName "test" -data TestSetup = TestSetup - { manager :: Manager - , gundeck :: Gundeck - , cannon :: Cannon - , cannon2 :: Cannon - , brig :: Brig - , cass :: Cql.ClientState - } - type TestSignature a = Gundeck -> Cannon -> Brig -> Cql.ClientState -> Http a type TestSignature2 a = Gundeck -> Cannon -> Cannon -> Brig -> Cql.ClientState -> Http a @@ -62,14 +53,14 @@ test setup n h = testCase n runTest where runTest = do s <- setup - void $ runHttpT (manager s) (h (gundeck s) (cannon s) (brig s) (cass s)) + void $ runHttpT (s ^. tsManager) (h (s ^. tsGundeck) (s ^. tsCannon) (s ^. tsBrig) (s ^. tsCass)) test2 :: IO TestSetup -> TestName -> (TestSignature2 a) -> TestTree test2 setup n h = testCase n runTest where runTest = do s <- setup - void $ runHttpT (manager s) (h (gundeck s) (cannon s) (cannon2 s) (brig s) (cass s)) + void $ runHttpT (s ^. tsManager) (h (s ^. tsGundeck) (s ^. tsCannon) (s ^. tsCannon2) (s ^. tsBrig) (s ^. tsCass)) tests :: IO TestSetup -> TestTree tests s = testGroup "Gundeck integration tests" [ diff --git a/services/gundeck/test/integration/Main.hs b/services/gundeck/test/integration/Main.hs index 4e5ca48c652..71b861c55cb 100644 --- a/services/gundeck/test/integration/Main.hs +++ b/services/gundeck/test/integration/Main.hs @@ -17,20 +17,20 @@ import OpenSSL (withOpenSSL) import Options.Applicative import Test.Tasty import Test.Tasty.Options -import Types import Util.Options import Util.Options.Common import Util.Test +import TestSetup import qualified API import qualified System.Logger as Logger data IntegrationConfig = IntegrationConfig -- internal endpoints - { gundeck :: Endpoint - , cannon :: Endpoint - , cannon2 :: Endpoint - , brig :: Endpoint + { gundeckEndpoint :: Endpoint + , cannonEndpoint :: Endpoint + , cannon2Endpoint :: Endpoint + , brigEndpoint :: Endpoint } deriving (Show, Generic) instance FromJSON IntegrationConfig @@ -39,7 +39,7 @@ newtype ServiceConfigFile = ServiceConfigFile String deriving (Eq, Ord, Typeable) instance IsOption ServiceConfigFile where - defaultValue = ServiceConfigFile "/etc/wire/gundeck/conf/gundeck.yaml" + defaultValue = ServiceConfigFile "/etc/wire/gundeckEndpoint/conf/gundeckEndpoint.yaml" parseValue = fmap ServiceConfigFile . safeRead optionName = return "service-config" optionHelp = return "Service config file to read from" @@ -74,10 +74,10 @@ main = withOpenSSL $ runTests go let local p = Endpoint { _epHost = "127.0.0.1", _epPort = p } gConf <- handleParseError =<< decodeFileEither gFile iConf <- handleParseError =<< decodeFileEither iFile - g <- Gundeck . mkRequest <$> optOrEnv gundeck iConf (local . read) "GUNDECK_WEB_PORT" - c <- Cannon . mkRequest <$> optOrEnv cannon iConf (local . read) "CANNON_WEB_PORT" - c2 <- Cannon . mkRequest <$> optOrEnv cannon2 iConf (local . read) "CANNON2_WEB_PORT" - b <- Brig . mkRequest <$> optOrEnv brig iConf (local . read) "BRIG_WEB_PORT" + g <- Gundeck . mkRequest <$> optOrEnv gundeckEndpoint iConf (local . read) "GUNDECK_WEB_PORT" + c <- Cannon . mkRequest <$> optOrEnv cannonEndpoint iConf (local . read) "CANNON_WEB_PORT" + c2 <- Cannon . mkRequest <$> optOrEnv cannon2Endpoint iConf (local . read) "CANNON2_WEB_PORT" + b <- Brig . mkRequest <$> optOrEnv brigEndpoint iConf (local . read) "BRIG_WEB_PORT" ch <- optOrEnv (\v -> v^.optCassandra.casEndpoint.epHost) gConf pack "GUNDECK_CASSANDRA_HOST" cp <- optOrEnv (\v -> v^.optCassandra.casEndpoint.epPort) gConf read "GUNDECK_CASSANDRA_PORT" ck <- optOrEnv (\v -> v^.optCassandra.casKeyspace) gConf pack "GUNDECK_CASSANDRA_KEYSPACE" @@ -85,7 +85,7 @@ main = withOpenSSL $ runTests go lg <- Logger.new Logger.defSettings db <- defInitCassandra ck ch cp lg - return $ API.TestSetup m g c c2 b db + return $ TestSetup m g c c2 b db releaseOpts _ = return () diff --git a/services/gundeck/test/integration/TestSetup.hs b/services/gundeck/test/integration/TestSetup.hs new file mode 100644 index 00000000000..73c6298a3e1 --- /dev/null +++ b/services/gundeck/test/integration/TestSetup.hs @@ -0,0 +1,22 @@ +module TestSetup where + +import Imports +import Util.Options +import Bilge +import Control.Lens (makeLenses) +import qualified Cassandra as Cql + +newtype Brig = Brig { runBrig :: Request -> Request } +newtype Cannon = Cannon { runCannon :: Request -> Request } +newtype Gundeck = Gundeck { runGundeck :: Request -> Request } + +data TestSetup = TestSetup + { _tsManager :: Manager + , _tsGundeck :: Gundeck + , _tsCannon :: Cannon + , _tsCannon2 :: Cannon + , _tsBrig :: Brig + , _tsCass :: Cql.ClientState + } + +makeLenses ''TestSetup diff --git a/services/gundeck/test/integration/Types.hs b/services/gundeck/test/integration/Types.hs deleted file mode 100644 index ca213f8c7db..00000000000 --- a/services/gundeck/test/integration/Types.hs +++ /dev/null @@ -1,7 +0,0 @@ -module Types where - -import Bilge (Request) - -newtype Brig = Brig { runBrig :: Request -> Request } -newtype Cannon = Cannon { runCannon :: Request -> Request } -newtype Gundeck = Gundeck { runGundeck :: Request -> Request }