nix(test): add test suite for observability tests#4732
Merged
steve-chavez merged 1 commit intoPostgREST:mainfrom Mar 19, 2026
Merged
nix(test): add test suite for observability tests#4732steve-chavez merged 1 commit intoPostgREST:mainfrom
steve-chavez merged 1 commit intoPostgREST:mainfrom
Conversation
2d48d58 to
0108cb6
Compare
Member
There was a problem hiding this comment.
Looked at our current
It is indeed purely tested in terms of metrics, so I agree in that it fits here.
Comment on lines
+31
to
+109
| baseCfg :: AppConfig | ||
| baseCfg = let secret = encodeUtf8 "reallyreallyreallyreallyverysafe" in | ||
| AppConfig { | ||
| configAppSettings = [] | ||
| , configClientErrorVerbosity = Verbose | ||
| , configDbAggregates = False | ||
| , configDbAnonRole = Just "postgrest_test_anonymous" | ||
| , configDbChannel = mempty | ||
| , configDbChannelEnabled = True | ||
| , configDbExtraSearchPath = [] | ||
| , configDbHoistedTxSettings = ["default_transaction_isolation","plan_filter.statement_cost_limit","statement_timeout"] | ||
| , configDbMaxRows = Nothing | ||
| , configDbPlanEnabled = False | ||
| , configDbPoolSize = 10 | ||
| , configDbPoolAcquisitionTimeout = 10 | ||
| , configDbPoolMaxLifetime = 1800 | ||
| , configDbPoolMaxIdletime = 600 | ||
| , configDbPoolAutomaticRecovery = True | ||
| , configDbPreRequest = Nothing | ||
| , configDbPreparedStatements = True | ||
| , configDbRootSpec = Nothing | ||
| , configDbSchemas = fromList ["test"] | ||
| , configDbConfig = False | ||
| , configDbPreConfig = Nothing | ||
| , configDbUri = "postgresql://" | ||
| , configFilePath = Nothing | ||
| , configJWKS = rightToMaybe $ parseSecret secret | ||
| , configJwtAudience = Nothing | ||
| , configJwtRoleClaimKey = [JSPKey "role"] | ||
| , configJwtSecret = Just secret | ||
| , configJwtSecretIsBase64 = False | ||
| , configJwtCacheMaxEntries = 10 | ||
| , configLogLevel = LogCrit | ||
| , configLogQuery = False | ||
| , configOpenApiMode = OAFollowPriv | ||
| , configOpenApiSecurityActive = False | ||
| , configOpenApiServerProxyUri = Nothing | ||
| , configServerCorsAllowedOrigins = Nothing | ||
| , configServerHost = "localhost" | ||
| , configServerPort = 3000 | ||
| , configServerTraceHeader = Nothing | ||
| , configServerUnixSocket = Nothing | ||
| , configServerUnixSocketMode = 432 | ||
| , configDbTxAllowOverride = True | ||
| , configDbTxRollbackAll = True | ||
| , configAdminServerHost = "localhost" | ||
| , configAdminServerPort = Nothing | ||
| , configRoleSettings = mempty | ||
| , configRoleIsoLvl = mempty | ||
| , configInternalSCQuerySleep = Nothing | ||
| , configInternalSCLoadSleep = Nothing | ||
| , configInternalSCRelLoadSleep = Nothing | ||
| , configServerTimingEnabled = True | ||
| } | ||
|
|
||
| testCfg :: AppConfig | ||
| testCfg = baseCfg | ||
|
|
||
| testCfgJwtCache :: AppConfig | ||
| testCfgJwtCache = | ||
| baseCfg { | ||
| configJwtSecret = Just generateSecret | ||
| , configJWKS = rightToMaybe $ parseSecret generateSecret | ||
| , configJwtCacheMaxEntries = 2 | ||
| } | ||
|
|
||
| authHeader :: BS.ByteString -> BS.ByteString -> Header | ||
| authHeader typ creds = | ||
| (hAuthorization, typ <> " " <> creds) | ||
|
|
||
| authHeaderJWT :: BS.ByteString -> Header | ||
| authHeaderJWT = authHeader "Bearer" | ||
|
|
||
| generateSecret :: ByteString | ||
| generateSecret = B64.decodeLenient "cmVhbGx5cmVhbGx5cmVhbGx5cmVhbGx5dmVyeXNhZmU=" | ||
|
|
||
| generateJWT :: BL.ByteString -> ByteString | ||
| generateJWT claims = | ||
| either mempty JWT.unJwt $ JWT.hmacEncode JWT.HS256 generateSecret (BL.toStrict claims) |
Member
There was a problem hiding this comment.
I see there's duplication here but don't have a good idea on how to solve right now.
Member
Author
There was a problem hiding this comment.
Yup, I feel the same way. I believe the long term solution would be to come with some sort of internal helper library of functions, but that would be too much for now.
steve-chavez
approved these changes
Mar 18, 2026
- Create separate test suite for observability tests - Create wrapper script `postgrest-test-observability` - Add to CI and `postgrest-check` - Move JWT cache tests under observability tests Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
0108cb6 to
0678896
Compare
Member
Author
|
I think we should backport this so future fixes apply cleanly using our backport action. To backport this, we first need to backport #4659 and maybe more. |
This was referenced Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create separate test suite for observability tests
Create wrapper script
postgrest-test-observabilityAdd to CI and
postgrest-checkMove JWT cache tests under observability tests
As discussed in #4671 (comment).