Set up hooks for the functional job and add test_migrations test

Add gate hooks for the dsvm-functional job including set-up of
configure_for_lbaas_func_testing.sh script and corresponding changes to
tox.ini.

PyMySQL dependency was moved from test_requirements.txt to
functional/requirements.txt.

test_migrations.py was moved from unit tests to functional in
order to prevent it from being skipped in case of db backend
unavailability.

Fixed failing TestModelsMigrations test by importing modules with
missing models in db/models/head.py

Closes-Bug: #1585116
Closes-Bug: #1596984
Change-Id: Ic39805ea0ed330ef7da82043f77077e8a5617ca0
This commit is contained in:
Elena Ezhova 2016-05-25 16:42:09 +03:00 committed by Brandon Logan
parent b322615e48
commit 2317364c31
11 changed files with 159 additions and 43 deletions

View File

@ -28,9 +28,6 @@ function neutron_lbaas_configure_common {
die $LINENO "Do not enable both Version 1 and Version 2 of LBaaS."
fi
# Uses oslo config generator to generate LBaaS sample configuration files
(cd $NEUTRON_LBAAS_DIR && exec ./tools/generate_config_file_samples.sh)
cp $NEUTRON_LBAAS_DIR/etc/neutron_lbaas.conf.sample $NEUTRON_LBAAS_CONF
if is_service_enabled $LBAAS_V1; then
@ -69,21 +66,29 @@ function neutron_lbaas_configure_common {
}
function neutron_lbaas_configure_agent {
mkdir -p $LBAAS_AGENT_CONF_PATH
cp $NEUTRON_LBAAS_DIR/etc/lbaas_agent.ini.sample $LBAAS_AGENT_CONF_FILENAME
if [ -z "$1" ]; then
mkdir -p $LBAAS_AGENT_CONF_PATH
fi
conf=${1:-$LBAAS_AGENT_CONF_FILENAME}
cp $NEUTRON_LBAAS_DIR/etc/lbaas_agent.ini.sample $conf
# ovs_use_veth needs to be set before the plugin configuration
# occurs to allow plugins to override the setting.
iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT ovs_use_veth $Q_OVS_USE_VETH
iniset $conf DEFAULT ovs_use_veth $Q_OVS_USE_VETH
neutron_plugin_setup_interface_driver $LBAAS_AGENT_CONF_FILENAME
neutron_plugin_setup_interface_driver $conf
if is_fedora; then
iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT user_group "nobody"
iniset $LBAAS_AGENT_CONF_FILENAME haproxy user_group "nobody"
iniset $conf DEFAULT user_group "nobody"
iniset $conf haproxy user_group "nobody"
fi
}
function neutron_lbaas_generate_config_files {
# Uses oslo config generator to generate LBaaS sample configuration files
(cd $NEUTRON_LBAAS_DIR && exec ./tools/generate_config_file_samples.sh)
}
function neutron_lbaas_start {
local is_run_process=True
@ -134,6 +139,7 @@ if is_service_enabled $LBAAS_ANY; then
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Configure after the other layer 1 and 2 services have been configured
echo_summary "Configuring neutron-lbaas"
neutron_lbaas_generate_config_files
neutron_lbaas_configure_common
neutron_lbaas_configure_agent

View File

@ -14,8 +14,11 @@
from neutron.db.migration.models import head
import neutron_lbaas.agent_scheduler # noqa
import neutron_lbaas.db.loadbalancer.loadbalancer_db # noqa
import neutron_lbaas.db.loadbalancer.models # noqa
import neutron_lbaas.services.loadbalancer.agent_scheduler # noqa
import neutron_lbaas.services.loadbalancer.drivers.vmware.models # noqa
def get_metadata():

View File

@ -27,32 +27,39 @@
testtype="$1"
lbaasversion="$2"
lbaastest="$3"
lbaasenv=$(echo "$lbaastest" | perl -ne '/^(.*)-([^-]+)$/ && print "$1";')
if [ -z "$lbaasenv" ]; then
lbaasenv=$lbaastest
fi
lbaasdriver=$(echo "$lbaastest" | perl -ne '/^(.*)-([^-]+)$/ && print "$2";')
if [ -z "$lbaasdriver" ]; then
lbaasdriver='octavia'
fi
testenv=${lbaastest:-"apiv2"}
case $testtype in
"dsvm-functional")
testenv=$testtype
;;
if [ "$lbaasversion" = "lbaasv1" ]; then
testenv="apiv1"
elif [ "$lbaasversion" = "lbaasv2" ]; then
case "$lbaasenv" in
"api"|"healthmonitor"|"listener"|"loadbalancer"|"member"|"minimal"|"pool")
testenv="apiv2"
;;
"scenario")
testenv="scenario"
;;
*)
echo "Unrecognized env $lbaasenv".
exit 1
;;
esac
fi
"tempest")
lbaasenv=$(echo "$lbaastest" | perl -ne '/^(.*)-([^-]+)$/ && print "$1";')
if [ -z "$lbaasenv" ]; then
lbaasenv=$lbaastest
fi
lbaasdriver=$(echo "$lbaastest" | perl -ne '/^(.*)-([^-]+)$/ && print "$2";')
if [ -z "$lbaasdriver" ]; then
lbaasdriver='octavia'
fi
testenv=${lbaastest:-"apiv2"}
if [ "$lbaasversion" = "lbaasv1" ]; then
testenv="apiv1"
elif [ "$lbaasversion" = "lbaasv2" ]; then
case "$lbaasenv" in
"api"|"healthmonitor"|"listener"|"loadbalancer"|"member"|"minimal"|"pool")
testenv="apiv2"
;;
"scenario")
testenv="scenario"
;;
*)
echo "Unrecognized env $lbaasenv".
exit 1
;;
esac
fi
;;
esac

