Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Interop Image #79

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Ignoring volumes created by docker-compose
data/
interop-volumes/
influxdb/
22 changes: 21 additions & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,33 @@ services:
ipv4_address: 172.16.238.10

interop-server:
image: uavaustin/interop-server:2019.05
image: uavaustin/interop-server:2020.11
ports:
- '8080:80'
environment:
- DB_HOST=172.16.238.53
- DB_PORT=5432
volumes:
- ./interop-volumes/mount:/mount
- ./interop-volumes/logs/uwsgi:/var/log/uwsgi
- ./interop-volumes/var/www/media/objects:/var/www/media/objects
depends_on:
- interop-db
networks:
test_net:
ipv4_address: 172.16.238.11

interop-db:
image: postgres:12.3
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ./interop-volumes/var/lib.postgresql/data:/var/lib/postgresql/data
networks:
test_net:
ipv4_address: 172.16.238.53

telemetry:
image: uavaustin/telemetry
ports:
Expand Down
116 changes: 116 additions & 0 deletions test/scripts/interop-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env bash
# Utility scripts taken from auvsi-suas/interop

SERVER=$(dirname ${BASH_SOURCE[0]})
REPO=${SERVER}/..

# Quit on any error.
set -e

# Run commands from context of server directory.
cd $SERVER

# Creates the database and loads test data. Only needs to be done once.
# Groups together "create_db" and "load_test_data"
if ["$1" == create_load]
then
docker-compose run interop-server ./healthcheck.py --postgres_host interop-db --check_postgres
docker-compose run interop-server psql "postgresql://postgres:postgres@interop-db" -c "CREATE DATABASE auvsi_suas_db;"
docker-compose run interop-server ./manage.py migrate

docker-compose run interop-server ./healthcheck.py --postgres_host interop-db --check_postgres
docker-compose run interop-server ./config/load_test_data.py
fi
# Checks the health of everything.
if [ "$1" == "healthcheck" ]
then
docker-compose run interop-server ./healthcheck.py --postgres_host interop-db --check_postgres --check_homepage
fi

# Creates the database. Only needs to be done once.
if [ "$1" == "create_db" ]
then
docker-compose run interop-server ./healthcheck.py --postgres_host interop-db --check_postgres
docker-compose run interop-server psql "postgresql://postgres:postgres@interop-db" -c "CREATE DATABASE auvsi_suas_db;"
docker-compose run interop-server ./manage.py migrate
fi

# Drops the database. Dangerous!
if [ "$1" == "drop_db" ]
then
docker-compose run interop-server ./healthcheck.py --postgres_host interop-db --check_postgres
docker-compose run interop-server psql "postgresql://postgres:postgres@interop-db" -c "DROP DATABASE auvsi_suas_db;"
fi

# Loads test data. Optional, only needs to be done once.
if [ "$1" == "load_test_data" ]
then
docker-compose run interop-server ./healthcheck.py --postgres_host interop-db --check_postgres
docker-compose run interop-server ./config/load_test_data.py
fi

# Runs the interop system. Stops on Ctrl-C.
if [ "$1" == "up" ]
then
docker-compose up
fi

# Runs the interop system detached. Stops on 'down'.
if [ "$1" == "up_d" ]
then
docker-compose up -d
docker-compose exec interop-server ./healthcheck.py --postgres_host interop-db --check_postgres --check_homepage
fi

# Stops the interop system previously started.
if [ "$1" == "down" ]
then
docker-compose down
fi

# Gets a bash shell inside the server.
if [ "$1" == "shell" ]
then
docker-compose exec interop-server bash
fi

# Upgrades the interop system.
if [ "$1" == "upgrade" ]
then
docker-compose rm -v
docker-compose pull
docker-compose run interop-server ./manage.py migrate
fi

# Removes the container images and anonymous volumes.
if [ "$1" == "rm_data" ]
then
docker-compose rm -v
rm -rf volumes
fi

# Interop developer only. Teams need not run these.

# Pulls new images.
if [ "$1" == "pull" ]
then
docker-compose pull
fi

# Builds container images.
if [ "$1" == "build" ]
then
docker-compose build --pull
fi

# Migrates the database.
if [ "$1" == "migrate" ]
then
docker-compose run interop-server ./manage.py migrate
fi

# Tests the system.
if [ "$1" == "test" ]
then
docker-compose run interop-server ./manage.py test --parallel
fi