Change in vdsm[master]: ipwrapperTests: prevent infinite stuck

phoracek at redhat.com phoracek at redhat.com
Fri Dec 5 13:25:05 UTC 2014


Petr Horáček has uploaded a new change for review.

Change subject: ipwrapperTests: prevent infinite stuck
......................................................................

ipwrapperTests: prevent infinite stuck

In case when iterator.next() has nothing to return, thread stuck.
To prevent this case, we added timeout to testMonitorInteration test.

Change-Id: Ie71eb5b33cabf5402f00815aa603bbc384159d56
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M tests/ipwrapperTests.py
1 file changed, 15 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/35901/1

diff --git a/tests/ipwrapperTests.py b/tests/ipwrapperTests.py
index 62f331c..b4d59d9 100644
--- a/tests/ipwrapperTests.py
+++ b/tests/ipwrapperTests.py
@@ -18,6 +18,8 @@
 #
 # Refer to the README and COPYING files for full details of the license
 #
+from threading import Timer
+
 from testValidation import ValidateRunningAsRoot
 from vdsm import ipwrapper
 from vdsm.ipwrapper import Monitor
@@ -152,17 +154,26 @@
 
     @ValidateRunningAsRoot
     def testMonitorIteration(self):
+
         bridge = tcTests._Bridge()
         tcTests._checkDependencies()
         mon = Monitor()
         mon.start()
+
+        def _timeout(mon):
+            mon.stop()
+            raise MonitorError("Test timeout")
+        timer = Timer(3, _timeout, args=[mon])
+        timer.start()
+
         iterator = iter(mon)
 
-        bridge.addDevice()  # Generate an event to avoid blocking
+        # Generate events to avoid blocking
+        bridge.addDevice()
         iterator.next()
 
         bridge.delDevice()
-        iterator.next()  # Generate an event to avoid blocking
+        iterator.next()
 
         # Stop the monitor and check that eventually StopIteration is raised.
         # There might be other system link events so we loop to exhaust them.
@@ -171,6 +182,8 @@
             while True:
                 iterator.next()
 
+        timer.cancel()
+
 
 class TestLinks(TestCaseBase):
     _bridge = tcTests._Bridge()


-- 
To view, visit http://gerrit.ovirt.org/35901
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie71eb5b33cabf5402f00815aa603bbc384159d56
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>


More information about the vdsm-patches mailing list