Bug 1119172

Summary: pthreading.monkey_patch is too late when done in the vdsm tests
Product: Red Hat Enterprise Virtualization Manager Reporter: Yaniv Bronhaim <ybronhei>
Component: python-pthreadingAssignee: Yaniv Bronhaim <ybronhei>
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Belka <jbelka>
Severity: unspecified Docs Contact: Ruediger Landmann <rlandman>
Priority: unspecified    
Version: 3.6.0CC: bazulay, danken, gklein, nsoffer, oourfali, pstehlik, srevivo, ybronhei
Target Milestone: ovirt-3.6.0-rcKeywords: CodeChange
Target Release: 3.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-20 01:28:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yaniv Bronhaim 2014-07-14 08:21:20 UTC
Description of problem:
The introduction of the condition [1] that fail with exception while module thread is being imported before monkey patch it, raised that exception while noisetests starts up. One of nose imports import thread before we manage to call the monkey patch function in python-pthreading

[1] https://github.com/oVirt/pthreading/commit/490e837e0afed37823803d9e180a5d3eb17cb82c

Comment 1 Nir Soffer 2014-07-14 08:30:47 UTC
Monkey patching in the testrunner is too late - we need to monkey patch using something like site.py or other means that perform the monkeypatch first thing before importing anything else.

One option is to have our own nosetest executable:

 1 #!/usr/bin/python                                                                                                                                                                                              
  2 # EASY-INSTALL-ENTRY-SCRIPT: 'nose==1.3.3','console_scripts','nosetests'
  3 __requires__ = 'nose==1.3.3'
  4 import sys

Here we can import pthreading and monkey patch.

  5 from pkg_resources import load_entry_point
  6 
  7 if __name__ == '__main__':
  8     sys.exit(
  9         load_entry_point('nose==1.3.3', 'console_scripts', 'nosetests')()
 10     )

Comment 2 Nir Soffer 2014-07-14 12:47:42 UTC
Turns out that the issue was importing and running pthreading.monkey_patch twice in the tests, because we used testrunner both as script and library. The attached patch fixes this issue.

Comment 3 Jiri Belka 2014-09-17 09:32:35 UTC
CodeChange only or is it easy for a verification? If the latter please provide steps for verification. Thx.

Comment 4 Jiri Belka 2014-09-17 10:58:47 UTC
this is not really testable by QA, it is code change in devel nose tests.