|
From: <ba...@us...> - 2008-10-15 23:34:42
|
Revision: 1099
http://omc.svn.sourceforge.net/omc/?rev=1099&view=rev
Author: bartw
Date: 2008-10-15 23:34:36 +0000 (Wed, 15 Oct 2008)
Log Message:
-----------
some improvements for Indication Test
Modified Paths:
--------------
cmpi-bindings/trunk/test/python/TestIndications.py
Modified: cmpi-bindings/trunk/test/python/TestIndications.py
===================================================================
--- cmpi-bindings/trunk/test/python/TestIndications.py 2008-10-15 22:58:23 UTC (rev 1098)
+++ cmpi-bindings/trunk/test/python/TestIndications.py 2008-10-15 23:34:36 UTC (rev 1099)
@@ -20,7 +20,7 @@
from lib import wbem_connection
_port = 5309
-_lock = threading.RLock()
+_num_to_send = pywbem.Uint16(42)
class CIMListener(resource.Resource):
""" CIM Listener
@@ -123,6 +123,9 @@
#log.startLogging(sys.stdout)
+_lock = threading.RLock()
+_shutdown = False
+_insts_received = 0
if __name__ == '__main__':
parser = optparse.OptionParser()
@@ -140,30 +143,48 @@
conn = wbem_connection.WBEMConnFromOptions(parser)
def cb(inst):
+ global _lock
+ global _shutdown
+ global _insts_received
+ global _num_to_send
print inst['IndicationTime'], inst['Description']
+ _lock.acquire()
+ _insts_received+= 1
+ if _num_to_send == _insts_received:
+ _shutdown = True
+ _lock.release()
+
cl = CIMListener(callback=cb, http_port=5309)
def threadfunc():
time.sleep(1)
numrcv = 0
subcop = createSubscription(conn)
- num_to_send = pywbem.Uint16(7)
time.sleep(1)
conn.InvokeMethod('reset_indication_count', 'Test_UpcallAtom')
countsent,outs = conn.InvokeMethod('send_indications',
- 'Test_UpcallAtom', num_to_send=num_to_send)
+ 'Test_UpcallAtom', num_to_send=_num_to_send)
numsent,outs = conn.InvokeMethod('get_indication_send_count',
'Test_UpcallAtom')
deleteSubscription(conn, subcop)
if (countsent != numsent):
print("send_indications NumSent(%d) doesn't match get_indication_send_count NumSent(%d)"%(countsent, numsent));
sys.exit(1)
- time.sleep(4)
+ for i in xrange(10):
+ _lock.acquire()
+ if _shutdown:
+ reactor.stop()
+ _lock.release()
+ if not reactor.running:
+ break
+ time.sleep(.5)
if reactor.running:
reactor.stop()
- #self.fail("number received(%d) doesn't match number sent(%d)"%(numrcv,numsent));
thread = threading.Thread(target=threadfunc)
thread.start()
reactor.run()
+ if _num_to_send != _insts_received:
+ print 'Expected %s exceptions, got %s' % (_num_to_send, _insts_received)
+ sys.exit(1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|