Add server-unix-socket config option (#1303)
Add ncat workaround to test socket connection on CircleCI
This commit is contained in:
committed by
Steve Chávez
parent
e292fb5eb9
commit
78e5677fbe
@@ -64,6 +64,8 @@ getEnvVarWithDefault var def = toS <$>
|
||||
_baseCfg :: AppConfig
|
||||
_baseCfg = -- Connection Settings
|
||||
AppConfig mempty "postgrest_test_anonymous" Nothing "test" "localhost" 3000
|
||||
-- No user configured Unix Socket
|
||||
Nothing
|
||||
-- Jwt settings
|
||||
(Just $ encodeUtf8 "reallyreallyreallyreallyverysafe") False Nothing
|
||||
-- Connection Modifiers
|
||||
|
||||
@@ -181,6 +181,30 @@ ensureAppSettings(){
|
||||
pgrStop
|
||||
}
|
||||
|
||||
getSocketStatus() {
|
||||
curl -sL -w "%{http_code}\\n" -o /dev/null localhost:54321
|
||||
}
|
||||
|
||||
socketConnection(){
|
||||
# map port 54321 traffic to unix socket as workaround for curl below 7.40
|
||||
# not supporting --unix-socket flag
|
||||
ncat -vlk 54321 -c 'ncat -U /tmp/postgrest.sock' &
|
||||
pgrStart "./configs/unix-socket.config"
|
||||
while pgrStarted && test "$( getSocketStatus )" -ne 200
|
||||
do
|
||||
# wait for the server to start
|
||||
sleep 0.1 \
|
||||
|| sleep 1 # fallback: subsecond sleep is not standard and may fail
|
||||
done
|
||||
if test $( getSocketStatus ) -eq 200
|
||||
then
|
||||
ok "Succesfully connected through unix socket"
|
||||
else
|
||||
ko "Failed to connect through unix socket"
|
||||
fi
|
||||
pgrStop
|
||||
}
|
||||
|
||||
# PRE: curl must be available
|
||||
test -n "$(command -v curl)" || bailOut 'curl is not available'
|
||||
|
||||
@@ -191,6 +215,8 @@ setUp
|
||||
|
||||
echo "Running IO tests.."
|
||||
|
||||
socketConnection
|
||||
|
||||
readSecretFromFile word.noeol 'simple (no EOL)'
|
||||
readSecretFromFile word.txt 'simple'
|
||||
readSecretFromFile ascii.noeol 'ASCII (no EOL)'
|
||||
@@ -224,6 +250,7 @@ invalidRoleClaimKey 1234
|
||||
ensureIatClaimWorks
|
||||
ensureAppSettings
|
||||
|
||||
|
||||
cleanUp
|
||||
|
||||
exit $failedTests
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
db-uri = "postgres:///postgrest_test"
|
||||
db-schema = "test"
|
||||
db-anon-role = "postgrest_test_anonymous"
|
||||
db-pool = 1
|
||||
server-host = "127.0.0.1"
|
||||
server-unix-socket = "/tmp/postgrest.sock"
|
||||
jwt-secret = "reallyreallyreallyreallyverysafe"
|
||||
Reference in New Issue
Block a user