View File

@ -50,6 +50,21 @@ EOF
case "$testtype" in
"dsvm-functional")
PROJECT_NAME=neutron-lbaas
NEUTRON_LBAAS_PATH=$GATE_DEST/$PROJECT_NAME
DEVSTACK_PATH=$GATE_DEST/devstack
IS_GATE=True
USE_CONSTRAINT_ENV=False
export LOG_COLOR=False
source "$NEUTRON_LBAAS_PATH"/tools/configure_for_lbaas_func_testing.sh
# Make the workspace owned by the stack user
sudo chown -R "$STACK_USER":"$STACK_USER" "$BASE"
configure_host_for_lbaas_func_testing
;;
"tempest")
# These are not needed with either v1 or v2
ENABLED_SERVICES+="-c-api,-c-bak,-c-sch,-c-vol,-cinder,"
@ -83,6 +98,7 @@ case "$testtype" in
fi
export ENABLED_SERVICES
"$GATE_DEST"/devstack-gate/devstack-vm-gate.sh
;;
*)
@ -90,6 +106,3 @@ case "$testtype" in
exit 1
;;
esac
"$GATE_DEST"/devstack-gate/devstack-vm-gate.sh

View File

@ -48,7 +48,7 @@ function generate_testr_results {
sudo -H -u "$owner" chmod o+rw .
sudo -H -u "$owner" chmod o+rw -R .testrepository
if [ -f ".testrepository/0" ] ; then
subunit-1to2 < .testrepository/0 > ./testrepository.subunit
.tox/"$testenv"/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit
$SCRIPTS_DIR/subunit2html ./testrepository.subunit testr_results.html
gzip -9 ./testrepository.subunit
gzip -9 ./testr_results.html
@ -56,9 +56,17 @@ function generate_testr_results {
fi
}
owner=tempest
# Configure the api and scenario tests to use the tempest.conf set by devstack
sudo_env="TEMPEST_CONFIG_DIR=$TEMPEST_CONFIG_DIR"
case $testtype in
"dsvm-functional")
owner=stack
sudo_env=
;;
"tempest")
owner=tempest
# Configure the api and scenario tests to use the tempest.conf set by devstack
sudo_env="TEMPEST_CONFIG_DIR=$TEMPEST_CONFIG_DIR"
;;
esac
# Set owner permissions according to job's requirements.
cd "$NEUTRON_LBAAS_DIR"

View File

@ -0,0 +1,9 @@
# 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.
psutil>=1.1.1,<2.0.0
psycopg2
PyMySQL>=0.6.2 # MIT License

View File

@ -19,6 +19,4 @@ testscenarios>=0.4 # Apache-2.0/BSD
WebOb>=1.2.3 # MIT
WebTest>=2.0 # MIT
reno>=1.8.0 # Apache2
# Needed to run DB commands in virtualenvs
PyMySQL>=0.6.2 # MIT License
tempest>=12.1.0 # Apache-2.0

View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
IS_GATE=${IS_GATE:-False}
USE_CONSTRAINT_ENV=${USE_CONSTRAINT_ENV:-False}
PROJECT_NAME=${PROJECT_NAME:-neutron-lbaas}
REPO_BASE=${GATE_DEST:-$(cd $(dirname "$BASH_SOURCE")/../.. && pwd)}
source $REPO_BASE/neutron/tools/configure_for_func_testing.sh
function configure_host_for_lbaas_func_testing {
echo_summary "Configuring for LBaaS functional testing"
if [ "$IS_GATE" == "True" ]; then
configure_host_for_func_testing
fi
source $REPO_BASE/neutron-lbaas/devstack/settings
source $NEUTRON_LBAAS_DIR/devstack/plugin.sh
local temp_ini=$(mktemp)
# Note(pc_m): Need to ensure this is installed so we have
# oslo-config-generator present (as this script runs before tox.ini).
sudo pip install --force oslo.config
neutron_lbaas_generate_config_files
neutron_agent_lbaas_install_agent_packages
neutron_lbaas_configure_agent $temp_ini
sudo install -d -o $STACK_USER $LBAAS_AGENT_CONF_PATH
sudo install -m 644 -o $STACK_USER $temp_ini $LBAAS_AGENT_CONF_FILENAME
}
if [ "$IS_GATE" != "True" ]; then
configure_host_for_lbaas_func_testing
fi

21
tox.ini
View File

@ -63,6 +63,27 @@ exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,ra
import_exceptions = neutron_lbaas._i18n
local-check-factory = neutron_lib.hacking.checks.factory
[testenv:functional]
basepython = python2.7
setenv = {[testenv]setenv}
OS_TEST_PATH={toxinidir}/neutron_lbaas/tests/functional
OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}
deps =
{[testenv]deps}
-r{toxinidir}/neutron_lbaas/tests/functional/requirements.txt
[testenv:dsvm-functional]
setenv = {[testenv]setenv}
{[testenv:functional]setenv}
OS_SUDO_TESTING=1
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
OS_FAIL_ON_MISSING_DEPS=1
deps =
{[testenv:functional]deps}
commands =
sh tools/pretty_tox.sh '{posargs}'
# If you are running the tests locally you should set the env variable
# TEMPEST_CONFIG_DIR=/opt/stack/tempest/etc
[testenv:apiv1]