functional: Introduce a base class for OVN func testing
The patch creates a base classes that inherit from the ovsdbapp project. A new API fixture is added to be able to use OVN BGP agent OVN IDL in the functional tests. Change-Id: I139d6798a1ed2f51d447c86f16dad2aa3892412b Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
This commit is contained in:
parent
8a7ebde363
commit
a01dddcefa
10
bindep.txt
Normal file
10
bindep.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# This file contains runtime (non-python) dependencies
|
||||
# More info at: http://docs.openstack.org/infra/bindep/readme.html
|
||||
|
||||
openvswitch [platform:rpm test]
|
||||
openvswitch-switch [platform:dpkg test]
|
||||
autoconf [test]
|
||||
automake [test]
|
||||
libtool [test]
|
||||
gcc [test]
|
||||
make [test]
|
@ -24,9 +24,11 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import fileutils
|
||||
from oslotest import base
|
||||
from ovsdbapp.tests.functional import base as ovsdbapp_base
|
||||
|
||||
import ovn_bgp_agent
|
||||
from ovn_bgp_agent import config
|
||||
from ovn_bgp_agent.tests.functional import fixtures
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -119,3 +121,11 @@ class BaseFunctionalTestCase(base.BaseTestCase,
|
||||
group = kw.pop('group', None)
|
||||
for k, v in kw.items():
|
||||
CONF.set_override(k, v, group)
|
||||
|
||||
|
||||
class BaseFunctionalNorthboundTestCase(ovsdbapp_base.FunctionalTestCase):
|
||||
schemas = ['OVN_Northbound']
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.api = self.useFixture(fixtures.NbApiFixture(self.connection)).obj
|
||||
|
0
ovn_bgp_agent/tests/functional/drivers/__init__.py
Normal file
0
ovn_bgp_agent/tests/functional/drivers/__init__.py
Normal file
@ -0,0 +1,49 @@
|
||||
# Copyright 2024 Red Hat, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from ovn_bgp_agent import constants
|
||||
from ovn_bgp_agent.tests.functional import base
|
||||
|
||||
|
||||
class OvsdbNbOvnIdl(base.BaseFunctionalNorthboundTestCase):
|
||||
def _lsp_add(self, ls_name, lsp_name, type_, tag):
|
||||
self.api.lsp_add(ls_name, lsp_name, type=type_).execute(
|
||||
check_error=True)
|
||||
# lsp_add requires parent to be specified with the tag, work it
|
||||
# around with the db_set
|
||||
self.api.db_set(
|
||||
'Logical_Switch_Port', lsp_name, ('tag', tag)).execute(
|
||||
check_error=True)
|
||||
|
||||
def test_get_network_vlan_tags(self):
|
||||
# 0 is not a valid tag, let's start with 1
|
||||
expected_tags = list(range(1, 4))
|
||||
len_tags = len(expected_tags)
|
||||
|
||||
for i, tag in enumerate(expected_tags):
|
||||
self.api.ls_add('ls%d' % i).execute(check_error=True)
|
||||
ls_name = 'ls%d' % (i % 2)
|
||||
lsp_name = 'localnetport%d' % i
|
||||
self._lsp_add(
|
||||
ls_name, lsp_name,
|
||||
constants.OVN_LOCALNET_VIF_PORT_TYPE, tag=tag)
|
||||
for i, tag in enumerate(expected_tags):
|
||||
ls_name = 'ls%d' % i
|
||||
lsp_name = 'port%d' % i
|
||||
self._lsp_add(
|
||||
ls_name, lsp_name,
|
||||
type_=None, tag=i + len_tags)
|
||||
|
||||
tags = self.api.get_network_vlan_tags()
|
||||
self.assertCountEqual(expected_tags, tags)
|
21
ovn_bgp_agent/tests/functional/fixtures.py
Normal file
21
ovn_bgp_agent/tests/functional/fixtures.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright 2024 Red Hat, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from ovsdbapp.tests.functional.schema import fixtures
|
||||
|
||||
from ovn_bgp_agent.drivers.openstack.utils import ovn
|
||||
|
||||
|
||||
class NbApiFixture(fixtures.ApiImplFixture):
|
||||
api_cls = ovn.OvsdbNbOvnIdl
|
18
tools/setup-ovs.sh
Normal file
18
tools/setup-ovs.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash -xe
|
||||
|
||||
# This is a copy from the ovsdbapp projects
|
||||
|
||||
OVN_BRANCH=${OVN_BRANCH:-main}
|
||||
|
||||
if [ "$OVN_SRCDIR" -a ! -d "$OVN_SRCDIR" ]; then
|
||||
echo "Building OVN branch $OVN_BRANCH in $OVN_SRCDIR"
|
||||
mkdir -p $OVN_SRCDIR
|
||||
git clone --recurse-submodules https://github.com/ovn-org/ovn.git $OVN_SRCDIR
|
||||
pushd $OVN_SRCDIR
|
||||
git checkout $OVN_BRANCH
|
||||
pushd ovs
|
||||
./boot.sh && PYTHON=/usr/bin/python ./configure && make -j$(($(nproc) + 1))
|
||||
popd
|
||||
./boot.sh && PYTHON=/usr/bin/python ./configure && make -j$(($(nproc) + 1))
|
||||
popd
|
||||
fi
|
9
tox.ini
9
tox.ini
@ -25,10 +25,15 @@ commands = flake8 {posargs}
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:functional]
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
setenv = {[testenv]setenv}
|
||||
OVN_SRCDIR={envdir}/src/ovn
|
||||
OVS_SRCDIR={envdir}/src/ovn/ovs
|
||||
VTEP_SRCDIR={envdir}/src/ovn/ovs/vtep
|
||||
OVN_BRANCH={env:OVN_BRANCH:}
|
||||
commands =
|
||||
bash {toxinidir}/tools/setup-ovs.sh
|
||||
stestr run --exclude-regex ".tests.unit" {posargs}
|
||||
allowlist_externals = bash
|
||||
|
||||
[testenv:cover]
|
||||
setenv =
|
||||
|
Loading…
Reference in New Issue
Block a user