Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

usgs/time-series-services

Repository files navigation

This project has been moved to GitLab. It is still under active development, but that development nolonger happens here.

Water Data for the Nation

Codacy Badge Build Status codecov

Water Data for the Nation Observations service.

Development

This is a Spring Boot project. All of the normal caveats relating to a Spring Boot application apply.

Environment Variables

To run in a development environment, create an application.yml file in the project root directory containing the following (shown are example values):

ROOT_LOG_LEVEL: "INFO"
SERVER_PORT: "8080"
SERVER_CONTEXT_PATH: "/api/observations"
SITE_URL_BASE: "http://localhost:8080/api/observations/"
MONLOC_CONTACT_NAME: "First Last"
MONLOC_CONTACT_EMAIL: "changeMe"
WDFN_DATABASE_ADDRESS: "localhost"
WDFN_DATABASE_PORT: "5432"
WDFN_DATABASE_NAME: "wdfn_db"
WDFN_DB_READ_ONLY_USERNAME: "wdfn_user"
WDFN_DB_READ_ONLY_PASSWORD: "changeMe"
WDFN_SCHEMA_OWNER_USERNAME: "wdfn_owner"
WDFN_SCHEMA_OWNER_PASSWORD: "changeMe"

Running the Demo DB for local development

The short version:

docker network create --subnet=172.25.0.0/16 wdfn  (only needs to be run once)
docker run -it --network=wdfn -p 127.0.0.1:5437:5432/tcp usgswma/wqp_db:etl

The network and the port will need to match the values in the application.yml.

Unit Testing

To run the JUnit tests via Maven:

mvn package

Database Integration Testing

To additionally start up a Docker database and run the integration tests via Maven, use:

docker network create --subnet=172.25.0.0/16 wdfn  (only needs to be run once)
mvn verify -DTESTING_DATABASE_PORT=5437 -DTESTING_DATABASE_ADDRESS=localhost -DTESTING_DATABASE_NETWORK=wdfn

Note: If you configure your IDE to run integration tests, make sure the configuration is pointed at a local Docker db, not a cloud hosted db. Integration tests will delete/modify records in the db they are pointed at.

Maven DOCKER_HOST Error

If maven verify returns an error like this "... no DOCKER_HOST environment variable ..." then the user running mvn command has not been granted rights to the docker group.

The following commands will ensure the docker group exists and assign it to the current user.

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker