is test_time_limit is failing because of timing?

give it up to ten seconds to mark the job finished
This commit is contained in:
Noah Levitt 2018-06-25 10:35:24 -05:00
parent c52c16c260
commit d4db8ba9bc

View File

@ -769,7 +769,7 @@ def test_time_limit(httpd):
rr = doublethink.Rethinker('localhost', db='brozzler') rr = doublethink.Rethinker('localhost', db='brozzler')
frontier = brozzler.RethinkDbFrontier(rr) frontier = brozzler.RethinkDbFrontier(rr)
# create a new job with three sites that could be crawled forever # create a new job with one seed that could be crawled forever
job_conf = {'seeds': [{ job_conf = {'seeds': [{
'url': 'http://localhost:%s/infinite/foo/' % httpd.server_port, 'url': 'http://localhost:%s/infinite/foo/' % httpd.server_port,
'time_limit': 20}]} 'time_limit': 20}]}
@ -789,6 +789,10 @@ def test_time_limit(httpd):
assert sites[0].status == 'FINISHED_TIME_LIMIT' assert sites[0].status == 'FINISHED_TIME_LIMIT'
# all sites finished so job should be finished too # all sites finished so job should be finished too
start = time.time()
job.refresh()
while not job.status == 'FINISHED' and time.time() - start < 10:
time.sleep(0.5)
job.refresh() job.refresh()
assert job.status == 'FINISHED' assert job.status == 'FINISHED'