diff --git a/doc/source/devref/db_layer.rst b/doc/source/devref/db_layer.rst index bacd7731600..d0d7bd52105 100644 --- a/doc/source/devref/db_layer.rst +++ b/doc/source/devref/db_layer.rst @@ -2,10 +2,10 @@ Neutron Database Layer ====================== -Testing database and models sync --------------------------------- +Tests to verify that database migrations and models are in sync +--------------------------------------------------------------- -.. automodule:: neutron.tests.unit.db.test_migration +.. automodule:: neutron.tests.functional.db.test_migration .. autoclass:: _TestModelsMigrations :members: diff --git a/neutron/tests/contrib/gate_hook.sh b/neutron/tests/contrib/gate_hook.sh index 9b04233ac25..8409a3c3448 100644 --- a/neutron/tests/contrib/gate_hook.sh +++ b/neutron/tests/contrib/gate_hook.sh @@ -10,3 +10,42 @@ $BASE/new/devstack-gate/devstack-vm-gate.sh FUNC_FILTER=$BASE/new/neutron/neutron/tests/functional/contrib/filters.template sed -e "s+\$BASE_PATH+$BASE/new/neutron/.tox/dsvm-functional+" \ $FUNC_FILTER | sudo tee /etc/neutron/rootwrap.d/functional.filters > /dev/null + +# Use devstack functions to install mysql and psql servers +TOP_DIR=$BASE/new/devstack +source $TOP_DIR/functions +source $TOP_DIR/lib/config +source $TOP_DIR/stackrc +source $TOP_DIR/lib/database +source $TOP_DIR/localrc + +disable_service postgresql +enable_service mysql +initialize_database_backends +install_database + +disable_service mysql +enable_service postgresql +initialize_database_backends +install_database + +# Set up the 'openstack_citest' user and database in each backend +tmp_dir=`mktemp -d` + +cat << EOF > $tmp_dir/mysql.sql +CREATE DATABASE openstack_citest; +CREATE USER 'openstack_citest'@'localhost' IDENTIFIED BY 'openstack_citest'; +CREATE USER 'openstack_citest' IDENTIFIED BY 'openstack_citest'; +GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'@'localhost'; +GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'; +FLUSH PRIVILEGES; +EOF +/usr/bin/mysql -u root < $tmp_dir/mysql.sql + +cat << EOF > $tmp_dir/postgresql.sql +CREATE USER openstack_citest WITH CREATEDB LOGIN PASSWORD 'openstack_citest'; +CREATE DATABASE openstack_citest WITH OWNER openstack_citest; +EOF +# User/group postgres needs to be given access to tmp_dir +setfacl -m g:postgres:rwx $tmp_dir +sudo -u postgres /usr/bin/psql --file=$tmp_dir/postgresql.sql diff --git a/neutron/tests/unit/db/test_migration.py b/neutron/tests/functional/db/test_migrations.py similarity index 100% rename from neutron/tests/unit/db/test_migration.py rename to neutron/tests/functional/db/test_migrations.py diff --git a/neutron/tests/functional/requirements.txt b/neutron/tests/functional/requirements.txt new file mode 100644 index 00000000000..0c5f2215b44 --- /dev/null +++ b/neutron/tests/functional/requirements.txt @@ -0,0 +1,8 @@ +# Additional requirements for functional tests + +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. + +psycopg2 +MySQL-python diff --git a/test-requirements.txt b/test-requirements.txt index c46402904af..26cf54526a4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -17,6 +17,4 @@ testtools>=0.9.36,!=1.2.0 testscenarios>=0.4 WebTest>=2.0 oslotest>=1.2.0 # Apache-2.0 -psycopg2 -MySQL-python tempest-lib diff --git a/tox.ini b/tox.ini index 858999c09b8..301d453d041 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,9 @@ setenv = VIRTUAL_ENV={envdir} [testenv:functional] setenv = OS_TEST_PATH=./neutron/tests/functional OS_TEST_TIMEOUT=90 +deps = + {[testenv]deps} + -r{toxinidir}/neutron/tests/functional/requirements.txt [testenv:dsvm-functional] setenv = OS_TEST_PATH=./neutron/tests/functional @@ -35,6 +38,8 @@ setenv = OS_TEST_PATH=./neutron/tests/functional OS_FAIL_ON_MISSING_DEPS=1 OS_TEST_TIMEOUT=90 sitepackages=True +deps = + {[testenv:functional]deps} [tox:jenkins] sitepackages = True