Merge pull request #3914 from dokku/3911-nginx-log-path

Add ability to change or disable the access/error log path
This commit is contained in:
Jose Diaz-Gonzalez
2020-04-01 20:06:50 -04:00
committed by GitHub
7 changed files with 157 additions and 29 deletions

View File

@@ -26,8 +26,90 @@ teardown() {
@test "(nginx-vhosts) logging" {
deploy_app
assert_access_log ${TEST_APP}
assert_error_log ${TEST_APP}
run [ -a "/var/log/nginx/$TEST_APP-access.log" ]
echo "output: $output"
echo "status: $status"
assert_success
run [ -a "/var/log/nginx/$TEST_APP-error.log" ]
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:access-logs $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:error-logs $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(nginx-vhosts) log-path" {
deploy_app
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_output_contains "off;"
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_output_contains "off;" 0
run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_output_contains "off;"
run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_output_contains "off;" 0
}
@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" {

View File

@@ -256,18 +256,6 @@ assert_urls() {
assert_output < <(tr ' ' '\n' <<< "${urls}" | sort)
}
assert_access_log() {
local prefix=$1
run [ -a "/var/log/nginx/$prefix-access.log" ]
assert_success
}
assert_error_log() {
local prefix=$1
run [ -a "/var/log/nginx/$prefix-error.log" ]
assert_success
}
deploy_app() {
declare APP_TYPE="$1" GIT_REMOTE="$2" CUSTOM_TEMPLATE="$3" CUSTOM_PATH="$4"
local APP_TYPE=${APP_TYPE:="nodejs-express"}