Skip to content

Commit ab71fb1

Browse files
authored
Merge pull request #20 from usabilla/ignore-env
Ignore the environment when executing `cgi-fcgi`
2 parents 4316fb4 + 2779eb0 commit ab71fb1

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

php-fpm-healthcheck

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ get_fpm_status() {
6161
if test "$VERBOSE" = 1; then printf "Trying to connect to php-fpm via: %s\\n" "$1"; fi;
6262

6363
# Since I cannot use pipefail I'll just split these in two commands
64-
FPM_STATUS=$(cgi-fcgi -bind -connect "$1" 2> /dev/null)
64+
FPM_STATUS=$(env -i REQUEST_METHOD="$REQUEST_METHOD" SCRIPT_NAME="$SCRIPT_NAME" SCRIPT_FILENAME="$SCRIPT_FILENAME" cgi-fcgi -bind -connect "$1" 2> /dev/null)
6565
FPM_STATUS=$(echo "$FPM_STATUS" | tail +5)
6666

6767
if test "$VERBOSE" = 1; then printf "php-fpm status output:\\n%s\\n" "$FPM_STATUS"; fi;

test/testinfra/test_fpm.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def test_fpm_on_socket(host):
3232
host.run("sed -i /usr/local/etc/php-fpm.d/zz-docker.conf -e '/^listen/ s/.*/listen = 9000/'")
3333
host.run("kill -USR2 1")
3434

35+
# https://github.com/renatomefi/php-fpm-healthcheck/issues/18
36+
@pytest.mark.php_fpm
37+
def test_fpm_on_socket_with_huge_env(host):
38+
cmd = host.run("HUGE_ENV=\"$(dd if=/dev/zero bs=8192 count=1 | tr '\\000' '\\040')\" php-fpm-healthcheck -v")
39+
assert cmd.rc == 0
40+
assert "Trying to connect to php-fpm via:" in cmd.stdout
41+
assert "status output:" in cmd.stdout
42+
assert "pool:" in cmd.stdout
43+
3544
@pytest.mark.alpine
3645
def test_exit_when_fpm_is_not_reachable_apk(host):
3746
cmd = host.run("FCGI_CONNECT=localhost:9001 php-fpm-healthcheck -v")

test/testinfra/test_metrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
@pytest.mark.php_fpm
44
def test_metric_fail_accepted_conn(host):
5+
host.run("kill -USR2 1") # reset accepted conn value
56
cmd = host.run("php-fpm-healthcheck --accepted-conn=0")
67
assert cmd.rc == 1
78
assert "'accepted conn' value '1' is greater than expected '0'" in cmd.stderr

0 commit comments

Comments
 (0)