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