Skip to content

Commit aebaaf7

Browse files
author
Bryan Latten
committed
Test: fixing GH CI test environment
- Cleaning up testing structure
1 parent f6cf050 commit aebaaf7

File tree

8 files changed

+46
-40
lines changed

8 files changed

+46
-40
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- linux/amd64
1818
- linux/arm64
1919
exclude:
20-
- variant: 7.4-alpine
20+
# TODO: enable with compile cache
2121
- platform: linux/arm64
2222
env:
2323
TEST_MATCH: PHP Version ${{ matrix.variant }}
@@ -28,8 +28,9 @@ jobs:
2828
-
2929
name: Install goss
3030
run: |
31-
curl -fsSL https://goss.rocks/install | sh
31+
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.9/goss-linux-amd64 -o /usr/local/bin/goss
3232
curl -L https://raw.githubusercontent.com/aelsabbahy/goss/master/extras/dgoss/dgoss -o /usr/local/bin/dgoss
33+
chmod +rx /usr/local/bin/goss
3334
chmod +rx /usr/local/bin/dgoss
3435
-
3536
name: Detect host configuration

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ sudo: required
22

33
env:
44
global:
5-
- GOSS_INSTALL_PATH="./"
5+
- GOSS_PATH="./goss"
6+
- DGOSS_PATH="./dgoss"
67
jobs:
78
- PHP_VARIANT=7.4-alpine
89
- PHP_VARIANT=7.4

runtime-tests/newrelic/7.4-alpine/goss.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

runtime-tests/newrelic/goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ file:
99
- '/^newrelic.loglevel = \"verbosedebug\"/'
1010
- '/^newrelic.daemon.loglevel = \"verbosedebug\"/'
1111
- '/^newrelic.special=debug_autorum/'
12+
/goss/docker_output.log:
13+
exists: true
14+
filetype: file # file, symlink, directory
15+
contains: # Check file content for these patterns
16+
- '/enabling APM metrics/'
17+
- '/adding in newrelic.special/'
18+
- '/enabling tracing/'

runtime-tests/startup/7.4/goss.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

runtime-tests/startup/8.0/goss.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

runtime-tests/startup/7.4-alpine/goss.yaml renamed to runtime-tests/startup/goss.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ file:
44
filetype: file # file, symlink, directory
55
contains: # Check file content for these patterns
66
- '/launching...$/'
7+
- '/fpm is running/'
8+
- '/ready to handle connections/'

test.sh

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,30 @@ set -o pipefail
1414
MACHINE=$1
1515
INTERNAL_PORT=8080
1616
PREFIX="==>"
17+
BASE_NAME="docker-php"
1718

18-
if [ -z "$1" ]; then
19+
if [[ -z "$1" ]]; then
1920
printf "Basic integration script for docker-php and its variants\n\n"
2021
printf "Usage:\n\ttest.sh [docker-machine ip]\n"
21-
exit 1;
22+
exit 1
2223
fi
2324

24-
if [ ! $PHP_VARIANT ]; then
25+
if [[ ! $PHP_VARIANT ]]; then
2526
echo "Missing PHP_VARIANT environment variable"
2627
exit 1
2728
fi
2829

30+
# Required for dgoss execution, below
31+
if [[ ! -n "$GOSS_PATH" ]]; then
32+
[ -f $(which goss) ] || { echo 'goss not found, pass GOSS_PATH'; exit 1; }
33+
GOSS_PATH=$(which goss)
34+
fi
35+
36+
if [[ ! -n "$DGOSS_PATH" ]]; then
37+
[ -f $(which dgoss) ] || { echo 'dgoss not found, pass DGOSS_PATH'; exit 1; }
38+
DGOSS_PATH=$(which dgoss)
39+
fi
40+
2941
# Distinguish between naming types
3042
VARIANT_NAME=$PHP_VARIANT
3143
DOCKERFILE_NAME="Dockerfile-${PHP_VARIANT}"
@@ -36,13 +48,12 @@ TEST_STRING="PHP Version ${PHP_VERSION}."
3648
PLATFORM="${PLATFORM:=linux/amd64}"
3749

