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,
|
2022-03-15 19:08:47 +03:00
|
|
|
mysqlDb,
|
2021-11-17 22:50:39 +03:00
|
|
|
mysqlHost,
|
|
|
|
mysqlPort,
|
|
|
|
mysqlConnectInfo,
|
2021-12-30 14:00:52 +03:00
|
|
|
sqlserverLivenessCheckAttempts,
|
|
|
|
sqlserverLivenessCheckIntervalSeconds,
|
|
|
|
sqlserverLivenessCheckIntervalMicroseconds,
|
|
|
|
sqlserverConnectInfo,
|
2022-03-01 01:47:51 +03:00
|
|
|
sqlserverDb,
|
2022-03-14 10:49:36 +03:00
|
|
|
bigqueryServiceKeyVar,
|
2022-02-09 18:26:14 +03:00
|
|
|
bigqueryProjectIdVar,
|
2022-03-01 01:47:51 +03:00
|
|
|
bigqueryDataset,
|
2021-11-17 22:50:39 +03:00
|
|
|
httpHealthCheckAttempts,
|
|
|
|
httpHealthCheckIntervalSeconds,
|
|
|
|
httpHealthCheckIntervalMicroseconds,
|
2021-12-30 14:00:52 +03:00
|
|
|
citusConnectionString,
|
2022-03-01 01:47:51 +03:00
|
|
|
citusDb,
|
2021-11-23 21:15:17 +03:00
|
|
|
serveOptions,
|
2021-11-17 22:50:39 +03:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2022-02-14 20:24:24 +03:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
2021-11-23 21:15:17 +03:00
|
|
|
import Data.HashSet qualified as Set
|
2022-02-14 20:24:24 +03:00
|
|
|
import Data.Word (Word16)
|
2021-11-17 22:50:39 +03:00
|
|
|
import Database.MySQL.Simple qualified as Mysql
|
2021-11-23 21:15:17 +03:00
|
|
|
import Database.PG.Query qualified as Q
|
2022-03-21 13:39:49 +03:00
|
|
|
import Hasura.GraphQL.Execute.Subscription.Options qualified as ES
|
2021-11-23 21:15:17 +03:00
|
|
|
import Hasura.Logging qualified as L
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.Types
|
2022-02-14 20:24:24 +03:00
|
|
|
( FunctionPermissionsCtx (FunctionPermissionsInferred),
|
|
|
|
RemoteSchemaPermsCtx (RemoteSchemaPermsDisabled),
|
|
|
|
)
|
2022-02-23 23:17:58 +03:00
|
|
|
import Hasura.RQL.Types.Common (StringifyNumbers (..))
|
2022-02-14 20:24:24 +03:00
|
|
|
import Hasura.Server.Cors (CorsConfig (CCAllowAll))
|
2021-11-23 21:15:17 +03:00
|
|
|
import Hasura.Server.Init
|
2022-02-14 20:24:24 +03:00
|
|
|
( API (CONFIG, DEVELOPER, GRAPHQL, METADATA),
|
|
|
|
OptionalInterval (..),
|
|
|
|
ResponseInternalErrorsConfig (..),
|
|
|
|
ServeOptions (..),
|
|
|
|
)
|
|
|
|
import Hasura.Server.Init qualified as Init
|
2022-04-11 20:49:25 +03:00
|
|
|
import Hasura.Server.Logging (MetadataQueryLoggingMode (MetadataQueryLoggingDisabled))
|
2021-11-23 21:15:17 +03:00
|
|
|
import Hasura.Server.Types
|
2022-02-14 20:24:24 +03:00
|
|
|
( EventingMode (EventingEnabled),
|
|
|
|
MaintenanceMode (MaintenanceModeDisabled),
|
|
|
|
ReadOnlyMode (ReadOnlyModeDisabled),
|
|
|
|
)
|
2021-11-23 21:15:17 +03:00
|
|
|
import Network.WebSockets qualified as WS
|
2021-11-17 22:50:39 +03:00
|
|
|
|
2022-02-14 20:24:24 +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"
|
|
|
|
|
2022-03-01 01:47:51 +03:00
|
|
|
sqlserverDb :: String
|
|
|
|
sqlserverDb = "hasura"
|
|
|
|
|
2021-12-30 14:00:52 +03:00
|
|
|
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
|
|
|
|
2022-03-15 19:08:47 +03:00
|
|
|
mysqlDb :: String
|
|
|
|
mysqlDb = "hasura"
|
2021-11-17 22:50:39 +03:00
|
|
|
|
|
|
|
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,
|
2022-03-15 19:08:47 +03:00
|
|
|
Mysql.connectDatabase = mysqlDb,
|
2021-11-17 22:50:39 +03:00
|
|
|
Mysql.connectHost = mysqlHost,
|
|
|
|
Mysql.connectPort = mysqlPort
|
|
|
|
}
|
|
|
|
|
2022-03-14 10:49:36 +03:00
|
|
|
bigqueryServiceKeyVar :: String
|
|
|
|
bigqueryServiceKeyVar = "HASURA_BIGQUERY_SERVICE_KEY"
|
2022-02-09 18:26:14 +03:00
|
|
|
|
|
|
|
bigqueryProjectIdVar :: String
|
|
|
|
bigqueryProjectIdVar = "HASURA_BIGQUERY_PROJECT_ID"
|
|
|
|
|
2022-03-01 01:47:51 +03:00
|
|
|
bigqueryDataset :: String
|
|
|
|
bigqueryDataset = "hasura"
|
|
|
|
|
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
|
|
|
|
|
2022-02-14 20:24:24 +03:00
|
|
|
serveOptions :: ServeOptions L.Hasura
|
2021-11-23 21:15:17 +03:00
|
|
|
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,
|
2022-02-14 02:33:49 +03:00
|
|
|
soJwtSecret = mempty,
|
2021-11-23 21:15:17 +03:00
|
|
|
soUnAuthRole = Nothing,
|
|
|
|
soCorsConfig = CCAllowAll,
|
|
|
|
soEnableConsole = True,
|
|
|
|
soConsoleAssetsDir = Nothing,
|
|
|
|
soEnableTelemetry = False,
|
2022-02-23 23:17:58 +03:00
|
|
|
soStringifyNum = StringifyNumbers,
|
2021-11-23 21:15:17 +03:00
|
|
|
soDangerousBooleanCollapse = False,
|
|
|
|
soEnabledAPIs = testSuiteEnabledApis,
|
2022-03-21 13:39:49 +03:00
|
|
|
soLiveQueryOpts = ES.mkSubscriptionsOptions Nothing Nothing,
|
2022-04-07 17:41:43 +03:00
|
|
|
soStreamingQueryOpts = ES.mkSubscriptionsOptions Nothing Nothing,
|
2021-11-23 21:15:17 +03:00
|
|
|
soEnableAllowlist = False,
|
2022-02-14 20:24:24 +03:00
|
|
|
soEnabledLogTypes = Set.fromList L.userAllowedLogTypes,
|
|
|
|
soLogLevel = fromMaybe (L.LevelOther "test-suite") engineLogLevel,
|
2021-11-23 21:15:17 +03:00
|
|
|
soResponseInternalErrorsConfig = InternalErrorsAllRequests,
|
|
|
|
soEventsHttpPoolSize = Nothing,
|
|
|
|
soEventsFetchInterval = Nothing,
|
|
|
|
soAsyncActionsFetchInterval = Skip,
|
|
|
|
soLogHeadersFromEnv = False,
|
|
|
|
soEnableRemoteSchemaPermissions = RemoteSchemaPermsDisabled,
|
|
|
|
soConnectionOptions = WS.defaultConnectionOptions,
|
2022-02-14 20:24:24 +03:00
|
|
|
soWebsocketKeepAlive = Init.defaultKeepAliveDelay,
|
2021-11-23 21:15:17 +03:00
|
|
|
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.
|
2022-02-14 20:24:24 +03:00
|
|
|
soWebsocketConnectionInitTimeout = Init.defaultWSConnectionInitTimeout,
|
2021-12-08 09:26:46 +03:00
|
|
|
soEventingMode = EventingEnabled,
|
2022-04-11 20:49:25 +03:00
|
|
|
soReadOnlyMode = ReadOnlyModeDisabled,
|
|
|
|
soEnableMetadataQueryLogging = MetadataQueryLoggingDisabled
|
2021-11-23 21:15:17 +03:00
|
|
|
}
|
|
|
|
|
2022-02-14 20:24:24 +03:00
|
|
|
-- | What log level should be used by the engine; this is not exported, and
|
|
|
|
-- only used in 'serveOptions'.
|
|
|
|
--
|
|
|
|
-- This should be adjusted locally for debugging purposes; e.g. change it to
|
2022-03-17 23:53:56 +03:00
|
|
|
-- @Just L.LevelDebug@ to enable all logs.
|
2022-02-14 20:24:24 +03:00
|
|
|
--
|
|
|
|
-- See 'L.LogLevel' for an enumeration of available log levels.
|
|
|
|
engineLogLevel :: Maybe L.LogLevel
|
|
|
|
engineLogLevel = Nothing
|
2021-11-26 21:21:01 +03:00
|
|
|
|
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]
|