Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 37 additions & 39 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,77 +20,75 @@ jobs:
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:7.1-fpm-alpine3.7" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.1-fpm-alpine3.8" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.1-fpm-alpine3.9" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.1-fpm-alpine3.10" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.1-fpm-stretch" DOCKERFILE="stretch"
- run: make test-image IMAGE="php:7.1-fpm-buster" DOCKERFILE="buster"
- run: make test-image IMAGE="php:7.1-fpm-alpine" DOCKERFILE="alpine"

test-72:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:7.2-fpm-alpine3.7" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.2-fpm-alpine3.8" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.2-fpm-alpine3.9" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.2-fpm-alpine3.10" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.2-fpm-alpine3.11" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.2-fpm-alpine3.12" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.2-fpm-stretch" DOCKERFILE="stretch"
- run: make test-image IMAGE="php:7.2-fpm-buster" DOCKERFILE="buster"
- run: make test-image IMAGE="php:7.2-fpm-alpine" DOCKERFILE="alpine"

test-73:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:7.3-fpm-alpine3.8" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.9" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.10" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.11" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.12" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.13" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.14" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-alpine3.15" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-stretch" DOCKERFILE="stretch"
- run: make test-image IMAGE="php:7.3-fpm-buster" DOCKERFILE="buster"
- run: make test-image IMAGE="php:7.3-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.3-fpm-bullseye" DOCKERFILE="bullseye"

test-74:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:7.4-fpm-alpine3.10" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-alpine3.11" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-alpine3.12" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-alpine3.13" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-alpine3.14" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-alpine3.15" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-buster" DOCKERFILE="buster"
- run: make test-image IMAGE="php:7.4-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:7.4-fpm-bullseye" DOCKERFILE="bullseye"

test-80:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:8.0-fpm-alpine3.12" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.0-fpm-alpine3.13" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.0-fpm-alpine3.14" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.0-fpm-alpine3.15" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.0-fpm-buster" DOCKERFILE="buster"
- run: make test-image IMAGE="php:8.0-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.0-fpm-bullseye" DOCKERFILE="bullseye"

test-81:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:8.1-fpm-alpine3.14" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.1-fpm-alpine3.15" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.1-fpm-buster" DOCKERFILE="buster"
- run: make test-image IMAGE="php:8.1-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.1-fpm-trixie" DOCKERFILE="trixie"

test-82:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:8.2-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.2-fpm-trixie" DOCKERFILE="trixie"

test-83:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:8.3-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.3-fpm-trixie" DOCKERFILE="trixie"

test-84:
runs-on: ubuntu-latest
needs: lint
steps:

- uses: actions/checkout@v2
- run: make test-image IMAGE="php:8.4-fpm-alpine" DOCKERFILE="alpine"
- run: make test-image IMAGE="php:8.4-fpm-trixie" DOCKERFILE="trixie"
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ test: ## Test code in multiple images
$(MAKE) test-image IMAGE="php:7.4-fpm-alpine" DOCKERFILE="alpine"
$(MAKE) test-image IMAGE="php:8.0-fpm-alpine" DOCKERFILE="alpine"
$(MAKE) test-image IMAGE="php:8.1-fpm-alpine" DOCKERFILE="alpine"
$(MAKE) test-image IMAGE="php:7.1-fpm-stretch" DOCKERFILE="stretch"
$(MAKE) test-image IMAGE="php:7.2-fpm-stretch" DOCKERFILE="stretch"
$(MAKE) test-image IMAGE="php:7.3-fpm-stretch" DOCKERFILE="stretch"
$(MAKE) test-image IMAGE="php:7.4-fpm-buster" DOCKERFILE="buster"
$(MAKE) test-image IMAGE="php:8.0-fpm-buster" DOCKERFILE="buster"
$(MAKE) test-image IMAGE="php:8.1-fpm-buster" DOCKERFILE="buster"
$(MAKE) test-image IMAGE="php:8.2-fpm-alpine" DOCKERFILE="alpine"
$(MAKE) test-image IMAGE="php:8.3-fpm-alpine" DOCKERFILE="alpine"
$(MAKE) test-image IMAGE="php:8.4-fpm-alpine" DOCKERFILE="alpine"
$(MAKE) test-image IMAGE="php:7.3-fpm-bullseye" DOCKERFILE="bullseye"
$(MAKE) test-image IMAGE="php:7.4-fpm-bullseye" DOCKERFILE="bullseye"
$(MAKE) test-image IMAGE="php:8.0-fpm-bullseye" DOCKERFILE="bullseye"
$(MAKE) test-image IMAGE="php:8.1-fpm-trixie" DOCKERFILE="trixie"
$(MAKE) test-image IMAGE="php:8.2-fpm-trixie" DOCKERFILE="trixie"
$(MAKE) test-image IMAGE="php:8.3-fpm-trixie" DOCKERFILE="trixie"
$(MAKE) test-image IMAGE="php:8.4-fpm-trixie" DOCKERFILE="trixie"

