Add tools to run integration tests

According to spec in https://review.openstack.org/150743,
integration tests will be launched from the backend.
Add new install_test_backend.sh and destroy_test_backend.sh
scripts that will be called from each integration tests.
The workflow will be:

- install_test_backend
- run integration test
- destroy_test_backend

Change-Id: Ie676d3152cc4cd854ab6644e5fd281de9c2d70fd
This commit is contained in:
Yolanda Robla 2015-02-14 11:11:03 +01:00
parent 7abe1f3d24
commit 0b65cb4b02
3 changed files with 58 additions and 0 deletions

12
etc/storyboard.conf.test Normal file
View File

@ -0,0 +1,12 @@
[DEFAULT]
# Default log level is INFO
# verbose and debug has the same result.
# One of them will set DEBUG log level output
# debug = False
# verbose = False
# Where to store lock files
lock_path = $state_path/lock
[database]
connection = mysql+pymysql://#DB_USER#:#DB_PASSWORD#@127.0.0.1:3306/#DB_TEST#

12
tools/destroy_test_backend.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# This script cleans up the testing database and stops storyboard API
echo 'Killing storyboard-api...'
killall storyboard-api
# export default vars if not defined, to be available in conf file
export DB_USER=${DB_USER:-storyboard}
export DB_PASSWORD=${DB_PASSWORD:-storyboard}
export DB_TEST=${DB_TEST:-storyboard_test}
mysql -u $DB_USER -p$DB_PASSWORD -e "DROP DATABASE IF EXISTS $DB_TEST;"

34
tools/install_test_backend.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
if [ -f /usr/bin/apt-get ] ; then
export DEBIAN_FRONTEND=noninteractive
sudo apt-get install -y -q mysql-server libmysqlclient-dev python-dev
else
sudo yum install -y mysql-server mysql python-devel
fi
# export default vars if not defined, to be available in conf file
export DB_USER=${DB_USER:-storyboard}
export DB_PASSWORD=${DB_PASSWORD:-storyboard}
export DB_TEST=${DB_TEST:-storyboard_test}
# create the user if needed
if [ $CREATE_USER ]; then
if [ $DB_ADMIN_PASSWORD ]; then
FLAG_PASS="-p$DB_ADMIN_PASSWORD"
else
FLAG_PASS=""
fi
mysql -u $DB_ADMIN_USER $FLAG_PASS -e "CREATE USER $DB_USER@'localhost' IDENTIFIED BY '$DB_PASSWORD';"
mysql -u $DB_ADMIN_USER $FLAG_PASS -e "GRANT ALL PRIVILEGES ON $DB_TEST.* TO $DB_USER@'localhost';"
mysql -u $DB_ADMIN_USER $FLAG_PASS -e "FLUSH PRIVILEGES;"
fi
# create the test database
mysql -u $DB_USER -p$DB_PASSWORD -e "DROP DATABASE IF EXISTS $DB_TEST;"
mysql -u $DB_USER -p$DB_PASSWORD -e "CREATE DATABASE $DB_TEST;"
# replace env vars
cd ${STORYBOARD_PATH:-storyboard}
sed -i -e "s/#DB_USER#/$DB_USER/g" -e "s/#DB_PASSWORD#/$DB_PASSWORD/g" -e "s/#DB_TEST#/$DB_TEST/g" ./etc/storyboard.conf.test
tox -e venv "storyboard-db-manage --config-file ./etc/storyboard.conf.test upgrade head"
tox -e venv "storyboard-api --config-file ./etc/storyboard.conf.test" &