3850
# Since containers may or may not be against the same docker engine, create a matrix-unique tag name for outputs
39-
TAG_NAME="docker-php-${VARIANT_NAME}-${PLATFORM}"
51+
TAG_NAME="${BASE_NAME}-${VARIANT_NAME}-${PLATFORM}"
4052
# Formats as lowercase
4153
TAG_NAME=$(echo $TAG_NAME | tr '[:upper:]' '[:lower:]')
4254
# Removes slashes
4355
TAG_NAME=$(echo $TAG_NAME | sed 's/\///')
4456

45-
4657
echo "${PREFIX} Variant ${VARIANT_NAME}"
4758
echo "${PREFIX} PHP Version: ${PHP_VERSION}"
4859
echo "${PREFIX} Dockerfile: ${DOCKERFILE_NAME}"
@@ -51,6 +62,9 @@ echo "${PREFIX} Platform: ${PLATFORM}"
5162

5263
printf "${PREFIX} Building container\n"
5364

65+
printf "${PREFIX} using goss (${GOSS_PATH})\n"
66+
printf "${PREFIX} using dgoss (${DGOSS_PATH})\n"
67+
5468
docker buildx build --platform $PLATFORM --iidfile $TAG_NAME -t $TAG_NAME -f $DOCKERFILE_NAME .
5569

5670
# 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"
6377
CONTAINER_ID=$(docker run --rm --platform $PLATFORM --env-file ./.test.env -p $INTERNAL_PORT -d $BUILD_SHA)
6478
CONTAINER_PORT=$(docker inspect --format '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' $CONTAINER_ID)
6579

80+
printf "${PREFIX} Waiting for container to boot\n"
81+
sleep 5
82+
6683
# ==> Cleanup routine
6784
# CI environments may be ephemeral, but local environments are not
6885
function finish {
@@ -77,9 +94,7 @@ function finish {
7794

7895
trap finish EXIT
7996

80-
printf "${PREFIX} Waiting for container to boot\n"
81-
sleep 5
82-
97+
# -------------------------------------------------------------
8398
echo "${PREFIX} Check default response, including PHP version identification"
8499
curl "${MACHINE}:${CONTAINER_PORT}" | grep "${TEST_STRING}"
85100

@@ -90,16 +105,19 @@ echo "${PREFIX} Send uploaded file"
90105
curl --form upload=@tmp.txt "${MACHINE}:${CONTAINER_PORT}" \
91106
| grep "${TEST_STRING}" > /dev/null
92107

108+
# -------------------------------------------------------------
93109
echo "${PREFIX} Perform startup tests"
94-
GOSS_PATH=goss \
110+
111+
GOSS_FILES_PATH="runtime-tests/startup/" \
95112
GOSS_SLEEP=5 \
96-
GOSS_FILES_PATH="runtime-tests/startup/${PHP_VARIANT}/" \
97-
"${GOSS_INSTALL_PATH}dgoss" run --rm $BUILD_SHA
113+
$DGOSS_PATH run --rm $BUILD_SHA
98114

115+
# -------------------------------------------------------------
99116
echo "${PREFIX} Perform NewRelic runtime tests"
100-
GOSS_PATH=goss \
101-
GOSS_FILES_PATH="runtime-tests/newrelic/${PHP_VARIANT}/" \
102-
"${GOSS_INSTALL_PATH}dgoss" run \
117+
118+
GOSS_FILES_PATH="runtime-tests/newrelic/" \
119+
GOSS_SLEEP=5 \
120+
$DGOSS_PATH run --rm \
103121
-e REPLACE_NEWRELIC_APP="abcdefg" \
104122
-e REPLACE_NEWRELIC_LICENSE="hijklmno" \
105123
-e NEWRELIC_TRACING_ENABLED="true" \

0 commit comments

Comments
 (0)