From db4eddf0b151086b1075c3e568866a466fa366c8 Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Wed, 23 Aug 2017 14:44:16 +0000 Subject: [PATCH] functional: Remove ovsdb tests There are tests that exercise ovsdbapp internals and should be part of ovsdbapp project. We keep test_ovs_lib which exercises the real things. Change-Id: I0375caef25d6ea6c58832fc39f7acc915793ffd0 Related-bug: #1712594 --- .../tests/functional/agent/ovsdb/__init__.py | 0 .../functional/agent/ovsdb/native/__init__.py | 0 .../agent/ovsdb/native/test_connection.py | 45 ----------- .../functional/agent/ovsdb/test_impl_idl.py | 77 ------------------- 4 files changed, 122 deletions(-) delete mode 100644 neutron/tests/functional/agent/ovsdb/__init__.py delete mode 100644 neutron/tests/functional/agent/ovsdb/native/__init__.py delete mode 100644 neutron/tests/functional/agent/ovsdb/native/test_connection.py delete mode 100644 neutron/tests/functional/agent/ovsdb/test_impl_idl.py diff --git a/neutron/tests/functional/agent/ovsdb/__init__.py b/neutron/tests/functional/agent/ovsdb/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/neutron/tests/functional/agent/ovsdb/native/__init__.py b/neutron/tests/functional/agent/ovsdb/native/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/neutron/tests/functional/agent/ovsdb/native/test_connection.py b/neutron/tests/functional/agent/ovsdb/native/test_connection.py deleted file mode 100644 index fb48779e70c..00000000000 --- a/neutron/tests/functional/agent/ovsdb/native/test_connection.py +++ /dev/null @@ -1,45 +0,0 @@ -# All Rights Reserved. -# -# 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 neutron.agent.ovsdb.native import connection -from neutron.agent.ovsdb.native import idlutils -from neutron.tests.functional import base -from oslo_config import cfg -from ovs.db import idl - - -class OVSDBConnectionTestCase(base.BaseSudoTestCase): - - def test_idl_factory(self): - tables = ['Open_vSwitch', 'Bridge', 'Port'] - - def _idl_factory(): - connection = cfg.CONF.OVS.ovsdb_connection - helper = idlutils.get_schema_helper(connection, 'Open_vSwitch') - for table in tables: - helper.register_table(table) - return idl.Idl(connection, helper) - - try: - self.connection = connection.Connection( - idl=_idl_factory(), - timeout=cfg.CONF.ovs_vsctl_timeout, - ) - except TypeError: - self.connection = connection.Connection( - idl_factory=_idl_factory, - timeout=cfg.CONF.ovs_vsctl_timeout, - ) - self.connection.start() - self.assertItemsEqual(tables, self.connection.idl.tables.keys()) diff --git a/neutron/tests/functional/agent/ovsdb/test_impl_idl.py b/neutron/tests/functional/agent/ovsdb/test_impl_idl.py deleted file mode 100644 index fe433b34917..00000000000 --- a/neutron/tests/functional/agent/ovsdb/test_impl_idl.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (c) 2016 Red Hat, Inc. -# All Rights Reserved. -# -# 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. - -import mock - -from ovsdbapp import exceptions as exc -from ovsdbapp.schema.open_vswitch import impl_idl - -from neutron.agent.common import ovs_lib -from neutron.common import utils -from neutron.tests.common import net_helpers -from neutron.tests.functional import base - - -# NOTE(twilson) functools.partial does not work for this -def trpatch(*args, **kwargs): - def wrapped(fn): - return mock.patch.object(impl_idl.OvsVsctlTransaction, - *args, **kwargs)(fn) - return wrapped - - -class ImplIdlTestCase(base.BaseSudoTestCase): - def setUp(self): - super(ImplIdlTestCase, self).setUp() - self.config(group='OVS', ovsdb_interface='native') - self.ovs = ovs_lib.BaseOVS() - self.brname = utils.get_rand_device_name(net_helpers.BR_PREFIX) - # Make sure exceptions pass through by calling do_post_commit directly - mock.patch.object( - impl_idl.OvsVsctlTransaction, "post_commit", - side_effect=impl_idl.OvsVsctlTransaction.do_post_commit, - autospec=True).start() - - def _add_br(self): - # NOTE(twilson) we will be raising exceptions with add_br, so schedule - # cleanup before that. - self.addCleanup(self.ovs.delete_bridge, self.brname) - ovsdb = self.ovs.ovsdb - with ovsdb.transaction(check_error=True) as tr: - tr.add(ovsdb.add_br(self.brname)) - return tr - - def _add_br_and_test(self): - self._add_br() - ofport = self.ovs.db_get_val("Interface", self.brname, "ofport") - self.assertTrue(int(ofport)) - self.assertGreater(ofport, -1) - - def test_post_commit_vswitchd_completed_no_failures(self): - self._add_br_and_test() - - @trpatch("vswitchd_has_completed", return_value=True) - @trpatch("post_commit_failed_interfaces", return_value=["failed_if1"]) - @trpatch("timeout_exceeded", return_value=False) - def test_post_commit_vswitchd_completed_failures(self, *args): - self.assertRaises(impl_idl.VswitchdInterfaceAddException, - self._add_br) - - @trpatch("vswitchd_has_completed", return_value=False) - def test_post_commit_vswitchd_incomplete_timeout(self, *args): - # Due to timing issues we may rarely hit the global timeout, which - # raises RuntimeError to match the vsctl implementation - self.ovs.ovsdb.ovsdb_connection.timeout = 3 - self.assertRaises((exc.TimeoutException, RuntimeError), self._add_br)