Skip to content

Commit 078ab63

Browse files
committed
Test the ability to change status page path
1 parent 0b4e20f commit 078ab63

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

php-fpm-healthcheck

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ command -v grep 1> /dev/null || { >&2 echo "Make sure grep is installed (i.e. ap
5252
# Get status from fastcgi connection
5353
# $1 - cgi-fcgi connect argument
5454
get_fpm_status() {
55-
if test "$VERBOSE" = 1; then printf "Trying to connect to php-fpm via: %s\\n" "$1"; fi;
55+
if test "$VERBOSE" = 1; then printf "Trying to connect to php-fpm via: %s%s\\n" "$1" "$SCRIPT_NAME"; fi;
5656

5757
# Since I cannot use pipefail I'll just split these in two commands
5858
FPM_STATUS=$(env -i REQUEST_METHOD="$REQUEST_METHOD" SCRIPT_NAME="$SCRIPT_NAME" SCRIPT_FILENAME="$SCRIPT_FILENAME" "$FCGI_CMD_PATH" -bind -connect "$1" 2> /dev/null)

test/testinfra/test_execution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def test_valid_with_non_integer_value_exits_properly(host):
2222

2323
@pytest.mark.php_fpm
2424
def test_all_available_options_at_once(host):
25-
cmd = host.run("php-fpm-healthcheck --accepted-conn=1000 --listen-queue=1000 --max-listen-queue=1000 --listen-queue-len=1000 --idle-processes=1000 --active-processes=1000 --total-processes=1000 --max-active-processes=1000 --max-children-reached=1000 --slow-requests=1000")
25+
cmd = host.run("php-fpm-healthcheck --accepted-conn=1000 --listen-queue=1000 --max-listen-queue=1000 "
26+
"--listen-queue-len=1000 --idle-processes=1000 --active-processes=1000 --total-processes=1000 "
27+
"--max-active-processes=1000 --max-children-reached=1000 --slow-requests=1000")
2628
assert cmd.rc == 0
2729

2830
@pytest.mark.php_fpm

test/testinfra/test_fpm.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ def test_fpm_on_socket_with_huge_env(host, setup_fpm_to_default_fixture):
4747
assert "status output:" in cmd.stdout
4848
assert "pool:" in cmd.stdout
4949

50+
@pytest.mark.php_fpm
51+
def test_default_status_page_path(host, setup_fpm_to_default_fixture):
52+
cmd = host.run("php-fpm-healthcheck -v")
53+
assert cmd.rc == 0
54+
assert "Trying to connect to php-fpm via: localhost:9000/status" in cmd.stdout
55+
56+
@pytest.mark.php_fpm
57+
def test_exit_when_fpm_is_invalid_path(host, setup_fpm_to_default_fixture):
58+
cmd = host.run("FCGI_STATUS_PATH=/invalid php-fpm-healthcheck -v")
59+
assert cmd.rc == 8
60+
assert "Trying to connect to php-fpm via: localhost:9000/invalid" in cmd.stdout
61+
assert "File not found." in cmd.stdout
62+
assert "php-fpm status page non reachable" in cmd.stderr
63+
5064
@pytest.mark.alpine
5165
def test_exit_when_fpm_is_not_reachable_apk(host, setup_fpm_to_default_fixture):
5266
cmd = host.run("FCGI_CONNECT=localhost:9001 php-fpm-healthcheck -v")
@@ -70,3 +84,4 @@ def test_exit_when_fpm_is_invalid_host_apt(host, setup_fpm_to_default_fixture):
7084
cmd = host.run("FCGI_CONNECT=abc php-fpm-healthcheck -v")
7185
assert cmd.rc == 2
7286
assert "Trying to connect to php-fpm via: abc" in cmd.stdout
87+

0 commit comments

Comments
 (0)