##// END OF EJS Templates
Add Testcases for new purging methods in parallel.Client...
Jan Schulz -
Show More
@@ -400,7 +400,7 b' class TestClient(ClusterTestCase):'
400 """ensure KeyError on resubmit of nonexistant task"""
400 """ensure KeyError on resubmit of nonexistant task"""
401 self.assertRaisesRemote(KeyError, self.client.resubmit, ['invalid'])
401 self.assertRaisesRemote(KeyError, self.client.resubmit, ['invalid'])
402
402
403 def test_purge_results(self):
403 def test_purge_hub_results(self):
404 # ensure there are some tasks
404 # ensure there are some tasks
405 for i in range(5):
405 for i in range(5):
406 self.client[:].apply_sync(lambda : 1)
406 self.client[:].apply_sync(lambda : 1)
@@ -412,16 +412,63 b' class TestClient(ClusterTestCase):'
412 hist = self.client.hub_history()
412 hist = self.client.hub_history()
413 ahr = rc2.get_result([hist[-1]])
413 ahr = rc2.get_result([hist[-1]])
414 ahr.wait(10)
414 ahr.wait(10)
415 self.client.purge_results(hist[-1])
415 self.client.purge_hub_results(hist[-1])
416 newhist = self.client.hub_history()
416 newhist = self.client.hub_history()
417 self.assertEqual(len(newhist)+1,len(hist))
417 self.assertEqual(len(newhist)+1,len(hist))
418 rc2.spin()
418 rc2.spin()
419 rc2.close()
419 rc2.close()
420
421 def test_purge_local_results(self):
422 # ensure there are some tasks
423 res = []
424 for i in range(5):
425 res.append(self.client[:].apply_async(lambda : 1))
426 time.sleep(0.1)
427 self.client.wait(10) # wait for the results to come back
428 before = len(self.client.results)
429 self.assertEqual(len(self.client.metadata),before)
430 self.client.purge_local_results(res[-1])
431 self.assertEqual(len(self.client.results),before-len(res[-1]), msg="Not removed from results")
432 self.assertEqual(len(self.client.metadata),before-len(res[-1]), msg="Not removed from metadata")
420
433
434 def test_purge_all_hub_results(self):
435 self.client.purge_hub_results('all')
436 hist = self.client.hub_history()
437 self.assertEqual(len(hist), 0)
438
439 def test_purge_all_local_results(self):
440 self.client.purge_local_results('all')
441 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
442 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
443
421 def test_purge_all_results(self):
444 def test_purge_all_results(self):
445 # ensure there are some tasks
446 for i in range(5):
447 self.client[:].apply_sync(lambda : 1)
448 self.client.wait(10)
422 self.client.purge_results('all')
449 self.client.purge_results('all')
450 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
451 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
452 time.sleep(0.1)
453 hist = self.client.hub_history()#
454 self.assertEqual(len(hist), 0, msg="hub history not empty")
455
456 def test_purge_everything(self):
457 # ensure there are some tasks
458 for i in range(5):
459 self.client[:].apply_sync(lambda : 1)
460 self.client.wait(10)
461 self.client.purge_everything()
462 # The client results
463 self.assertEqual(len(self.client.results), 0, msg="Results not empty")
464 self.assertEqual(len(self.client.metadata), 0, msg="metadata not empty")
465 # the hub results
423 hist = self.client.hub_history()
466 hist = self.client.hub_history()
424 self.assertEqual(len(hist), 0)
467 self.assertEqual(len(hist), 0, msg="hub history not empty")
468 # The client "bookkeeping"
469 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")
471
425
472
426 def test_spin_thread(self):
473 def test_spin_thread(self):
427 self.client.spin_thread(0.01)
474 self.client.spin_thread(0.01)
General Comments 0
You need to be logged in to leave comments. Login now