2021-11-17 22:50:39 +03:00
|
|
|
{-# LANGUAGE DisambiguateRecordFields #-}
|
|
|
|
|
|
|
|
-- | Constant configurations used throughout the test suite.
|
|
|
|
module Harness.Constants
|
|
|
|
( postgresPassword,
|
|
|
|
postgresUser,
|
|
|
|
postgresDb,
|
|
|
|
postgresHost,
|
|
|
|
postgresPort,
|
|
|
|
postgresqlConnectionString,
|
|
|
|
postgresLivenessCheckAttempts,
|
|
|
|
postgresLivenessCheckIntervalSeconds,
|
|
|
|
postgresLivenessCheckIntervalMicroseconds,
|
|
|
|
mysqlLivenessCheckAttempts,
|
|
|
|
mysqlLivenessCheckIntervalSeconds,
|
|
|
|
mysqlLivenessCheckIntervalMicroseconds,
|
|
|
|
mysqlPassword,
|
|
|
|
mysqlUser,
|
|
|
|
mysqlDatabase,
|
|
|
|
mysqlHost,
|
|
|
|
mysqlPort,
|
|
|
|
mysqlConnectInfo,
|
2021-12-30 14:00:52 +03:00
|
|
|
sqlserverLivenessCheckAttempts,
|
|
|
|
sqlserverLivenessCheckIntervalSeconds,
|
|
|
|
sqlserverLivenessCheckIntervalMicroseconds,
|
|
|
|
sqlserverConnectInfo,
|
2021-11-17 22:50:39 +03:00
|
|
|
httpHealthCheckAttempts,
|
|
|
|
httpHealthCheckIntervalSeconds,
|
|
|
|
httpHealthCheckIntervalMicroseconds,
|
2021-12-30 14:00:52 +03:00
|
|
|
citusConnectionString,
|
2021-11-23 21:15:17 +03:00
|
|
|
serveOptions,
|
2021-11-26 21:21:01 +03:00
|
|
|
debugMessagesEnabled,
|
2021-11-17 22:50:39 +03:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2021-11-23 21:15:17 +03:00
|
|
|
import Data.HashSet qualified as Set
|
2021-11-17 22:50:39 +03:00
|
|
|
import Data.Word
|
|
|
|
import Database.MySQL.Simple qualified as Mysql
|
2021-11-23 21:15:17 +03:00
|
|
|
import Database.PG.Query qualified as Q
|
|
|
|
import Hasura.GraphQL.Execute.LiveQuery.Options qualified as LQ
|
|
|
|
import Hasura.Logging qualified as L
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.Types
|
|
|
|
import Hasura.Server.Cors
|
|
|
|
import Hasura.Server.Init
|
|
|
|
import Hasura.Server.Types
|
|
|
|
import Network.WebSockets qualified as WS
|
2021-11-17 22:50:39 +03:00
|
|
|
|
2022-01-21 10:48:27 +03:00
|
|
|
-- * Postgres
|
|
|
|
|
2021-11-17 22:50:39 +03:00
|
|
|
postgresPassword :: String
|
2021-11-23 21:15:17 +03:00
|
|
|
postgresPassword = "hasura"
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
postgresUser :: String
|
2021-11-23 21:15:17 +03:00
|
|
|
postgresUser = "hasura"
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
postgresDb :: String
|
2021-11-23 21:15:17 +03:00
|
|
|
postgresDb = "hasura"
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
postgresHost :: String
|
|
|
|
postgresHost = "127.0.0.1"
|
|
|
|
|
|
|
|
postgresPort :: Word16
|
2021-11-23 21:15:17 +03:00
|
|
|
postgresPort = 65002
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
postgresqlConnectionString :: String
|
|
|
|
postgresqlConnectionString =
|
|
|
|
"postgres://"
|
|
|
|
++ postgresUser
|
|
|
|
++ ":"
|
|
|
|
++ postgresPassword
|
|
|
|
++ "@"
|
|
|
|
++ postgresHost
|
|
|
|
++ ":"
|
|
|
|
++ show postgresPort
|
|
|
|
++ "/"
|
|
|
|
++ postgresDb
|
|
|
|
|
2022-01-21 10:48:27 +03:00
|
|
|
-- * Citus
|
|
|
|
|
2021-12-30 14:00:52 +03:00
|
|
|
citusPassword :: String
|
|
|
|
citusPassword = "hasura"
|
|
|
|
|
|
|
|
citusUser :: String
|
|
|
|
citusUser = "hasura"
|
|
|
|
|
|
|
|
citusDb :: String
|
|
|
|
citusDb = "hasura"
|
|
|
|
|
|
|
|
citusHost :: String
|
|
|
|
citusHost = "127.0.0.1"
|
|
|
|
|
|
|
|
citusPort :: Word16
|
|
|
|
citusPort = 65004
|
|
|
|
|
|
|
|
citusConnectionString :: String
|
|
|
|
citusConnectionString =
|
|
|
|
"postgres://"
|
|
|
|
++ citusUser
|
|
|
|
++ ":"
|
|
|
|
++ citusPassword
|
|
|
|
++ "@"
|
|
|
|
++ citusHost
|
|
|
|
++ ":"
|
|
|
|
++ show citusPort
|
|
|
|
++ "/"
|
|
|
|
++ citusDb
|
|
|
|
|
2022-01-21 10:48:27 +03:00
|
|
|
-- * Liveness
|
|
|
|
|
2021-11-17 22:50:39 +03:00
|
|
|
postgresLivenessCheckAttempts :: Int
|
|
|
|
postgresLivenessCheckAttempts = 5
|
|
|
|
|
|
|
|
postgresLivenessCheckIntervalSeconds :: Int
|
|
|
|
postgresLivenessCheckIntervalSeconds = 1
|
|
|
|
|
2021-12-30 14:00:52 +03:00
|
|
|
sqlserverLivenessCheckAttempts :: Int
|
|
|
|
sqlserverLivenessCheckAttempts = 5
|
|
|
|
|
|
|
|
sqlserverLivenessCheckIntervalSeconds :: Int
|
|
|
|
sqlserverLivenessCheckIntervalSeconds = 1
|
|
|
|
|
|
|
|
-- | SQL Server has strict password requirements, that's why it's not
|
|
|
|
-- simply @hasura@ like the others.
|
|
|
|
sqlserverConnectInfo :: Text
|
|
|
|
sqlserverConnectInfo = "DRIVER={ODBC Driver 17 for SQL Server};SERVER=127.0.0.1,65003;Uid=hasura;Pwd=Hasura1!;Encrypt=no"
|
|
|
|
|
|
|
|
sqlserverLivenessCheckIntervalMicroseconds :: Int
|
|
|
|
sqlserverLivenessCheckIntervalMicroseconds = 1000 * 1000 * sqlserverLivenessCheckIntervalSeconds
|
|
|
|
|
2021-11-17 22:50:39 +03:00
|
|
|
postgresLivenessCheckIntervalMicroseconds :: Int
|
|
|
|
postgresLivenessCheckIntervalMicroseconds = 1000 * 1000 * postgresLivenessCheckIntervalSeconds
|
|
|
|
|
|
|
|
mysqlLivenessCheckAttempts :: Int
|
|
|
|
mysqlLivenessCheckAttempts = 5
|
|
|
|
|
|
|
|
mysqlLivenessCheckIntervalSeconds :: Int
|
|
|
|
mysqlLivenessCheckIntervalSeconds = 1
|
|
|
|
|
|
|
|
mysqlLivenessCheckIntervalMicroseconds :: Int
|
|
|
|
mysqlLivenessCheckIntervalMicroseconds = 1000 * 1000 * mysqlLivenessCheckIntervalSeconds
|
|
|
|
|
2022-01-21 10:48:27 +03:00
|
|
|
-- * MySQL
|
|
|
|
|
2021-11-17 22:50:39 +03:00
|
|
|
mysqlPassword :: String
|
2021-11-23 21:15:17 +03:00
|
|
|
mysqlPassword = "hasura"
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
mysqlUser :: String
|
2021-11-23 21:15:17 +03:00
|
|
|
mysqlUser = "hasura"
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
mysqlDatabase :: String
|
|
|
|
mysqlDatabase = "hasura"
|
|
|
|
|
|
|
|
mysqlHost :: String
|
|
|
|
mysqlHost = "127.0.0.1"
|
|
|
|
|
|
|
|
mysqlPort :: Word16
|
2021-11-23 21:15:17 +03:00
|
|
|
mysqlPort = 65001
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
mysqlConnectInfo :: Mysql.ConnectInfo
|
|
|
|
mysqlConnectInfo =
|
|
|
|
Mysql.defaultConnectInfo
|
|
|
|
{ Mysql.connectUser = mysqlUser,
|
|
|
|
Mysql.connectPassword = mysqlPassword,
|
|
|
|
Mysql.connectDatabase = mysqlDatabase,
|
|
|
|
Mysql.connectHost = mysqlHost,
|
|
|
|
Mysql.connectPort = mysqlPort
|
|
|
|
}
|
|
|
|
|
2022-01-21 10:48:27 +03:00
|
|
|
-- * HTTP health checks
|
|
|
|
|
2021-11-17 22:50:39 +03:00
|
|
|
httpHealthCheckAttempts :: Int
|
|
|
|
httpHealthCheckAttempts = 5
|
|
|
|
|
|
|
|
httpHealthCheckIntervalSeconds :: Int
|
|
|
|
httpHealthCheckIntervalSeconds = 1
|
|
|
|
|
|
|
|
httpHealthCheckIntervalMicroseconds :: Int
|
|
|
|
httpHealthCheckIntervalMicroseconds = 1000 * 1000 * httpHealthCheckIntervalSeconds
|
|
|
|
|
2022-01-21 10:48:27 +03:00
|
|
|
-- * Server configuration
|
|
|
|
|
2021-11-23 21:15:17 +03:00
|
|
|
serveOptions :: ServeOptions impl
|
|
|
|
serveOptions =
|
|
|
|
ServeOptions
|
|
|
|
{ soPort = 12345, -- The server runner will typically be generating
|
|
|
|
-- a random port, so this isn't particularly
|
|
|
|
-- important.
|
|
|
|
soHost = "0.0.0.0",
|
|
|
|
soConnParams = Q.defaultConnParams,
|
|
|
|
soTxIso = Q.Serializable,
|
|
|
|
soAdminSecret = mempty,
|
|
|
|
soAuthHook = Nothing,
|
2021-12-14 17:28:50 +03:00
|
|
|
soJwtSecret = Nothing,
|
2021-11-23 21:15:17 +03:00
|
|
|
soUnAuthRole = Nothing,
|
|
|
|
soCorsConfig = CCAllowAll,
|
|
|
|
soEnableConsole = True,
|
|
|
|
soConsoleAssetsDir = Nothing,
|
|
|
|
soEnableTelemetry = False,
|
|
|
|
soStringifyNum = True,
|
|
|
|
soDangerousBooleanCollapse = False,
|
|
|
|
soEnabledAPIs = testSuiteEnabledApis,
|
|
|
|
soLiveQueryOpts = LQ.mkLiveQueriesOptions Nothing Nothing,
|
|
|
|
soEnableAllowlist = False,
|
|
|
|
soEnabledLogTypes = Set.empty,
|
|
|
|
soLogLevel =
|
2021-11-26 21:21:01 +03:00
|
|
|
if debugMessagesEnabled
|
|
|
|
then L.LevelDebug
|
|
|
|
else L.LevelOther "test-suite",
|
2021-11-23 21:15:17 +03:00
|
|
|
soResponseInternalErrorsConfig = InternalErrorsAllRequests,
|
|
|
|
soEventsHttpPoolSize = Nothing,
|
|
|
|
soEventsFetchInterval = Nothing,
|
|
|
|
soAsyncActionsFetchInterval = Skip,
|
|
|
|
soLogHeadersFromEnv = False,
|
|
|
|
soEnableRemoteSchemaPermissions = RemoteSchemaPermsDisabled,
|
|
|
|
soConnectionOptions = WS.defaultConnectionOptions,
|
|
|
|
soWebsocketKeepAlive = defaultKeepAliveDelay,
|
|
|
|
soInferFunctionPermissions = FunctionPermissionsInferred,
|
|
|
|
soEnableMaintenanceMode = MaintenanceModeDisabled,
|
|
|
|
-- MUST be disabled to be able to modify schema.
|
|
|
|
soSchemaPollInterval = Interval 10,
|
|
|
|
soExperimentalFeatures = mempty,
|
|
|
|
soEventsFetchBatchSize = 1,
|
|
|
|
soDevMode = True,
|
|
|
|
soGracefulShutdownTimeout = 0, -- Don't wait to shutdown.
|
2021-11-30 15:31:27 +03:00
|
|
|
soWebsocketConnectionInitTimeout = defaultWSConnectionInitTimeout,
|
2021-12-08 09:26:46 +03:00
|
|
|
soEventingMode = EventingEnabled,
|
|
|
|
soReadOnlyMode = ReadOnlyModeDisabled
|
2021-11-23 21:15:17 +03:00
|
|
|
}
|
|
|
|
|
2021-11-26 21:21:01 +03:00
|
|
|
-- | Use the below to show messages.
|
|
|
|
debugMessagesEnabled :: Bool
|
|
|
|
debugMessagesEnabled = False
|
|
|
|
|
2021-11-23 21:15:17 +03:00
|
|
|
-- These are important for the test suite.
|
|
|
|
testSuiteEnabledApis :: HashSet API
|
|
|
|
testSuiteEnabledApis = Set.fromList [METADATA, GRAPHQL, DEVELOPER, CONFIG]
|