Skip to content

Commit 972097f

Browse files
committed
Test if the script works on php-fpm socket
Fixes #5 The test will change temporarily fpm to run on socket, run the healthcheck and revert it.
1 parent 07b5a33 commit 972097f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

php-fpm-healthcheck

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Ping mode with data (outputs php-fpm status text): ./php-fpm-healthcheck -v
1919
#
2020
# Exit status codes:
21-
# 9 - Couldn't connect to PHP fpm, is it running?
21+
# 2,9,111 - Couldn't connect to PHP fpm, is it running?
2222
# 8 - Couldn't reach PHP fpm status page, have you configured it with `pm.status_path = /status`?
2323
# 1 - A healthcheck condition has failed
2424
# 3 - Invalid option given

test/testinfra/test_fpm.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ def test_exit_when_no_status_page_is_configured(host):
1616
host.run("sed -i /usr/local/etc/php-fpm.d/zz-docker.conf -e '/;pm.status_path/ s/^;*//'")
1717
host.run("kill -USR2 1")
1818

19+
@pytest.mark.php_fpm
20+
def test_fpm_on_socket(host):
21+
# change fpm to socket
22+
host.run("sed -i /usr/local/etc/php-fpm.d/zz-docker.conf -e '/^listen/ s/.*/listen = \\/var\\/run\\/php-fpm.sock/'")
23+
host.run("kill -USR2 1")
24+
25+
cmd = host.run("FCGI_CONNECT=/var/run/php-fpm.sock php-fpm-healthcheck -v")
26+
assert cmd.rc == 0
27+
assert "Trying to connect to php-fpm via:" in cmd.stdout
28+
assert "status output:" in cmd.stdout
29+
assert "pool:" in cmd.stdout
30+
31+
# change fpm back to port 9000
32+
host.run("sed -i /usr/local/etc/php-fpm.d/zz-docker.conf -e '/^listen/ s/.*/listen = 9000/'")
33+
host.run("kill -USR2 1")
34+
1935
@pytest.mark.alpine
2036
def test_exit_when_fpm_is_not_reachable_apk(host):
2137
cmd = host.run("FCGI_CONNECT=localhost:9001 php-fpm-healthcheck -v")

0 commit comments

Comments
 (0)