Skip to content

Commit

Permalink
Add test for db-schema reload
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Jul 12, 2020
1 parent 31feffe commit 87d4fdb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/io-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ authorsStatus(){
"http://localhost:$pgrPort/authors_only"
}

v1SchemaParentsStatus(){
curl -s -o /dev/null -w '%{http_code}' \
-H "Accept-Profile: v1" \
"http://localhost:$pgrPort/parents"
}

# Unit Test Templates
readSecretFromFile(){
case "$1" in
Expand Down Expand Up @@ -237,6 +243,31 @@ checkJwtSecretReload(){
replaceConfigValue "jwt-secret" "invalidinvalidinvalidinvalidinvalid" ./configs/sigusr2-settings.config
}

checkDbSchemaReload(){
pgrStart "./configs/sigusr2-settings.config"
while pgrStarted && test "$( rootStatus )" -ne 200
do
# wait for the server to start
sleep 0.1 \
|| sleep 1 # fallback: subsecond sleep is not standard and may fail
done
secret="reallyreallyreallyreallyverysafe"
# add v1 schema to db-schema
replaceConfigValue "db-schema" "test, v1" ./configs/sigusr2-settings.config
# reload
kill -s SIGUSR2 $pgrPID
httpStatus="$(v1SchemaParentsStatus)"
if test "$httpStatus" -eq 200
then
ok "db-schema config reloaded with SIGUSR2"
else
ko "db-schema config not reloaded with SIGUSR2. Got: $httpStatus"
fi
pgrStop
# go back to original setting
replaceConfigValue "db-schema" "test" ./configs/sigusr2-settings.config
}

replaceConfigValue(){
sed -i "s/.*$1.*/$1 = \"$2\"/g" $3
}
Expand Down Expand Up @@ -312,6 +343,7 @@ ensureAppSettings

checkAppSettingsReload
checkJwtSecretReload
checkDbSchemaReload
# TODO: SIGUSR2 tests for other config options

trap - int term exit
Expand Down

0 comments on commit 87d4fdb

Please sign in to comment.