]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Stop running L3 functional tests with both OVSDB interfaces
authorAssaf Muller <amuller@redhat.com>
Fri, 27 Mar 2015 23:31:51 +0000 (19:31 -0400)
committerAssaf Muller <amuller@redhat.com>
Wed, 15 Apr 2015 00:01:44 +0000 (20:01 -0400)
Running the L3 functional tests with both OVSDB interfaces doubles
the run time and may discourage developers from running them
frequently during development. Since the OVSDB interfaces
are tested explicitly, I don't think the trade off is worth it
here. The L3 functional tests use OVS in a *really* trivial way
and won't catch any issues that the explicit tests won't.

Added an OVSInterfaceDriverTestCase plug functional test that runs with
both OVS interfaces to make it harder to introduce regressions.

Related-Bug: #1442272
Change-Id: I387db347fe34f8497069ddf768624bccb9d1de8b

neutron/tests/functional/agent/linux/test_interface.py [new file with mode: 0644]
neutron/tests/functional/agent/test_l3_agent.py

diff --git a/neutron/tests/functional/agent/linux/test_interface.py b/neutron/tests/functional/agent/linux/test_interface.py
new file mode 100644 (file)
index 0000000..9fca936
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (c) 2015 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 oslo_config import cfg
+import testtools
+
+from neutron.agent.linux import interface
+from neutron.agent.linux import ip_lib
+from neutron.common import exceptions
+from neutron.common import utils
+from neutron.openstack.common import uuidutils
+from neutron.tests import base as tests_base
+from neutron.tests.common import net_helpers
+from neutron.tests.functional.agent.linux import base
+
+
+class OVSInterfaceDriverTestCase(base.BaseOVSLinuxTestCase):
+    def setUp(self):
+        super(OVSInterfaceDriverTestCase, self).setUp()
+        conf = cfg.ConfigOpts()
+        conf.register_opts(interface.OPTS)
+        self.interface = interface.OVSInterfaceDriver(conf)
+
+    def test_plug_checks_if_bridge_exists(self):
+        with testtools.ExpectedException(exceptions.BridgeDoesNotExist):
+            self.interface.plug(network_id=42,
+                                port_id=71,
+                                device_name='not_a_device',
+                                mac_address='',
+                                bridge='not_a_bridge',
+                                namespace='not_a_namespace')
+
+    def test_plug_succeeds(self):
+        device_name = tests_base.get_rand_name()
+        mac_address = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
+        namespace = self._create_namespace()
+        bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
+
+        self.assertFalse(bridge.get_port_name_list())
+        self.interface.plug(network_id=uuidutils.generate_uuid(),
+                            port_id=uuidutils.generate_uuid(),
+                            device_name=device_name,
+                            mac_address=mac_address,
+                            bridge=bridge.br_name,
+                            namespace=namespace.namespace)
+        self.assertIn(device_name, bridge.get_port_name_list())
+        self.assertTrue(ip_lib.device_exists(device_name, namespace.namespace))
index 62c1ad642677fb94627c512ac15a4d6995a670b3..876175d105edfe7a8c9b662e9c41da88e3b9d6b0 100755 (executable)
@@ -60,7 +60,7 @@ def get_ovs_bridge(br_name):
     return ovs_lib.OVSBridge(br_name)
 
 
-class L3AgentTestFramework(base.BaseOVSLinuxTestCase):
+class L3AgentTestFramework(base.BaseLinuxTestCase):
     def setUp(self):
         super(L3AgentTestFramework, self).setUp()
         mock.patch('neutron.agent.l3.agent.L3PluginApi').start()