feat(dbtest): Make test container name configurable

This commit is contained in:
Timothy Messier committed 2021-11-03 07:44:51 -04:00
1 parent decc3ec2cf
commit 35a7c4f6e7
2 files changed
+15 -4

No files matched your search

+9
View File
@@ -144,6 +144,15 @@ $ make test-database-up
$ make test
```
By default the container name is `boundary-sql-tests`.
This can be changed in the same way as the port:
```
$ export TEST_CONTAINER_NAME="custom-name"
$ make test-database-up
$ docker logs custom-name
```
The default docker image is built using the `postgres:11` base image.
The image can be changed using a make option to test against other versions:
+6 -4
View File
@@ -8,6 +8,7 @@ IMAGE_NAME=postgres
IMAGE_TAG ?= $(REGISTRY_NAME)/$(IMAGE_NAME):11-alpine
PG_OPTS ?=
TEST_DB_PORT ?= 5432
TEST_CONTAINER_NAME ?= boundary-sql-tests
# Generate targets from dockerfiles
dockerfiles = $(wildcard Dockerfile.*)
@@ -29,7 +30,7 @@ database-up:
@echo "Additional postgres configuration: $(PG_OPTS)"
@docker run \
$(DOCKER_ARGS) \
--name boundary-sql-tests \
--name $(TEST_CONTAINER_NAME) \
-p $(TEST_DB_PORT):5432 \
-e POSTGRES_PASSWORD=boundary \
-e POSTGRES_USER=boundary \
@@ -40,11 +41,12 @@ database-up:
$(IMAGE_TAG) \
-c 'config_file=/etc/postgresql/postgresql.conf' \
$(PG_OPTS) 1> /dev/null
@echo "Container name: $(TEST_CONTAINER_NAME)"
@echo "Test database available at: 127.0.0.1:$(TEST_DB_PORT)"
@echo "For database logs run:"
@echo " docker logs boundary-sql-tests"
@echo " docker logs $(TEST_CONTAINER_NAME)"
clean:
docker stop boundary-sql-tests || true
docker rm -v boundary-sql-tests || true
docker stop $(TEST_CONTAINER_NAME) || true
docker rm -v $(TEST_CONTAINER_NAME) || true
.PHONY: all docker-build database-up ${docker-builds} ${docker-publishes} clean