Skip to content

Commit

Permalink
add JSON logging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen committed Mar 10, 2023
1 parent a43ab2a commit 6990b70
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ echo "HEADLESS environment variable tests completed successfully"

printf "\n\n*******************\n\n"

# Json Logging Variables
echo "Tests the ability to change the log format to JSON"

./tests/test.json.logging.sh

echo "JSON Logging Tests Completed"

printf "\n\n*******************\n\n"

# Rewrites Environment variables
echo "Testing the ability to specify to turn rewrites off via an environment variable"

Expand Down
31 changes: 31 additions & 0 deletions build/tests/test.json.logging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Set any error to exit non-zero
set -e
# Perform reset operations now, before we start issuing exit codes

# Clear out any previous runtime JSON files
rm -f $APP_DIR/*.json

# Clear out any previous runtime-created modules
rm -rf $APP_DIR/modules

cd ${APP_DIR}

export BOX_SERVER_RUNWAR_CONSOLE_APPENDERLAYOUT="JSONTemplateLayout"

echo "Starting server with JSON logging enabled"

runOutput="$( ${BUILD_DIR}/run.sh )"

printf '%s\n' "${runOutput}"

$BUILD_DIR/tests/test.up.sh

if [[ ${runOutput} != *"\"level\": \"INFO\""* ]];then
echo "JSON Template layout was not activated successfully"
exit 1
fi

# cleanup
unset BOX_SERVER_RUNWAR_CONSOLE_APPENDERLAYOUT
box server stop

0 comments on commit 6990b70

Please sign in to comment.