From 0ec5095cf5c9d12a68a47cb486a0483582c1d629 Mon Sep 17 00:00:00 2001 From: Rob Kiefer Date: Thu, 12 Jan 2017 14:51:40 -0500 Subject: [PATCH] Cleanup Makefile targets, script names, and README --- Makefile | 35 +++++++++++------- README.md | 37 ++++++++++++------- extension/Makefile | 2 +- .../{start-pg-docker.sh => start-docker.sh} | 0 4 files changed, 46 insertions(+), 28 deletions(-) rename scripts/{start-pg-docker.sh => start-docker.sh} (100%) diff --git a/Makefile b/Makefile index 3f4b804e6..28d1f6a0e 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,28 @@ -TEST_IMAGE_NAME = iobeamdb-test -TEST_CONTAINER_NAME = iobeamdb-test-container - +IMAGE_NAME = iobeamdb MAKE = make -all: test +all: test-docker -build-test-docker: - @docker build . -t $(TEST_IMAGE_NAME) +# Targets for installing the extension without using Docker +clean: + $(MAKE) -C ./extension clean + @rm -f ./extension/iobeamdb--*.sql -start-test-docker: stop-test-docker - @IOBEAMDB_DOCKER_IMAGE=$(TEST_IMAGE_NAME) ./scripts/start-pg-docker.sh +install: + $(MAKE) -C ./extension install -stop-test-docker: +# Targets for building/running Docker images +build-docker: + @docker build . -t $(IMAGE_NAME) + +start-docker: stop-docker + @IOBEAMDB_DOCKER_IMAGE=$(IMAGE_NAME) ./scripts/start-docker.sh + +stop-docker: @docker rm -f iobeamdb || : +# Targets for tests test-regression: @cd extension/sql/tests/regression; ./run.sh @@ -24,9 +32,10 @@ test-unit: test-all: test-regression test-unit @echo Running all tests +test-docker: build-docker start-docker test-all stop-docker + +# Setting up a single node database setup-single-node-db: - PGDATABASE=test ./scripts/run_sql.sh setup_single_node_db.psql + PGDATABASE=test ./scripts/run_sql.sh setup_single_node_db.psql -test: build-test-docker start-test-docker test-all stop-test-docker - -.PHONY: build-test-docker start-test-docker stop-test-docker test-regression test-unit test-all test all setup-single-node-db +.PHONY: build-docker start-docker stop-docker test-regression test-unit test-all test all setup-single-node-db diff --git a/README.md b/README.md index e64971672..358b935c7 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,26 @@ -### Running docker image +### Building and running in Docker -To start the database, simply: +The `Makefile` included in this repo has convenient commands for building, +starting, and stopping a Docker image of **iobeamdb**: ```bash -make start-pg-docker -``` -This will allow you to run the tests. When finished, -```bash -make stop-pg-docker +# To build the image +make build-docker +# To start the image (will stop any running instances first) +make start-docker +# To stop the image +make stop-docker ``` -### Initializing a single-node database -After setting up a docker image, you can start a local -single node database with the following command: +With the Docker image running you can run the tests (see Testing) or create +your own single-node cluster. + +#### Initializing a single-node database +After starting the Docker image, you can start a local single node database: ```bash make setup-single-node-db ``` -This will set up a database named iobeam which can be accessed with: + +This will set up a database named `iobeam` which can be accessed with: ```bash psql -U postgres -h localhost -d iobeam ``` @@ -27,10 +32,14 @@ psql -U postgres -h localhost -d iobeam * [Querying With Ioql](extension/sql/tests/regression/query.sql) ### Testing -There are three commands to run tests: (1) all tests, (2) regression tests, and -(3) unit tests. They are: +There are four commands to run tests: ```bash -make test +# Build and run a docker image and run all tests in that image +make test-docker +# Run all tests (no image built) +make test-all +# Run regression tests (no image built) make test-regression +# Run unit tests (no image built) make test-unit ``` diff --git a/extension/Makefile b/extension/Makefile index f6a3a0bce..106d467c9 100644 --- a/extension/Makefile +++ b/extension/Makefile @@ -35,4 +35,4 @@ package: clean all generate-sql-install-file $(install_sh) -m 644 iobeamdb.control 'package/extension/' $(install_sh) -m 644 iobeamdb--1.0.sql 'package/extension/' -.PHONY: check-sql-files generate-sql-install-file start-pg-docker stop-pg-docker test test-regression test-unit +.PHONY: check-sql-files generate-sql-install-file diff --git a/scripts/start-pg-docker.sh b/scripts/start-docker.sh similarity index 100% rename from scripts/start-pg-docker.sh rename to scripts/start-docker.sh