-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Cleaning up testing structure
- Loading branch information
Bryan Latten
committed
Dec 20, 2021
1 parent
f6cf050
commit aebaaf7
Showing
8 changed files
with
46 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected] "${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" \ | ||
|