Jugglr
Jugglr is a tool for managing test data and running tests with a lightweight, dedicated database. Jugglr enables developers, testers, and CI/CD processes to run tests against containerized databases with data loaded at runtime.
Authors
Installation
A. Download the Jugglr executable app from the project website to start using it right away.
B. Alternatively, follow these steps:
Clone the project
git clone https://github.com/oslabs-beta/Jugglr
Go to the project directory
cd Jugglr
Install dependencies
npm install
Start the servers
npm run build
npm start
Run tests
npm test
Note: you must be running Docker to use Jugglr. Download Docker Desktop from here.
Documentation
Detailed documentation on how to use Jugglr can be found here.
Running in CI/CD
To run tests in a CI/CD process, the Docker image must be built and run in a container on the CI/CD server. You may choose to create a second Dockerfile (e.g.) Dockerfile.cli as follows: Using the baseline Dockerfile created by Jugglr (in the <project root>
/jugglr/ directory), you can either load a sql file with all data included (i.e., a PostgreSQL dump file) or you can load data as a separate step, as described below
First, in the Dockerfile, add a step at the end to copy the csv file(s) into the container:
COPY <yourcsvfilename.csv with full path> <specify any path in the container, like /usr/data/yourcsvfilename.csv>
Build the image
- note: the dot after the image name is important, it means build the image from the current directory. If you want to build image from elsewhere, specify that location relative to where command is being run from
- if you name your Dockerfile a different name or put it in a different path, specify that after the -f flag.
docker build -t <image name> . -f jugglr/Dockerfile //or other name you have given the Dockerfile
Run the image in a container:
docker run -d \
--name <container name> \
-p <port to run on>:5432 \ //port number can be anything on the left of the colon. Leave the 5432 after the colon
-e POSTGRES_PASSWORD=<postgres password> <image name>
Finally, load data from a file (keep the single and double quotes in the copy command below):
docker exec -it <container name> psql -U <database username> -d <databasename> -c "\copy <tablename> FROM '<path to csv file in the Docker Container>' DELIMITER ',' CSV HEADER;"