diff --git a/README.rst b/README.rst index 43d0c5fc4..b7c00a9f1 100644 --- a/README.rst +++ b/README.rst @@ -41,6 +41,7 @@ If the cloud being used has no default_floating_pool defined in nova.conf, you will need to define a pool name using the nodepool yaml file to use floating ips. + Set up database for interactive testing: .. code-block:: bash @@ -60,6 +61,9 @@ Set up database for unit tests: mysql> flush privileges; mysql> create database openstack_citest; +Note that the script tools/test-setup.sh can be used for the step +above. + Export variable for your ssh key so you can log into the created instances: .. code-block:: bash diff --git a/tools/test-setup.sh b/tools/test-setup.sh new file mode 100755 index 000000000..f4a045869 --- /dev/null +++ b/tools/test-setup.sh @@ -0,0 +1,33 @@ +#!/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;"