Commit 69b74b3c authored by Daniele Venzano's avatar Daniele Venzano

Take out DB table creation to simplify testing

parent ba50b881
......@@ -3,18 +3,29 @@
ZOE_TEST_IMAGE=${ZOE_TEST_IMAGE:-zoe:manual}
DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker-registry:5000}
CI_BUILD_REF=${CI_BUILD_REF:-manual}
ZOE_COMMON_OPTIONS="--debug --backend-swarm-url http://localhost:2375 --deployment-name test${CI_BUILD_REF} --dbuser postgres --dbhost localhost --dbport 5432 --dbname postgres --dbpass postgres --master-url tcp://localhost:4850 --auth-type text --proxy-type none --listen-port 5100 --workspace-base-path /tmp"
if [ z${CI_BUILD_REF} != z"manual" ]; then
if [ z"${CI_BUILD_REF}" = z"manual" ]; then
echo "Start Postgres"
docker run --name postgres-${CI_BUILD_REF} -d -p 5432 postgres:9.3
docker run --name postgres-${CI_BUILD_REF} -d -p 5432:5432 postgres:9.3
sleep 5
fi
mkdir /tmp/test${CI_BUILD_REF}
python3 create_db_tables.py ${ZOE_COMMON_OPTIONS}
echo "Start Zoe API process"
python3 zoe-api.py --debug --backend-swarm-url http://localhost:2375 --deployment-name test${CI_BUILD_REF} --dbuser postgres --dbhost localhost --dbport 5432 --dbname postgres --dbpass postgres --master-url tcp://localhost:4850 --auth-type text --proxy-type none --listen-port 5100 --workspace-base-path /tmp --log-file /tmp/zoe-api-${CI_BUILD_REF}.log &
python3 zoe-api.py ${ZOE_COMMON_OPTIONS} --log-file /tmp/zoe-api-${CI_BUILD_REF}.log &
API_PID=$!
sleep 2
echo "Start Zoe Master process"
python3 zoe-master.py --debug --backend-swarm-url http://172.17.0.1:2375 --deployment-name test${CI_BUILD_REF} --dbuser postgres --dbhost postgres-${CI_BUILD_REF} --dbport 5432 --dbname postgres --dbpass postgres --auth-type text --proxy-type none --workspace-base-path /tmp --log-file /tmp/zoe-master-${CI_BUILD_REF}.log &
python3 zoe-master.py ${ZOE_COMMON_OPTIONS} --log-file /tmp/zoe-master-${CI_BUILD_REF}.log &
MASTER_PID=$!
sleep 2
cd tests
coverage run basic_auth_success_test.py localhost:5100
......@@ -23,12 +34,17 @@ cd ..
echo "<============== MASTER LOGS ======================>"
cat /tmp/zoe-master-${CI_BUILD_REF}.log
rm -f /tmp/zoe-master-${CI_BUILD_REF}.log
echo "<================ API LOGS =======================>"
cat /tmp/zoe-api-${CI_BUILD_REF}.log
rm -f /tmp/zoe-api-${CI_BUILD_REF}.log
kill ${API_PID} ${MASTER_PID}
rm -Rf /tmp/test${CI_BUILD_REF}
if [ z${CI_BUILD_REF} != z"manual" ]; then
if [ z"${CI_BUILD_REF}" = z"manual" ]; then
echo "Stop Postgres"
docker rm -f postgres-${CI_BUILD_REF}
fi
import zoe_lib.config as config
import zoe_api.db_init
config.load_configuration()
zoe_api.db_init.init()
......@@ -99,6 +99,7 @@ def create_tables(cur):
user_id TEXT
)''')
def init():
"""DB init entrypoint."""
dsn = 'dbname=' + get_conf().dbname + \
......
......@@ -55,6 +55,7 @@ def main():
}
if args.log_file != "stderr":
log_args['filename'] = args.log_file
logging.basicConfig(**log_args)
ret = _check_configuration_sanity()
if ret != 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment