Move DB TestModelsMigrations from unit to functional
The tests to check that DB migrations and models are in sync depends on the mysql and postgresql backends being available with a specific DB user and database created. This violates the principles for unit tests and therefore these tests should be moved to functional tests. For these tests to work in the functional job in the gate, the backends must be installed and the DB user and database created. We do this via the functional gate hook. Closes-bug: #1372981 Change-Id: I7b89feef3f19ca07dbfb05acfaa30529a5bf683d
This commit is contained in:
parent
5f95f67a0a
commit
3e0745827f
@ -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:
|
||||
|
@ -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
|
||||
|
8
neutron/tests/functional/requirements.txt
Normal file
8
neutron/tests/functional/requirements.txt
Normal file
@ -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
|
@ -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
|
||||
|
5
tox.ini
5
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
|
||||
|
Loading…
Reference in New Issue
Block a user