Skip to content

Commit

Permalink
Merge pull request #45 from uselagoon/update-services-docs
Browse files Browse the repository at this point in the history
chore: update services and add readme
  • Loading branch information
tobybellwood authored May 13, 2024
2 parents 909e6c4 + aff248e commit c95b96e
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 13 deletions.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Lagoon Internal Services Test

This project was designed to perform a functional test on a given native Lagoon service.

It works by
* taking a service type (e.g. solr, redis, postgres etc)
* taking a service name (e.g. solr-9, redis-6, postgres-15) that matches the docker compose service name
* writing a set of predefined variables into the selected services data store
* reading this data back to a web page for easy validation

## Supported services

Internal Services Test currently supports
* [MariaDB](https://docs.lagoon.sh/docker-images/mariadb/) - use `mariadb`
* [MongoDB](https://docs.lagoon.sh/docker-images/mongodb/) - use `mongodb`
* [OpenSearch](https://docs.lagoon.sh/docker-images/opensearch/) - use `opensearch`
* [PostgreSQL](https://docs.lagoon.sh/docker-images/postgres/) - use `postgres`
* [Redis](https://docs.lagoon.sh/docker-images/redis/) - use `redis`
* [Solr](https://docs.lagoon.sh/docker-images/solr/) - use `solr`
* [Persistent Storage](https://docs.lagoon.sh/concepts-basics/docker-compose-yml/#persistent-storage/) - use `storage`

As we add more service types to Lagoon, this list may expand

## Usage in Docker Compose locally

This project can be cloned, and the services started with:

```
docker compose build
docker compose up -d
```

You can then access the main test interface at `http://0.0.0.0:3000/` - note that there is no default page (yet)

To check a service, use this format http://0.0.0.0:3000/{service-type}?service={service-name}

```
internal-services-test$ curl -kL http://0.0.0.0:3000/opensearch?service=opensearch-2
"SERVICE_HOST=opensearch-2"
"LAGOON_ENVIRONMENT_TYPE=development"
"LAGOON_GIT_SHA=SHA256"
"LAGOON_TEST_VAR=internal-services-test"
```
and to check a storage path
```
internal-services-test$ curl -kL http://0.0.0.0:3000/storage?path=/app/files
"STORAGE_PATH=/app/files/storage.txt"
"LAGOON_GIT_SHA=SHA256"
"LAGOON_ENVIRONMENT_TYPE=development"
"LAGOON_TEST_VAR=internal-services-test"
```

### Additional or custom variables

In the docker-compose.yml file, you can update the environment variables in the `web` service and restart the docker-compose service. This will provide the updated variables to the service next time it is called.

## Usage in Lagoon

This project can also be cloned and deployed into a Lagoon cluster, using the same patterns as above for verification.

Note that by default, all services in the docker-compose.yml will be deployed



16 changes: 8 additions & 8 deletions TESTING_dockercompose.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Run the following commands to validate things are rolling as they should.
# 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://postgres-12:5432 -timeout 1m
docker run --rm --net internal-services-test_default jwilder/dockerize dockerize -wait tcp://postgres-16: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
Expand All @@ -45,13 +45,13 @@ docker compose exec -T commons sh -c "curl -kL http://go-web:3000/mariadb?servic
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-12 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-12" | grep "SERVICE_HOST=PostgreSQL 12"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-12" | 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"
# postgres-16 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-16" | grep "SERVICE_HOST=PostgreSQL 16"
docker compose exec -T commons sh -c "curl -kL http://go-web:3000/postgres?service=postgres-16" | 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"
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ services:
ports:
- '3306'

postgres-11:
image: uselagoon/postgres-11:latest
postgres-12:
image: uselagoon/postgres-12:latest
labels:
lagoon.type: postgres-single
lagoon.persistent.size: 100Mi
ports:
- '5432'

postgres-15:
image: uselagoon/postgres-15:latest
postgres-16:
image: uselagoon/postgres-16:latest
labels:
lagoon.type: postgres
ports:
Expand Down Expand Up @@ -116,7 +116,7 @@ services:
- mycore

solr-9:
image: testlagoon/solr-9:pr-963
image: uselagoon/solr-9:latest
labels:
lagoon.type: solr
lagoon.persistent.size: 100Mi
Expand Down

0 comments on commit c95b96e

Please sign in to comment.