Make ovndir configurable

Change tools/setup-ovs.sh to take an OVS_BRANCH env
variable to use a specific branch.

Also, make OvsOvnVenvFixture work with an ovndir before
or after OVN repository split.

Change-Id: I9994c6e914bdb1deb5952c193e521f83ad74363d
Closes-Bug: 1856676
Signed-off-by: Flavio Fernandes <flaviof@redhat.com>
This commit is contained in:
Flavio Fernandes 2019-12-17 06:42:36 -05:00
parent b22a6a09fb
commit 5d70d45f2d
3 changed files with 25 additions and 6 deletions

View File

@ -133,14 +133,23 @@ class OvsVenvFixture(fixtures.Fixture):
class OvsOvnVenvFixture(OvsVenvFixture):
def __init__(self, *args, **kwargs):
install_share_path = self._get_install_share_path()
self.add_chassis = kwargs.pop('add_chassis', False)
self.ovndir = kwargs.pop('ovndir', const.OVN_INSTALL_SHARE_PATH)
self.ovndir = kwargs.pop('ovndir',
install_share_path) or install_share_path
self.PATH_VAR_TEMPLATE += (
":{0}/controller:{0}/northd:{0}/utilities".format(
self.ovndir))
super(OvsOvnVenvFixture, self).__init__(*args, **kwargs)
self.env.update({'OVN_RUNDIR': self.venv})
@staticmethod
def _get_install_share_path():
path = os.path.join(const.OVN_INSTALL_SHARE_PATH, 'ovn-nb.ovsschema')
if os.path.isfile(path):
return const.OVN_INSTALL_SHARE_PATH
return const.OVS_INSTALL_SHARE_PATH
@property
def ovnsb_schema(self):
path = os.path.join(self.ovsdir, 'ovn', 'ovn-sb.ovsschema')

View File

@ -1,17 +1,25 @@
#!/bin/bash -xe
OVS_BRANCH=${OVS_BRANCH:-master}
OVN_BRANCH=${OVN_BRANCH:-$OVS_BRANCH}
function use_new_ovn_repository {
# If OVN_BRANCH > branch-2.12 return 0
return $(! printf "%s\n%s" $OVN_BRANCH branch-2.12 | sort -C -V)
}
# We require at least OVS 2.7. Testing infrastructure doesn't support it yet,
# so build it. Eventually, we should run some checks to see what is actually
# installed and see if we can use it instead.
if [ "$OVS_SRCDIR" -a ! -d "$OVS_SRCDIR" ]; then
echo "Building OVS in $OVS_SRCDIR"
echo "Building OVS branch $OVS_BRANCH in $OVS_SRCDIR"
mkdir -p $OVS_SRCDIR
git clone git://github.com/openvswitch/ovs.git $OVS_SRCDIR
(cd $OVS_SRCDIR && ./boot.sh && PYTHON=/usr/bin/python ./configure && make -j$(($(nproc) + 1)))
(cd $OVS_SRCDIR && git checkout $OVS_BRANCH && ./boot.sh && PYTHON=/usr/bin/python ./configure && make -j$(($(nproc) + 1)))
fi
if [ "$OVN_SRCDIR" -a ! -d "$OVN_SRCDIR" ]; then
echo "Building OVN in $OVN_SRCDIR"
if use_new_ovn_repository && [ "$OVN_SRCDIR" -a ! -d "$OVN_SRCDIR" ]; then
echo "Building OVN branch $OVN_BRANCH in $OVN_SRCDIR"
mkdir -p $OVN_SRCDIR
git clone git://github.com/ovn-org/ovn.git $OVN_SRCDIR
(cd $OVN_SRCDIR && ./boot.sh && PYTHON=/usr/bin/python ./configure --with-ovs-source=$OVS_SRCDIR && make -j$(($(nproc) + 1)))
(cd $OVN_SRCDIR && git checkout $OVN_BRANCH && ./boot.sh && PYTHON=/usr/bin/python ./configure --with-ovs-source=$OVS_SRCDIR && make -j$(($(nproc) + 1)))
fi

View File

@ -55,6 +55,8 @@ setenv = {[testenv]setenv}
OS_TEST_PATH=./ovsdbapp/tests/functional
OVS_SRCDIR={envdir}/src/ovs
OVN_SRCDIR={envdir}/src/ovn
OVS_BRANCH={env:OVS_BRANCH:}
OVN_BRANCH={env:OVN_BRANCH:}
passenv = KEEP_VENV
commands =
{toxinidir}/tools/setup-ovs.sh