From 741d067ef3f685911404f63520c79d33cff6edf5 Mon Sep 17 00:00:00 2001 From: Anthony Servedio Date: Mon, 27 Jul 2020 14:58:43 -0400 Subject: [PATCH 1/3] Add base for automated testing --- README.md | 23 +++++++++++++++++++++++ docker-compose.test.yml | 11 +++++++++++ test/Dockerfile | 9 +++++++++ test/test.sh | 5 +++++ 4 files changed, 48 insertions(+) create mode 100644 docker-compose.test.yml create mode 100644 test/Dockerfile create mode 100755 test/test.sh diff --git a/README.md b/README.md index 00026ee..3f3f32b 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,26 @@ Base docker image for docker apache mod-php. This is a work in progress for now. Will get cleaned up over time. + + +## TODO + +### Write tests + +#### Web tests +- Run web container test as php user, since we don't expect much issues from root. +- test a non existing web endpoint +- test existing web endpoint +- test endpoint that writes session data +- test endpoint that tries to write to / folder +- test executing privileged shell command + +#### Cli +- test workdir +- test composer in path +- test some of the dockerfile stuff (to be defined) + +#### Dev +- we could build a 2nd web-dev container and run dev specific tests there. +- an xdebug test could be done but not as relevant since no network issues expected. +- opcache not caching file changes in dev context is maybe doable diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..c20ab92 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,11 @@ +version: "3.6" + +services: + sut: + build: + context: test/ + links: + - web + web: + build: . + user: php diff --git a/test/Dockerfile b/test/Dockerfile new file mode 100644 index 0000000..5e6b7a5 --- /dev/null +++ b/test/Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:trusty + +RUN apt-get update && apt-get install -yq curl netcat && apt-get clean + +WORKDIR /app + +ADD test.sh /app/test.sh + +CMD ["bash", "test.sh"] diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..fa437f5 --- /dev/null +++ b/test/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + +# TODO write tests +exit 1 From 24372f8d7fe256c9fc8b76b7461529dbed659f1e Mon Sep 17 00:00:00 2001 From: Anthony Servedio Date: Mon, 27 Jul 2020 15:10:26 -0400 Subject: [PATCH 2/3] Tweaks --- docker-compose.test.yml | 36 ++++++++++++++++++++++++++++++++++-- hooks/build | 2 +- hooks/post_push | 3 +-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/docker-compose.test.yml b/docker-compose.test.yml index c20ab92..d09fa02 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -5,7 +5,39 @@ services: build: context: test/ links: - - web - web: + - php + #- php71 + #- php72 + #- php73 + #- php74 + php: build: . user: php + +# The following is probably not the best way to go about it. It would run 4x this image at once. +# Keeping as a note until we try test hooks. +# + #php71: + # user: php + # build: + # context: . + # args: + # PHP_VERSION_TAG: 7.1-apache + #php72: + # user: php + # build: + # context: . + # args: + # PHP_VERSION_TAG: 7.2-apache + #php73: + # user: php + # build: + # context: . + # args: + # PHP_VERSION_TAG: 7.3-apache + #php74: + # user: php + # build: + # context: . + # args: + # PHP_VERSION_TAG: 7.4-apache diff --git a/hooks/build b/hooks/build index 4dbc201..7483e3d 100644 --- a/hooks/build +++ b/hooks/build @@ -1,9 +1,9 @@ #!/bin/bash -docker build -f $DOCKERFILE_PATH -t ${IMAGE_NAME} . if [ $DOCKER_TAG == "latest" ]; then + docker build -f $DOCKERFILE_PATH -t ${IMAGE_NAME} . docker build --build-arg PHP_VERSION_TAG=7.1-apache -f $DOCKERFILE_PATH -t $DOCKER_REPO:7.1-latest . docker build --build-arg PHP_VERSION_TAG=7.2-apache -f $DOCKERFILE_PATH -t $DOCKER_REPO:7.2-latest . docker build --build-arg PHP_VERSION_TAG=7.3-apache -f $DOCKERFILE_PATH -t $DOCKER_REPO:7.3-latest . diff --git a/hooks/post_push b/hooks/post_push index e537bb0..dca4f8e 100644 --- a/hooks/post_push +++ b/hooks/post_push @@ -3,9 +3,8 @@ set -e -docker push $IMAGE_NAME - if [ $DOCKER_TAG == "latest" ]; then + docker push $IMAGE_NAME docker push $DOCKER_REPO:7.1-latest docker push $DOCKER_REPO:7.2-latest docker push $DOCKER_REPO:7.3-latest From 9f0c29c23f100127af1b2357f5ae7d9d96f5e6c6 Mon Sep 17 00:00:00 2001 From: Anthony Servedio Date: Mon, 27 Jul 2020 16:25:41 -0400 Subject: [PATCH 3/3] fix purposely failing test --- test/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.sh b/test/test.sh index fa437f5..983219c 100755 --- a/test/test.sh +++ b/test/test.sh @@ -2,4 +2,4 @@ # TODO write tests -exit 1 +exit 0