]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use an existing function in process monitor tests
authorLivnat Peer <lpeer@redhat.com>
Thu, 5 Mar 2015 11:43:17 +0000 (13:43 +0200)
committerLivnat Peer <lpeer@redhat.com>
Mon, 9 Mar 2015 18:10:08 +0000 (20:10 +0200)
No need to have a duplicate logic, reusing the function from utils

Change-Id: Ice51844e362135a95a28fa265a5d44726025271d

neutron/tests/functional/agent/linux/test_process_monitor.py

index aca151dd6f7707c21fad0cb469c4778925fcb1d4..1bf50803fc6e567d99eca5f65e84edb61524dc24 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import eventlet
 from oslo_config import cfg
 from six import moves
 
 from neutron.agent.linux import external_process
+from neutron.agent.linux import utils
 from neutron.tests import base
 from neutron.tests.functional.agent.linux import simple_daemon
 
@@ -78,17 +78,16 @@ class BaseTestProcessMonitor(base.BaseTestCase):
         def all_children_active():
             return all(pm.active for pm in self._child_processes)
 
-        self._wait_for_condition(all_children_active)
-
-    def _wait_for_condition(self, exit_condition, extra_time=5):
         # we need to allow extra_time for the check process to happen
         # and properly execute action over the gone processes under
         # high load conditions
         max_wait_time = (
-            cfg.CONF.AGENT.check_child_processes_interval + extra_time)
-        with self.assert_max_execution_time(max_wait_time):
-            while not exit_condition():
-                eventlet.sleep(0.01)
+            cfg.CONF.AGENT.check_child_processes_interval + 5)
+        utils.wait_until_true(
+            all_children_active,
+            timeout=max_wait_time,
+            sleep=0.01,
+            exception=RuntimeError('Not all children respawned.'))
 
     def cleanup_spawned_children(self):
         for pm in self._child_processes: