Joshua Hesketh | d78b448 | 2015-09-14 16:56:34 -0600 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
| 3 | # This script will be run by OpenStack CI before unit tests are run, |
| 4 | # it sets up the test system as needed. |
| 5 | # Developers should setup their test systems in a similar way. |
| 6 | |
| 7 | # This setup needs to be run as a user that can run sudo. |
| 8 | |
Paul Belanger | 6a766dc | 2017-03-22 08:53:41 -0400 | [diff] [blame] | 9 | # Be sure mysql and zookeeper are started. |
| 10 | sudo service mysql start |
| 11 | sudo service zookeeper start |
| 12 | |
Joshua Hesketh | d78b448 | 2015-09-14 16:56:34 -0600 | [diff] [blame] | 13 | # The root password for the MySQL database; pass it in via |
| 14 | # MYSQL_ROOT_PW. |
| 15 | DB_ROOT_PW=${MYSQL_ROOT_PW:-insecure_slave} |
| 16 | |
| 17 | # This user and its password are used by the tests, if you change it, |
| 18 | # your tests might fail. |
| 19 | DB_USER=openstack_citest |
| 20 | DB_PW=openstack_citest |
| 21 | |
| 22 | sudo -H mysqladmin -u root password $DB_ROOT_PW |
| 23 | |
| 24 | # It's best practice to remove anonymous users from the database. If |
| 25 | # a anonymous user exists, then it matches first for connections and |
| 26 | # other connections from that host will not work. |
| 27 | sudo -H mysql -u root -p$DB_ROOT_PW -h localhost -e " |
| 28 | DELETE FROM mysql.user WHERE User=''; |
| 29 | FLUSH PRIVILEGES; |
| 30 | GRANT ALL PRIVILEGES ON *.* |
| 31 | TO '$DB_USER'@'%' identified by '$DB_PW' WITH GRANT OPTION;" |
| 32 | |
| 33 | # Now create our database. |
| 34 | mysql -u $DB_USER -p$DB_PW -h 127.0.0.1 -e " |
| 35 | SET default_storage_engine=MYISAM; |
| 36 | DROP DATABASE IF EXISTS openstack_citest; |
| 37 | CREATE DATABASE openstack_citest CHARACTER SET utf8;" |