Compile OVS for functional tests
The patch takes OVS with conntrack support, compiles it and loads its kernel modules. The patch steals parts from networking-ovn project [1]. To run compilation of OVS, an environment variable COMPILE_OVS must be set to True. Optional environment variables OVS_REPO and OVS_BRANCH can be defined as a source of bits. Once Neutron starts using neutron-lib, next steps will be taking content of devstack/lib/ovs and putting it into neutron-lib project in order to let other projects like networking-ovn to re-use the code. [1] https://github.com/openstack/networking-ovn/blob/master/devstack/plugin.sh#L175 Change-Id: Id2f51853a6339da72dbde7a82f94f99a4c306565
This commit is contained in:
parent
f01bdd161f
commit
00f7313162
@ -127,7 +127,10 @@ Functional tests (neutron/tests/functional/) are intended to
|
|||||||
validate actual system interaction. Mocks should be used sparingly,
|
validate actual system interaction. Mocks should be used sparingly,
|
||||||
if at all. Care should be taken to ensure that existing system
|
if at all. Care should be taken to ensure that existing system
|
||||||
resources are not modified and that resources created in tests are
|
resources are not modified and that resources created in tests are
|
||||||
properly cleaned up both on test success and failure.
|
properly cleaned up both on test success and failure. Note that when run
|
||||||
|
at the gate, the functional tests compile OVS from source. Check out
|
||||||
|
neutron/tests/contrib/gate_hook.sh. Other jobs presently use OVS from
|
||||||
|
packages.
|
||||||
|
|
||||||
Let's examine the benefits of the functional testing framework.
|
Let's examine the benefits of the functional testing framework.
|
||||||
Neutron offers a library called 'ip_lib' that wraps around the 'ip' binary.
|
Neutron offers a library called 'ip_lib' that wraps around the 'ip' binary.
|
||||||
|
93
devstack/lib/ovs
Normal file
93
devstack/lib/ovs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
OVS_REPO=${OVS_REPO:-https://github.com/openvswitch/ovs.git}
|
||||||
|
OVS_REPO_NAME=$(basename ${OVS_REPO} | cut -f1 -d'.')
|
||||||
|
OVS_BRANCH=${OVS_BRANCH:-origin/master}
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
|
||||||
|
# load_module() - Load module using modprobe module given by argument and dies
|
||||||
|
# on failure
|
||||||
|
# - fatal argument is optional and says whether function should
|
||||||
|
# exit if module can't be loaded
|
||||||
|
function load_module {
|
||||||
|
local module=$1
|
||||||
|
local fatal=$2
|
||||||
|
|
||||||
|
if [ "$(trueorfalse True fatal)" == "True" ]; then
|
||||||
|
sudo modprobe $module || (dmesg && die $LINENO "FAILED TO LOAD $module")
|
||||||
|
else
|
||||||
|
sudo modprobe $module || (echo "FAILED TO LOAD vport_geneve" && dmesg)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# compile_ovs() - Compile OVS from source and load needed modules.
|
||||||
|
# Accepts two parameters:
|
||||||
|
# - first one is True, modules are built and installed.
|
||||||
|
# - second optional parameter defines prefix for ovs compilation
|
||||||
|
# Env variables OVS_REPO_NAME, OVS_REPO and OVS_BRANCH must be set
|
||||||
|
function compile_ovs {
|
||||||
|
local _pwd=$PWD
|
||||||
|
local build_modules=${1:-True}
|
||||||
|
local prefix=$2
|
||||||
|
|
||||||
|
if [ -n $prefix ]; then
|
||||||
|
prefix="--prefix=$prefix"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $DEST
|
||||||
|
if [ ! -d $OVS_REPO_NAME ] ; then
|
||||||
|
git clone $OVS_REPO
|
||||||
|
cd $OVS_REPO_NAME
|
||||||
|
git checkout $OVS_BRANCH
|
||||||
|
else
|
||||||
|
cd $OVS_REPO_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Can you create package list files like you can inside devstack?
|
||||||
|
install_package autoconf automake libtool gcc patch make
|
||||||
|
|
||||||
|
if is_fedora ; then
|
||||||
|
# is_fedora covers Fedora, RHEL, CentOS, etc...
|
||||||
|
install_package kernel-devel
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f configure ] ; then
|
||||||
|
./boot.sh
|
||||||
|
fi
|
||||||
|
if [ ! -f config.status ] || [ configure -nt config.status ] ; then
|
||||||
|
if [[ "$build_modules" == "True" ]]; then
|
||||||
|
./configure $prefix --with-linux=/lib/modules/$(uname -r)/build
|
||||||
|
else
|
||||||
|
./configure $prefix
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
make -j$[$(nproc) + 1]
|
||||||
|
sudo make install
|
||||||
|
if [[ "$build_modules" == "True" ]]; then
|
||||||
|
sudo make INSTALL_MOD_DIR=kernel/net/openvswitch modules_install
|
||||||
|
sudo modprobe -r vport_geneve
|
||||||
|
sudo modprobe -r openvswitch
|
||||||
|
fi
|
||||||
|
load_module openvswitch
|
||||||
|
load_module vport-geneve False
|
||||||
|
dmesg | tail
|
||||||
|
|
||||||
|
cd $_pwd
|
||||||
|
}
|
||||||
|
|
||||||
|
# start_new_ovs() - removes old ovs database, creates a new one and starts ovs
|
||||||
|
function start_new_ovs () {
|
||||||
|
rm -f /etc/openvswitch/conf.db /etc/openvswitch/.conf.db~lock~
|
||||||
|
sudo /usr/share/openvswitch/scripts/ovs-ctl start
|
||||||
|
}
|
@ -16,12 +16,28 @@ then
|
|||||||
PROJECT_NAME=neutron
|
PROJECT_NAME=neutron
|
||||||
IS_GATE=True
|
IS_GATE=True
|
||||||
|
|
||||||
|
source $DEVSTACK_PATH/functions
|
||||||
|
source $NEUTRON_PATH/devstack/lib/ovs
|
||||||
|
|
||||||
source $NEUTRON_PATH/tools/configure_for_func_testing.sh
|
source $NEUTRON_PATH/tools/configure_for_func_testing.sh
|
||||||
|
|
||||||
|
configure_host_for_func_testing
|
||||||
|
|
||||||
|
if [[ "$VENV" =~ "dsvm-functional" ]]; then
|
||||||
|
# Build from current branch-2.5 commit (2016-01-15)
|
||||||
|
OVS_BRANCH=eedd0ef239301f68964313e93dfd7ec41fc7814c
|
||||||
|
for package in openvswitch openvswitch-switch openvswitch-common; do
|
||||||
|
if is_package_installed $package; then
|
||||||
|
uninstall_package $package
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
compile_ovs True /usr
|
||||||
|
start_new_ovs
|
||||||
|
fi
|
||||||
|
|
||||||
# Make the workspace owned by the stack user
|
# Make the workspace owned by the stack user
|
||||||
sudo chown -R $STACK_USER:$STACK_USER $BASE
|
sudo chown -R $STACK_USER:$STACK_USER $BASE
|
||||||
|
|
||||||
configure_host_for_func_testing
|
|
||||||
elif [ "$VENV" == "api" -o "$VENV" == "api-pecan" -o "$VENV" == "full-pecan" ]
|
elif [ "$VENV" == "api" -o "$VENV" == "api-pecan" -o "$VENV" == "full-pecan" ]
|
||||||
then
|
then
|
||||||
cat > $DEVSTACK_PATH/local.conf <<EOF
|
cat > $DEVSTACK_PATH/local.conf <<EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user