summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/hooks/README4
l---------[-rwxr-xr-x]tools/hooks/post_test_hook.sh22
-rwxr-xr-xtools/test-setup.sh54
-rw-r--r--tools/xenserver/destroy_cached_images.py2
4 files changed, 56 insertions, 26 deletions
diff --git a/tools/hooks/README b/tools/hooks/README
deleted file mode 100644
index b7df206546..0000000000
--- a/tools/hooks/README
+++ /dev/null
@@ -1,4 +0,0 @@
-These are hooks to be used by the OpenStack infra test system. These scripts
-may be called by certain jobs at important times to do extra testing, setup,
-etc. They are really only relevant within the scope of the OpenStack infra
-system and are not expected to be useful to anyone else.
diff --git a/tools/hooks/post_test_hook.sh b/tools/hooks/post_test_hook.sh
index 5f72eb378d..c659cde494 100755..120000
--- a/tools/hooks/post_test_hook.sh
+++ b/tools/hooks/post_test_hook.sh
@@ -1,21 +1 @@
-#!/bin/bash -x
-
-MANAGE="/usr/local/bin/nova-manage"
-
-function archive_deleted_rows {
- # NOTE(danms): Run this a few times to make sure that we end
- # up with nothing more to archive
- for i in `seq 30`; do
- $MANAGE db archive_deleted_rows --verbose --max_rows 1000
- RET=$?
- if [[ $RET -gt 1 ]]; then
- echo Archiving failed with result $RET
- return $RET
- elif [[ $RET -eq 0 ]]; then
- echo Archiving Complete
- break;
- fi
- done
-}
-
-archive_deleted_rows
+../../gate/post_test_hook.sh \ No newline at end of file
diff --git a/tools/test-setup.sh b/tools/test-setup.sh
new file mode 100755
index 0000000000..00c765e734
--- /dev/null
+++ b/tools/test-setup.sh
@@ -0,0 +1,54 @@
+#!/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
+# an 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;"
+
+# Same for PostgreSQL
+
+# Setup user
+root_roles=$(sudo -H -u postgres psql -t -c "
+ SELECT 'HERE' from pg_roles where rolname='$DB_USER'")
+if [[ ${root_roles} == *HERE ]];then
+ sudo -H -u postgres psql -c "ALTER ROLE $DB_USER WITH SUPERUSER LOGIN PASSWORD '$DB_PW'"
+else
+ sudo -H -u postgres psql -c "CREATE ROLE $DB_USER WITH SUPERUSER LOGIN PASSWORD '$DB_PW'"
+fi
+
+# Store password for tests
+cat << EOF > $HOME/.pgpass
+*:*:*:$DB_USER:$DB_PW
+EOF
+chmod 0600 $HOME/.pgpass
+
+# Now create our database
+psql -h 127.0.0.1 -U $DB_USER -d template1 -c "DROP DATABASE IF EXISTS openstack_citest"
+createdb -h 127.0.0.1 -U $DB_USER -l C -T template0 -E utf8 openstack_citest
diff --git a/tools/xenserver/destroy_cached_images.py b/tools/xenserver/destroy_cached_images.py
index a330231c46..1cf254788d 100644
--- a/tools/xenserver/destroy_cached_images.py
+++ b/tools/xenserver/destroy_cached_images.py
@@ -28,6 +28,7 @@ eventlet.monkey_patch()
import os
import sys
+from os_xenapi.client import session
from oslo_config import cfg
# If ../nova/__init__.py exists, add ../ to Python search path, so that
@@ -42,7 +43,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
import nova.conf
from nova import config
from nova import utils
-from nova.virt.xenapi.client import session
from nova.virt.xenapi import vm_utils
destroy_opts = [