##// END OF EJS Templates
improve patience for slow Hub in client tests...
MinRK -
Show More
@@ -304,6 +304,20 b' class TestClient(ClusterTestCase):'
304 """wait for an engine to become idle, according to the Hub"""
304 """wait for an engine to become idle, according to the Hub"""
305 rc = self.client
305 rc = self.client
306
306
307 # step 1. wait for all requests to be noticed
308 # timeout 5s, polling every 100ms
309 msg_ids = set(rc.history)
310 hub_hist = rc.hub_history()
311 for i in range(50):
312 if msg_ids.difference(hub_hist):
313 time.sleep(0.1)
314 hub_hist = rc.hub_history()
315 else:
316 break
317
318 self.assertEqual(len(msg_ids.difference(hub_hist)), 0)
319
320 # step 2. wait for all requests to be done
307 # timeout 5s, polling every 100ms
321 # timeout 5s, polling every 100ms
308 qs = rc.queue_status()
322 qs = rc.queue_status()
309 for i in range(50):
323 for i in range(50):
@@ -407,7 +421,7 b' class TestClient(ClusterTestCase):'
407 # Wait for the Hub to realise the result is done:
421 # Wait for the Hub to realise the result is done:
408 # This prevents a race condition, where we
422 # This prevents a race condition, where we
409 # might purge a result the Hub still thinks is pending.
423 # might purge a result the Hub still thinks is pending.
410 time.sleep(0.1)
424 self._wait_for_idle()
411 rc2 = clientmod.Client(profile='iptest')
425 rc2 = clientmod.Client(profile='iptest')
412 hist = self.client.hub_history()
426 hist = self.client.hub_history()
413 ahr = rc2.get_result([hist[-1]])
427 ahr = rc2.get_result([hist[-1]])
@@ -423,7 +437,7 b' class TestClient(ClusterTestCase):'
423 res = []
437 res = []
424 for i in range(5):
438 for i in range(5):
425 res.append(self.client[:].apply_async(lambda : 1))
439 res.append(self.client[:].apply_async(lambda : 1))
426 time.sleep(0.1)
440 self._wait_for_idle()
427 self.client.wait(10) # wait for the results to come back
441 self.client.wait(10) # wait for the results to come back
428 before = len(self.client.results)
442 before = len(self.client.results)
429 self.assertEqual(len(self.client.metadata),before)
443 self.assertEqual(len(self.client.metadata),before)
@@ -446,11 +460,11 b' class TestClient(ClusterTestCase):'
446 for i in range(5):
460 for i in range(5):
447 self.client[:].apply_sync(lambda : 1)
461 self.client[:].apply_sync(lambda : 1)
448 self.client.wait(10)
462 self.client.wait(10)
463 self._wait_for_idle()
449 self.client.purge_results('all')
464 self.client.purge_results('all')
450 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
465 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
451 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
466 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
452 time.sleep(0.1)
467 hist = self.client.hub_history()
453 hist = self.client.hub_history()#
454 self.assertEqual(len(hist), 0, msg="hub history not empty")
468 self.assertEqual(len(hist), 0, msg="hub history not empty")
455
469
456 def test_purge_everything(self):
470 def test_purge_everything(self):
@@ -458,16 +472,17 b' class TestClient(ClusterTestCase):'
458 for i in range(5):
472 for i in range(5):
459 self.client[:].apply_sync(lambda : 1)
473 self.client[:].apply_sync(lambda : 1)
460 self.client.wait(10)
474 self.client.wait(10)
475 self._wait_for_idle()
461 self.client.purge_everything()
476 self.client.purge_everything()
462 # The client results
477 # The client results
463 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
478 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
464 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
479 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
465 # the hub results
466 hist = self.client.hub_history()
467 self.assertEqual(len(hist), 0, msg="hub history not empty")
468 # The client "bookkeeping"
480 # The client "bookkeeping"
469 self.assertEqual(len(self.client.session.digest_history), 0, msg="session digest not empty")
481 self.assertEqual(len(self.client.session.digest_history), 0, msg="session digest not empty")
470 self.assertEqual(len(self.client.history), 0, msg="client history not empty")
482 self.assertEqual(len(self.client.history), 0, msg="client history not empty")
483 # the hub results
484 hist = self.client.hub_history()
485 self.assertEqual(len(hist), 0, msg="hub history not empty")
471
486
472
487
473 def test_spin_thread(self):
488 def test_spin_thread(self):
General Comments 0
You need to be logged in to leave comments. Login now