/Jugglr

Jugglr is a test data management tool that enables reliable testing with a Docker containerized database

Primary LanguageTypeScriptMIT LicenseMIT

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.

The first time you build an image, it may take some time as Docker needs to download the Postgres image from DockerHub. After that, the Postgres image will be stored locally and image creation should take no more than a second or two.

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;"

How to Contribute:

Jugglr is an open source product and we encourage other developers to make improvements to the application. If you would like to contribute to Jugglr, head over to the dev branch, fork it, pull down the code, and create your own feature branch in the format name/feature. Run 'npm install', 'npm run build', and 'npm start' to see the app at it's current state. Once you've made your changes, push it back up to your feature branch and create a pull request into the original dev branch and the team will review your changes.

Enhancements:

Ideas for enhancements:

  • Add support for MongoDB and other popular databases
  • Maintain more than one Dockerfile so users can load data to different databases for different projects without having to switch out the Dockerfile each time (Maybe consider using a .yml file)
  • Render Docker commands directly in the app to pass on to the CI/CD team