Add tools/test-setup.sh
Add simple script to setup mysql database, this script can be run by users during testing and will be run by CI systems for specific setup before running unit tests. Update README.rst for this. Change-Id: I9af7c7d09b40c103af09ae8dd0e50afe3762ecba
This commit is contained in:
parent
6430d96ec3
commit
add601d073
@ -60,6 +60,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
|
||||
|
33
tools/test-setup.sh
Executable file
33
tools/test-setup.sh
Executable file
@ -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;"
|
Loading…
x
Reference in New Issue
Block a user