blob: 9712ae8ed44230a0bdef3a976f728e04cc02c882 [file] [log] [blame]
Joshua Heskethd78b4482015-09-14 16:56:34 -06001#!/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 Belangerca10f852017-07-11 15:58:40 -04008TOOLSDIR=$(dirname $0)
Joshua Heskethd78b4482015-09-14 16:56:34 -06009
Paul Belanger6a766dc2017-03-22 08:53:41 -040010# Be sure mysql and zookeeper are started.
11sudo service mysql start
12sudo service zookeeper start
13
Joshua Heskethd78b4482015-09-14 16:56:34 -060014# The root password for the MySQL database; pass it in via
15# MYSQL_ROOT_PW.
16DB_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.
20DB_USER=openstack_citest
21DB_PW=openstack_citest
22
23sudo -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.
28sudo -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.
35mysql -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 Belanger29896722017-05-02 12:47:49 -040039
40# TODO(pabelanger): Move this into bindep after we figure out how to enable our
41# PPA.
Paul Belangerca10f852017-07-11 15:58:40 -040042# NOTE(pabelanger): Avoid hitting http://keyserver.ubuntu.com
43sudo apt-key add $TOOLSDIR/018D05F5.gpg
44LSBDISTCODENAME=$(lsb_release -cs)
45echo "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 Belanger29896722017-05-02 12:47:49 -040047sudo apt-get update
48sudo apt-get --assume-yes install bubblewrap