diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fb4b185..887222b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,12 +20,7 @@ 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 @@ -33,14 +28,7 @@ jobs: 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 @@ -48,16 +36,8 @@ jobs: 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 @@ -65,13 +45,8 @@ jobs: 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 @@ -79,11 +54,8 @@ jobs: 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 @@ -91,6 +63,32 @@ jobs: 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" diff --git a/Makefile b/Makefile index 854fdf9..b923d8c 100644 --- a/Makefile +++ b/Makefile @@ -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} diff --git a/php-fpm-healthcheck b/php-fpm-healthcheck index cd69742..588caea 100755 --- a/php-fpm-healthcheck +++ b/php-fpm-healthcheck @@ -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 @@ -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; @@ -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 diff --git a/test/Dockerfile-stretch b/test/Dockerfile-bullseye similarity index 90% rename from test/Dockerfile-stretch rename to test/Dockerfile-bullseye index adcb3d3..8dbfeee 100644 --- a/test/Dockerfile-stretch +++ b/test/Dockerfile-bullseye @@ -1,4 +1,4 @@ -FROM php:7.2-fpm-stretch +FROM php:7.4-fpm-bullseye # Required software RUN set -x \ diff --git a/test/Dockerfile-buster b/test/Dockerfile-trixie similarity index 91% rename from test/Dockerfile-buster rename to test/Dockerfile-trixie index c1fafa5..0276bae 100644 --- a/test/Dockerfile-buster +++ b/test/Dockerfile-trixie @@ -1,4 +1,4 @@ -FROM php:7.4-fpm-buster +FROM php:8.1-fpm-trixie # Required software RUN set -x \ diff --git a/test/testinfra/test_execution.py b/test/testinfra/test_execution.py index 97ac00c..6127608 100644 --- a/test/testinfra/test_execution.py +++ b/test/testinfra/test_execution.py @@ -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 @@ -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")