Skip to content

Commit

Permalink
Updated to reflect changes in main
Browse files Browse the repository at this point in the history
  • Loading branch information
CGoodwin90 committed Nov 9, 2023
2 parents cb36382 + 467fc9f commit a214326
Show file tree
Hide file tree
Showing 19 changed files with 477 additions and 252 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,40 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ github.repository_owner }}/internal-services-test
ghcr.io/${{ github.repository_owner }}/internal-services-test
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/images-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Image test routine

on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'

jobs:
test-suite:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Pull all images
run: |
docker compose pull --ignore-pull-failures
- name: Install test harness
run: |
yarn add leia-parser mocha chai command-line-test
- name: Generate test files
run: |
yarn leia "TESTING*.md" test -r 2 -s 'Start up tests' -t 'Verification commands' -c 'Destroy tests' --split-file
- name: Run docker-compose tests
run: |
yarn mocha --timeout 900000 test/*compose*.func.js
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules
/test
package.json
yarn.lock
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
FROM golang:alpine
FROM golang:1.21-alpine

WORKDIR /go-dbaas
WORKDIR /internal-services-test

ADD . .

RUN go get github.com/joho/godotenv

RUN go build && chmod +x ./go-dbaas
RUN go build && chmod +x ./internal-services-test

ENV SOLR_HOST=solr \
REDIS_HOST=redis \
OPENSEARCH_HOST=opensearch-2
ENV STORAGE_LOCATION='/app/files'

EXPOSE 3000

CMD sleep 10 && ./go-dbaas
CMD sleep 10 && ./internal-services-test
93 changes: 93 additions & 0 deletions TESTING_dockercompose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Docker Compose test internal services test
==========================================

This is a docker-compose testing suite for the internal services:

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# should remove any previous runs and poweroff
docker compose down --volumes --remove-orphans

# should start up our services successfully
docker compose build && docker compose up -d
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Ensure services are ready to connect
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://mariadb-10-5:3306 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://mariadb-10-11:3306 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://postgres-11:5432 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://postgres-15:5432 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://opensearch-2:9200 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://mongo-4:27017 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://redis-6:6379 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://redis-7:6379 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://solr-7:8983 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://solr-8:8983 -timeout 1m

# commons should be running Alpine Linux
docker compose exec -T commons sh -c "cat /etc/os-release" | grep "Alpine Linux"

# mariadb-10-5 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mariadb?service=mariadb-10-5" | grep "SERVICE_HOST=10.5"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mariadb?service=mariadb-10-5" | grep "LAGOON_TEST_VAR=internal-services-test"

# mariadb-10-11 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mariadb?service=mariadb-10-11" | grep "SERVICE_HOST=10.11"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mariadb?service=mariadb-10-11" | grep "LAGOON_TEST_VAR=internal-services-test"

# postgres-11 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-11" | grep "SERVICE_HOST=PostgreSQL 11"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-11" | grep "LAGOON_TEST_VAR=internal-services-test"

# postgres-15 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-15" | grep "SERVICE_HOST=PostgreSQL 15"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-15" | grep "LAGOON_TEST_VAR=internal-services-test"

# opensearch-2 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/opensearch?service=opensearch-2" | grep "SERVICE_HOST=opensearch-2"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/opensearch?service=opensearch-2" | grep "LAGOON_TEST_VAR=internal-services-test"

# mongo-4 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mongo?service=mongo-4" | grep "SERVICE_HOST="
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mongo?service=mongo-4" | grep "LAGOON_TEST_VAR=internal-services-test"

# redis-6 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/redis?service=redis-6" | grep "SERVICE_HOST=redis-6"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/redis?service=redis-6" | grep "LAGOON_TEST_VAR=internal-services-test"

# redis-7 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/redis?service=redis-7" | grep "SERVICE_HOST=redis-7"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/redis?service=redis-7" | grep "LAGOON_TEST_VAR=internal-services-test"

# solr-7 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/solr?service=solr-7" | grep "SERVICE_HOST=solr-7"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/solr?service=solr-7" | grep "LAGOON_TEST_VAR=internal-services-test"

# solr-8 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/solr?service=solr-8" | grep "SERVICE_HOST=solr-8"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/solr?service=solr-8" | grep "LAGOON_TEST_VAR=internal-services-test"

# persistent storage should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/storage?path=/app/files" | grep "STORAGE_PATH=/app/files/storage.txt"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/storage?path=/app/files" | grep "LAGOON_TEST_VAR=internal-services-test"
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# should be able to destroy our services with success
docker compose down --volumes --remove-orphans
```
92 changes: 48 additions & 44 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
services:
web:
build:
context: .
dockerfile: Dockerfile
labels:
lagoon.type: basic
ports:
- '3000:3000'
container_name: go-web
environment:
- MARIADB_10_4_DRUPAL_USERNAME=drupal
- MARIADB_10_4_DRUPAL_PASSWORD=drupal
- MARIADB_10_4_DRUPAL_DATABASE=drupal
- POSTGRES_SECURE_USERNAME=secure
- POSTGRES_SECURE_PASSWORD=secure
- POSTGRES_SECURE_DATABASE=secure
- POSTGRES_SECURE_HOST=postgres-secure
- POSTGRES_SECURE_PORT=5432
commons:
image: uselagoon/commons:latest

mariadb-10-4-drupal:
image: uselagoon/mariadb-10.4-drupal
labels:
lagoon.type: mariadb-single
ports:
- '3306'
environment:
- LAGOON_TEST_VAR=test
- LAGOON_GIT_SHA=SHA256
- LAGOON_ENVIRONMENT_TYPE=development
# web:
# build:
# context: .
# dockerfile: Dockerfile
# labels:
# lagoon.type: basic
# ports:
# - '3000:3000'
# container_name: go-web
# environment:
# - LAGOON_TEST_VAR="88@oWT47^v0QN6ZuId#rbqLW5h!#P8Zzsf0w@p7I@3B%E6b1A8"
# - MARIADB_10_4_DRUPAL_USERNAME=drupal
# - MARIADB_10_4_DRUPAL_PASSWORD=drupal
# - MARIADB_10_4_DRUPAL_DATABASE=drupal
# - POSTGRES_SECURE_USERNAME=secure
# - POSTGRES_SECURE_PASSWORD=secure
# - POSTGRES_SECURE_DATABASE=secure
# - POSTGRES_SECURE_HOST=postgres-secure
# - POSTGRES_SECURE_PORT=5432

mongo-somedb:
image: uselagoon/mongo-4:latest
labels:
lagoon.type: mongo
ports:
- '27017'
# mariadb-10-4-drupal:
# image: uselagoon/mariadb-10.4-drupal
# labels:
# lagoon.type: mariadb-single
# ports:
# - '3306'
# environment:
# - LAGOON_TEST_VAR=test
# - LAGOON_GIT_SHA=SHA256
# - LAGOON_ENVIRONMENT_TYPE=development

postgres-secure:
image: testlagoon/postgres-15:main
labels:
lagoon.type: postgres
ports:
- '5432'
environment:
- POSTGRES_PASSWORD=secure
- POSTGRES_USER=secure
- POSTGRES_DB=secure
# mongo-somedb:
# image: uselagoon/mongo-4:latest
# labels:
# lagoon.type: mongo
# ports:
# - '27017'

# postgres-secure:
# image: testlagoon/postgres-15:main
# labels:
# lagoon.type: postgres
# ports:
# - '5432'
# environment:
# - POSTGRES_PASSWORD=secure
# - POSTGRES_USER=secure
# - POSTGRES_DB=secure
Loading

0 comments on commit a214326

Please sign in to comment.