test-image:
./test/docker.sh ${DOCKERFILE} ${IMAGE}
Expand Down
17 changes: 13 additions & 4 deletions php-fpm-healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
# Available options:
# -v|--verbose
#
# Connection options:
# --fcgi-connect=host:port
# --fcgi-status-path=path
#
# Metric options, fails in case the CURRENT VALUE is bigger than the GIVEN VALUE
# --accepted-conn=n
# --listen-queue=n
Expand Down Expand Up @@ -108,7 +112,7 @@ check_fpm_health() {
done
}

if ! GETOPT=$(getopt -o v --long verbose,accepted-conn:,listen-queue:,max-listen-queue:,listen-queue-len:,idle-processes:,active-processes:,total-processes:,max-active-processes:,max-children-reached:,slow-requests: -n 'php-fpm-healthcheck' -- "$@"); then
if ! GETOPT=$(getopt -o v --long verbose,fcgi-connect:,fcgi-status-path:,accepted-conn:,listen-queue:,max-listen-queue:,listen-queue-len:,idle-processes:,active-processes:,total-processes:,max-active-processes:,max-children-reached:,slow-requests: -n 'php-fpm-healthcheck' -- "$@"); then
>&2 echo "Invalid options, terminating." ; exit 3
fi;

Expand All @@ -118,16 +122,21 @@ eval set -- "$GETOPT"
FCGI_CONNECT_DEFAULT="localhost:9000"
FCGI_STATUS_PATH_DEFAULT="/status"

FCGI_CONNECT="${FCGI_CONNECT_ARG:-${FCGI_CONNECT:-$FCGI_CONNECT_DEFAULT}}"
SCRIPT_NAME="${FCGI_STATUS_PATH_ARG:-${FCGI_STATUS_PATH:-$FCGI_STATUS_PATH_DEFAULT}}"
SCRIPT_FILENAME="$SCRIPT_NAME"

export REQUEST_METHOD="GET"
export SCRIPT_NAME="${FCGI_STATUS_PATH:-$FCGI_STATUS_PATH_DEFAULT}"
export SCRIPT_FILENAME="${FCGI_STATUS_PATH:-$FCGI_STATUS_PATH_DEFAULT}"
FCGI_CONNECT="${FCGI_CONNECT:-$FCGI_CONNECT_DEFAULT}"
export SCRIPT_NAME
export SCRIPT_FILENAME

VERBOSE=0

while test "$1"; do
case "$1" in
-v|--verbose ) VERBOSE=1; shift ;;
--fcgi-connect ) FCGI_CONNECT_ARG="$2"; shift 2 ;;
--fcgi-status-path ) FCGI_STATUS_PATH_ARG="$2"; shift 2 ;;
--) shift ; break ;;
* ) check_later "$1" "$2"; shift 2 ;;
esac
Expand Down
2 changes: 1 addition & 1 deletion test/Dockerfile-stretch → test/Dockerfile-bullseye
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.2-fpm-stretch
FROM php:7.4-fpm-bullseye

# Required software
RUN set -x \
Expand Down
2 changes: 1 addition & 1 deletion test/Dockerfile-buster → test/Dockerfile-trixie
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-fpm-buster
FROM php:8.1-fpm-trixie

# Required software
RUN set -x \
Expand Down
21 changes: 18 additions & 3 deletions test/testinfra/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def test_valid_with_non_integer_value_exits_properly(host):

@pytest.mark.php_fpm
def test_all_available_options_at_once(host):
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")
cmd = host.run("php-fpm-healthcheck --accepted-conn=100000 --listen-queue=100000 --max-listen-queue=100000 "
"--listen-queue-len=100000 --idle-processes=100000 --active-processes=100000 --total-processes=100000 "
"--max-active-processes=100000 --max-children-reached=100000 --slow-requests=100000")
assert cmd.rc == 0

@pytest.mark.php_fpm
Expand All @@ -45,6 +45,21 @@ def test_all_available_options(host, option):
assert "value" in cmd.stdout
assert "and expected is less than '1000'" in cmd.stdout

@pytest.mark.php_fpm
def test_fcgi_connect_option(host):
cmd = host.run("php-fpm-healthcheck --fcgi-connect=127.0.0.1:9000")
assert cmd.rc == 0

@pytest.mark.php_fpm
def test_fcgi_status_path_option(host):
cmd = host.run("php-fpm-healthcheck --fcgi-status-path=/status")
assert cmd.rc == 0

@pytest.mark.php_fpm
def test_fcgi_options_combined(host):
cmd = host.run("php-fpm-healthcheck --fcgi-connect=localhost:9000 --fcgi-status-path=/status --accepted-conn=100000")
assert cmd.rc == 0

@pytest.mark.alpine
def test_missing_fcgi_apk(host):
host.run("apk del fcgi")
Expand Down