zaqar/tools/test-setup.sh
Fei Long Wang 1ddd9ca5c0 Fix sqlalchemy migration
1. Fix the case of table names
2. Fix the sqlalchemy migration tests

NOTE: The sqlalchemy migrations test depends on oslo_db's migration
test which requires mysql user 'openstack_citest' with password
'openstack_citest' otherwise the test will be skipped.

Closes-Bug: #1654105

Change-Id: Ia672440a948fa4784f6dd1aa6d5fed0bc3915663
2017-02-02 20:20:29 +13:00

33 lines
1.2 KiB
Bash
Executable File

#!/bin/bash -xe
# This script will be run by OpenStack CI before unit tests are run,
# it sets up the test system as needed.
# Developers should setup their test systems in a similar way.
# This setup needs to be run as a user that can run sudo.
# The root password for the MySQL database; pass it in via
# MYSQL_ROOT_PW.
DB_ROOT_PW=${MYSQL_ROOT_PW:-insecure_slave}
# This user and its password are used by the tests, if you change it,
# your tests might fail.
DB_USER=openstack_citest
DB_PW=openstack_citest
sudo -H mysqladmin -u root password $DB_ROOT_PW
# It's best practice to remove anonymous users from the database. If
# a anonymous user exists, then it matches first for connections and
# other connections from that host will not work.
sudo -H mysql -u root -p$DB_ROOT_PW -h localhost -e "
DELETE FROM mysql.user WHERE User='';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.*
TO '$DB_USER'@'%' identified by '$DB_PW' WITH GRANT OPTION;"
# Now create our database.
mysql -u $DB_USER -p$DB_PW -h 127.0.0.1 -e "
SET default_storage_engine=MYISAM;
DROP DATABASE IF EXISTS openstack_citest;
CREATE DATABASE openstack_citest CHARACTER SET utf8;"