From 330051a702453ee2953eb43555fa87117751465a Mon Sep 17 00:00:00 2001 From: Jan Gutter Date: Tue, 16 Oct 2018 17:26:04 +0200 Subject: [PATCH] Fix random test_unplug_ovs failures https://review.openstack.org/#/c/476612/ introduced an abstract OVSDB API, but it seems the gate is randomly calling linux_net utils in the context of Windows plug and unplug. This was because one of the tests set sys.platform to Windows, resulting in random failures, depending on the order in which the tests ran. Change-Id: I7e2a548fa4edc743d913f71dde48f613a7a5a8df Partial-Bug: #1798051 Signed-off-by: Jan Gutter --- vif_plug_ovs/constants.py | 1 + vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vif_plug_ovs/constants.py b/vif_plug_ovs/constants.py index f288e294..1935698d 100644 --- a/vif_plug_ovs/constants.py +++ b/vif_plug_ovs/constants.py @@ -19,4 +19,5 @@ OVS_VHOSTUSER_PREFIX = 'vhu' OVS_DATAPATH_SYSTEM = 'system' OVS_DATAPATH_NETDEV = 'netdev' +PLATFORM_LINUX = 'linux2' PLATFORM_WIN32 = 'win32' diff --git a/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py b/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py index b340c432..322f857e 100644 --- a/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py +++ b/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py @@ -11,7 +11,6 @@ # under the License. import mock -import sys import testtools from oslo_config import cfg @@ -52,17 +51,17 @@ class BaseOVSTest(testtools.TestCase): calls = [mock.call('Interface', 'device', ('mtu_request', 1500))] self.mock_db_set.assert_has_calls(calls) - @mock.patch.object(sys, 'platform', return_value='linux') + @mock.patch('sys.platform', constants.PLATFORM_LINUX) @mock.patch.object(linux_net, 'set_device_mtu') def test__update_device_mtu_interface_not_vhostuser_linux(self, - mock_set_device_mtu, mock_platform): + mock_set_device_mtu): self.br.update_device_mtu('device', 1500, 'not_vhost') mock_set_device_mtu.assert_has_calls([mock.call('device', 1500)]) + @mock.patch('sys.platform', constants.PLATFORM_WIN32) @mock.patch.object(linux_net, 'set_device_mtu') def test__update_device_mtu_interface_not_vhostuser_windows(self, mock_set_device_mtu): - sys.platform = constants.PLATFORM_WIN32 self.br.update_device_mtu('device', 1500, 'not_vhost') mock_set_device_mtu.assert_not_called()