diff --git a/test/io-tests.sh b/test/io-tests.sh index 1011a9feb08..2d2acfed995 100755 --- a/test/io-tests.sh +++ b/test/io-tests.sh @@ -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 @@ -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 } @@ -312,6 +343,7 @@ ensureAppSettings checkAppSettingsReload checkJwtSecretReload +checkDbSchemaReload # TODO: SIGUSR2 tests for other config options trap - int term exit