]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
SimpleInterfaceMonitor: get rid of self.data_received flag
authorIhar Hrachyshka <ihrachys@redhat.com>
Thu, 17 Sep 2015 13:52:29 +0000 (15:52 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Thu, 24 Sep 2015 15:08:36 +0000 (17:08 +0200)
It's not used anywhere outside tests, and there are better ways to
wait for updates.

The flag was once used to influence the state of activeness for the
monitor, but not anymore [1].

This cleanup also allows us to remove custom _read_stdout from the
monitor and reuse the one inherited from AsyncProcess. Meaning, we
also can safely get rid of another pile of duplicate tests.

[1]: I05faeddd061ab45af51c044a10462c3a57593d4d

Change-Id: I612d492c8f65a70e18f782a5e4d055de5f7948ef

neutron/agent/linux/ovsdb_monitor.py
neutron/tests/functional/agent/linux/test_ovsdb_monitor.py
neutron/tests/unit/agent/linux/test_ovsdb_monitor.py

index feed5c3ff32ef059447cef2fee79ddf897af2ac5..0300728a3d6d16d1f4d4c9d101de5616dc2bcd63 100644 (file)
@@ -60,7 +60,6 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
             format='json',
             respawn_interval=respawn_interval,
         )
-        self.data_received = False
         self.new_events = {'added': [], 'removed': []}
 
     @property
@@ -109,13 +108,3 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
             with eventlet.timeout.Timeout(timeout):
                 while not self.is_active():
                     eventlet.sleep()
-
-    def _kill(self, *args, **kwargs):
-        self.data_received = False
-        super(SimpleInterfaceMonitor, self)._kill(*args, **kwargs)
-
-    def _read_stdout(self):
-        data = super(SimpleInterfaceMonitor, self)._read_stdout()
-        if data and not self.data_received:
-            self.data_received = True
-        return data
index c2d5db446e00f6ca6ffb09731b3b04f28327d169..8fa8ed267bb7755aa760dc7a465cd6176da3d686 100644 (file)
@@ -91,9 +91,7 @@ class TestSimpleInterfaceMonitor(BaseMonitorTest):
         self.monitor.start(block=True, timeout=timeout)
 
     def test_has_updates(self):
-        utils.wait_until_true(lambda: self.monitor.data_received is True)
-        self.assertTrue(self.monitor.has_updates,
-                        'Initial call should always be true')
+        utils.wait_until_true(lambda: self.monitor.has_updates)
         # clear the event list
         self.monitor.get_events()
         self.useFixture(net_helpers.OVSPortFixture())
@@ -118,7 +116,7 @@ class TestSimpleInterfaceMonitor(BaseMonitorTest):
                 return True
 
     def test_get_events(self):
-        utils.wait_until_true(lambda: self.monitor.data_received is True)
+        utils.wait_until_true(lambda: self.monitor.has_updates)
         devices = self.monitor.get_events()
         self.assertTrue(devices.get('added'),
                         'Initial call should always be true')
index dc41c96e009f5a93d102735be1bbba015ec38163..73a3a08702c3589f54ae3961a7c16b5b5aef5e7e 100644 (file)
@@ -52,30 +52,6 @@ class TestSimpleInterfaceMonitor(base.BaseTestCase):
         with mock.patch(target, return_value=True):
             self.assertFalse(self.monitor.has_updates)
 
-    def test__kill_sets_data_received_to_false(self):
-        self.monitor.data_received = True
-        with mock.patch(
-                'neutron.agent.linux.ovsdb_monitor.OvsdbMonitor._kill'):
-            self.monitor._kill()
-        self.assertFalse(self.monitor.data_received)
-
-    def test__read_stdout_sets_data_received_and_returns_output(self):
-        output = 'foo'
-        with mock.patch(
-                'neutron.agent.linux.ovsdb_monitor.OvsdbMonitor._read_stdout',
-                return_value=output):
-            result = self.monitor._read_stdout()
-        self.assertTrue(self.monitor.data_received)
-        self.assertEqual(result, output)
-
-    def test__read_stdout_does_not_set_data_received_for_empty_ouput(self):
-        output = None
-        with mock.patch(
-                'neutron.agent.linux.ovsdb_monitor.OvsdbMonitor._read_stdout',
-                return_value=output):
-            self.monitor._read_stdout()
-        self.assertFalse(self.monitor.data_received)
-
     def test_has_updates_after_calling_get_events_is_false(self):
         with mock.patch.object(
                 self.monitor, 'process_events') as process_events: