Skip to content

Commit

Permalink
Add script for running tests in Docker container.
Browse files Browse the repository at this point in the history
  • Loading branch information
simpsonw committed May 31, 2019
1 parent f19fa4e commit 20d27ea
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
54 changes: 54 additions & 0 deletions run_tests_like_travis_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash


# BEWARE! This script:
# - Drops two databases
# - Deletes a user
# - Overwrites your variables.ini, local.py, secrets.py, etc.
# - Forcibly updates packages in your virtual environment
#
# Read it.

# Usage:
# 0. Start a bash session in your atmosphere docker container
# (docker exec -it <container_name> /bin/bash)
# 1. ./run_tests_like_travis.sh [cyverse|jetstream]

set -e
set -x

# Install pre-dependencies
apt-get update && apt-get install -y postgresql

DISTRIBUTION=${1:-cyverse}
VENV_PATH=/opt/env/atmo-test
ATMO_PATH=/opt/dev/atmosphere
SUDO_POSTGRES='' # Leave empty if sudo not required to run dropdb, createdb & psql
PIP_TOOLS_VERSION=1.9.0

cd $ATMO_PATH
if [ ! -d "$VENV_PATH" ]; then
virtualenv "$VENV_PATH";
fi
source $VENV_PATH/bin/activate

# pip install -U pip setuptools pip-tools=="$PIP_TOOLS_VERSION"
# pip-sync dev_requirements.txt
pip install -r dev_requirements.txt
echo "DROP DATABASE IF EXISTS atmosphere_db" | ./manage.py dbshell
echo "DROP DATABASE IF EXISTS test_atmosphere_db" | ./manage.py dbshell
echo "DROP USER IF EXISTS atmosphere_db_user" | ./manage.py dbshell
echo "CREATE USER atmosphere_db_user WITH PASSWORD 'atmosphere_db_pass' CREATEDB;" | ./manage.py dbshell
echo "CREATE DATABASE atmosphere_db WITH OWNER atmosphere_db_user;" | ./manage.py dbshell


mv ./variables.ini ./variables.ini.bak
cp ./variables.ini.dist ./variables.ini
patch variables.ini variables_for_testing_${DISTRIBUTION}_docker.ini.patch
./configure
# ./travis/check_properly_generated_requirements.sh

# python manage.py test --keepdb
rm -f rerun_failing.features
python manage.py behave --keepdb --tags ~@skip-if-${DISTRIBUTION}
mv ./variables.ini.bak ./variables.ini
23 changes: 23 additions & 0 deletions variables_for_testing_cyverse_docker.ini.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- variables.ini.dist 2019-05-31 21:38:20.029217819 +0000
+++ variables.ini 2019-05-31 21:45:15.413243671 +0000
@@ -40,7 +40,7 @@
DATABASE_ENGINE = django.db.backends.postgresql_psycopg2 # postgres only (for now)
DATABASE_USER = atmosphere_db_user # psql_user
DATABASE_PASSWORD = atmosphere_db_pass # psql_password
-DATABASE_HOST = localhost # remote.postgres-server.com
+DATABASE_HOST = postgres # remote.postgres-server.com
DATABASE_PORT = 5432
DATABASE_CONN_MAX_AGE = 60 # in seconds
DEBUG = True # Boolean required
@@ -58,7 +58,10 @@
LOGSTASH_PORT = # 8000
METRIC_SERVER = # atmosphere-metrics.server.com
SELF_SIGNED_CERT = False # Boolean required
-TESTING = False # Boolean required
+TESTING = True # Boolean required
+TEST_RUNNER_USER = # Nothing
+TEST_RUNNER_PASS = # Nothing
+DJANGO_JENKINS = False
#local.py - site configuration
AUTO_CREATE_NEW_ACCOUNTS = False # Boolean required
AUTO_CREATE_NEW_PROJECTS = False # Boolean required
29 changes: 29 additions & 0 deletions variables_for_testing_jetstream_docker.ini.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- variables.ini.dist 2019-05-31 20:42:48.909010495 +0000
+++ variables.ini 2019-05-31 21:30:15.025187633 +0000
@@ -40,7 +40,7 @@
DATABASE_ENGINE = django.db.backends.postgresql_psycopg2 # postgres only (for now)
DATABASE_USER = atmosphere_db_user # psql_user
DATABASE_PASSWORD = atmosphere_db_pass # psql_password
-DATABASE_HOST = localhost # remote.postgres-server.com
+DATABASE_HOST = postgres # remote.postgres-server.com
DATABASE_PORT = 5432
DATABASE_CONN_MAX_AGE = 60 # in seconds
DEBUG = True # Boolean required
@@ -58,12 +58,15 @@
LOGSTASH_PORT = # 8000
METRIC_SERVER = # atmosphere-metrics.server.com
SELF_SIGNED_CERT = False # Boolean required
-TESTING = False # Boolean required
+TESTING = True # Boolean required
+TEST_RUNNER_USER = # Nothing
+TEST_RUNNER_PASS = # Nothing
+DJANGO_JENKINS = False
#local.py - site configuration
AUTO_CREATE_NEW_ACCOUNTS = False # Boolean required
AUTO_CREATE_NEW_PROJECTS = False # Boolean required
ALLOCATION_SOURCE_COMPUTE_ALLOWED = 168 # Boolean required
-USE_JETSTREAM_PLUGIN = False # Boolean required
+USE_JETSTREAM_PLUGIN = True # Boolean required
TIME_ZONE = # America/Phoenix
SITE_NAME = # CyVerse
ORG_NAME = # CyVerse

0 comments on commit 20d27ea

Please sign in to comment.