diff --git a/runtime-tests/newrelic/7.4-alpine/goss.yaml b/runtime-tests/newrelic/7.4-alpine/goss.yaml deleted file mode 100644 index d2c8bf2..0000000 --- a/runtime-tests/newrelic/7.4-alpine/goss.yaml +++ /dev/null @@ -1,11 +0,0 @@ -file: - /etc/php7/conf.d/newrelic.ini: - exists: true - mode: "0644" - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/^newrelic.transaction_tracer.enabled = true/' - - '/^newrelic.distributed_tracing_enabled = true/' - - '/^newrelic.loglevel = \"verbosedebug\"/' - - '/^newrelic.daemon.loglevel = \"verbosedebug\"/' - - '/^newrelic.special=debug_autorum/' diff --git a/runtime-tests/newrelic/goss.yaml b/runtime-tests/newrelic/goss.yaml index 27fb171..ea8df64 100644 --- a/runtime-tests/newrelic/goss.yaml +++ b/runtime-tests/newrelic/goss.yaml @@ -9,3 +9,10 @@ file: - '/^newrelic.loglevel = \"verbosedebug\"/' - '/^newrelic.daemon.loglevel = \"verbosedebug\"/' - '/^newrelic.special=debug_autorum/' + /goss/docker_output.log: + exists: true + filetype: file # file, symlink, directory + contains: # Check file content for these patterns + - '/enabling APM metrics/' + - '/adding in newrelic.special/' + - '/enabling tracing/' diff --git a/runtime-tests/startup/7.4/goss.yaml b/runtime-tests/startup/7.4/goss.yaml deleted file mode 100644 index 7c10162..0000000 --- a/runtime-tests/startup/7.4/goss.yaml +++ /dev/null @@ -1,6 +0,0 @@ -file: - /goss/docker_output.log: - exists: true - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/launching...$/' diff --git a/runtime-tests/startup/8.0/goss.yaml b/runtime-tests/startup/8.0/goss.yaml deleted file mode 100644 index 7c10162..0000000 --- a/runtime-tests/startup/8.0/goss.yaml +++ /dev/null @@ -1,6 +0,0 @@ -file: - /goss/docker_output.log: - exists: true - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/launching...$/' diff --git a/runtime-tests/startup/7.4-alpine/goss.yaml b/runtime-tests/startup/goss.yaml similarity index 72% rename from runtime-tests/startup/7.4-alpine/goss.yaml rename to runtime-tests/startup/goss.yaml index 7c10162..c0a599f 100644 --- a/runtime-tests/startup/7.4-alpine/goss.yaml +++ b/runtime-tests/startup/goss.yaml @@ -4,3 +4,5 @@ file: filetype: file # file, symlink, directory contains: # Check file content for these patterns - '/launching...$/' + - '/fpm is running/' + - '/ready to handle connections/' diff --git a/test.sh b/test.sh index e7d8f23..31b2d80 100755 --- a/test.sh +++ b/test.sh @@ -14,18 +14,30 @@ set -o pipefail MACHINE=$1 INTERNAL_PORT=8080 PREFIX="==>" +BASE_NAME="docker-php" -if [ -z "$1" ]; then +if [[ -z "$1" ]]; then printf "Basic integration script for docker-php and its variants\n\n" printf "Usage:\n\ttest.sh [docker-machine ip]\n" - exit 1; + exit 1 fi -if [ ! $PHP_VARIANT ]; then +if [[ ! $PHP_VARIANT ]]; then echo "Missing PHP_VARIANT environment variable" exit 1 fi +# Required for dgoss execution, below +if [[ ! -n "$GOSS_PATH" ]]; then + [ -f $(which goss) ] || { echo 'goss not found, pass GOSS_PATH'; exit 1; } + GOSS_PATH=$(which goss) +fi + +if [[ ! -n "$DGOSS_PATH" ]]; then + [ -f $(which dgoss) ] || { echo 'dgoss not found, pass DGOSS_PATH'; exit 1; } + DGOSS_PATH=$(which dgoss) +fi + # Distinguish between naming types VARIANT_NAME=$PHP_VARIANT DOCKERFILE_NAME="Dockerfile-${PHP_VARIANT}" @@ -36,13 +48,12 @@ TEST_STRING="PHP Version ${PHP_VERSION}." PLATFORM="${PLATFORM:=linux/amd64}" # Since containers may or may not be against the same docker engine, create a matrix-unique tag name for outputs -TAG_NAME="docker-php-${VARIANT_NAME}-${PLATFORM}" +TAG_NAME="${BASE_NAME}-${VARIANT_NAME}-${PLATFORM}" # Formats as lowercase TAG_NAME=$(echo $TAG_NAME | tr '[:upper:]' '[:lower:]') # Removes slashes TAG_NAME=$(echo $TAG_NAME | sed 's/\///') - echo "${PREFIX} Variant ${VARIANT_NAME}" echo "${PREFIX} PHP Version: ${PHP_VERSION}" echo "${PREFIX} Dockerfile: ${DOCKERFILE_NAME}" @@ -51,6 +62,9 @@ echo "${PREFIX} Platform: ${PLATFORM}" printf "${PREFIX} Building container\n" +printf "${PREFIX} using goss (${GOSS_PATH})\n" +printf "${PREFIX} using dgoss (${DGOSS_PATH})\n" + docker buildx build --platform $PLATFORM --iidfile $TAG_NAME -t $TAG_NAME -f $DOCKERFILE_NAME . # NOTE: multi-arch builds may not be accessible by docker tag, instead target by ID @@ -63,6 +77,9 @@ printf "${PREFIX} Running container in background\n" CONTAINER_ID=$(docker run --rm --platform $PLATFORM --env-file ./.test.env -p $INTERNAL_PORT -d $BUILD_SHA) CONTAINER_PORT=$(docker inspect --format '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' $CONTAINER_ID) +printf "${PREFIX} Waiting for container to boot\n" +sleep 5 + # ==> Cleanup routine # CI environments may be ephemeral, but local environments are not function finish { @@ -77,9 +94,7 @@ function finish { trap finish EXIT -printf "${PREFIX} Waiting for container to boot\n" -sleep 5 - +# ------------------------------------------------------------- echo "${PREFIX} Check default response, including PHP version identification" curl "${MACHINE}:${CONTAINER_PORT}" | grep "${TEST_STRING}" @@ -90,16 +105,19 @@ echo "${PREFIX} Send uploaded file" curl --form upload=@tmp.txt "${MACHINE}:${CONTAINER_PORT}" \ | grep "${TEST_STRING}" > /dev/null +# ------------------------------------------------------------- echo "${PREFIX} Perform startup tests" -GOSS_PATH=goss \ + +GOSS_FILES_PATH="runtime-tests/startup/" \ GOSS_SLEEP=5 \ -GOSS_FILES_PATH="runtime-tests/startup/${PHP_VARIANT}/" \ -"${GOSS_INSTALL_PATH}dgoss" run --rm $BUILD_SHA +$DGOSS_PATH run --rm $BUILD_SHA +# ------------------------------------------------------------- echo "${PREFIX} Perform NewRelic runtime tests" -GOSS_PATH=goss \ -GOSS_FILES_PATH="runtime-tests/newrelic/${PHP_VARIANT}/" \ -"${GOSS_INSTALL_PATH}dgoss" run \ + +GOSS_FILES_PATH="runtime-tests/newrelic/" \ +GOSS_SLEEP=5 \ +$DGOSS_PATH run --rm \ -e REPLACE_NEWRELIC_APP="abcdefg" \ -e REPLACE_NEWRELIC_LICENSE="hijklmno" \ -e NEWRELIC_TRACING_ENABLED="true" \