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. |
Paul Belanger | ca10f85 | 2017-07-11 15:58:40 -0400 | [diff] [blame^] | 8 | TOOLSDIR=$(dirname $0) |
Joshua Hesketh | d78b448 | 2015-09-14 16:56:34 -0600 | [diff] [blame] | 9 | |
Paul Belanger | 6a766dc | 2017-03-22 08:53:41 -0400 | [diff] [blame] | 10 | # Be sure mysql and zookeeper are started. |
| 11 | sudo service mysql start |
| 12 | sudo service zookeeper start |
| 13 | |
Joshua Hesketh | d78b448 | 2015-09-14 16:56:34 -0600 | [diff] [blame] | 14 | # The root password for the MySQL database; pass it in via |
| 15 | # MYSQL_ROOT_PW. |
| 16 | DB_ROOT_PW=${MYSQL_ROOT_PW:-insecure_slave} |
| 17 | |
| 18 | # This user and its password are used by the tests, if you change it, |
| 19 | # your tests might fail. |
| 20 | DB_USER=openstack_citest |
| 21 | DB_PW=openstack_citest |
| 22 | |
| 23 | sudo -H mysqladmin -u root password $DB_ROOT_PW |
| 24 | |
| 25 | # It's best practice to remove anonymous users from the database. If |
| 26 | # a anonymous user exists, then it matches first for connections and |
| 27 | # other connections from that host will not work. |
| 28 | sudo -H mysql -u root -p$DB_ROOT_PW -h localhost -e " |
| 29 | DELETE FROM mysql.user WHERE User=''; |
| 30 | FLUSH PRIVILEGES; |
| 31 | GRANT ALL PRIVILEGES ON *.* |
| 32 | TO '$DB_USER'@'%' identified by '$DB_PW' WITH GRANT OPTION;" |
| 33 | |
| 34 | # Now create our database. |
| 35 | mysql -u $DB_USER -p$DB_PW -h 127.0.0.1 -e " |
| 36 | SET default_storage_engine=MYISAM; |
| 37 | DROP DATABASE IF EXISTS openstack_citest; |
| 38 | CREATE DATABASE openstack_citest CHARACTER SET utf8;" |
Paul Belanger | 2989672 | 2017-05-02 12:47:49 -0400 | [diff] [blame] | 39 | |
| 40 | # TODO(pabelanger): Move this into bindep after we figure out how to enable our |
| 41 | # PPA. |
Paul Belanger | ca10f85 | 2017-07-11 15:58:40 -0400 | [diff] [blame^] | 42 | # NOTE(pabelanger): Avoid hitting http://keyserver.ubuntu.com |
| 43 | sudo apt-key add $TOOLSDIR/018D05F5.gpg |
| 44 | LSBDISTCODENAME=$(lsb_release -cs) |
| 45 | echo "deb http://ppa.launchpad.net/openstack-ci-core/bubblewrap/ubuntu $LSBDISTCODENAME main" | \ |
| 46 | sudo tee /etc/apt/sources.list.d/openstack-ci-core-ubuntu-bubblewrap-xenial.list |
Paul Belanger | 2989672 | 2017-05-02 12:47:49 -0400 | [diff] [blame] | 47 | sudo apt-get update |
| 48 | sudo apt-get --assume-yes install bubblewrap |