Skip to content
Browse files

Makes several tests more reliable (#1321)

  • Loading branch information
dposada authored and shamsimam committed Nov 27, 2019
1 parent 083ed27 commit 94a26b882d4ca0eb0e78e52c06105ae4490fb2a8
Showing with 8 additions and 2 deletions.
  1. +8 −2 integration/tests/cook/
@@ -675,7 +675,7 @@ def memory_limit_exceeded_helper(self, command, executor_type, mem=128):
job_details = f"Job details: {json.dumps(job, sort_keys=True)}"
self.assertEqual('failed', job['state'], job_details)
self.assertLessEqual(1, len(job['instances']), job_details)
instance = job['instances'][-1]
instance = next(i for i in job['instances'] if i['reason_code'] in [2002, 99003])
instance_details = json.dumps(instance, sort_keys=True)
self.logger.debug('instance: %s' % instance)
# did the job fail as expected?
@@ -1064,6 +1064,11 @@ def test_list_jobs_by_pool(self):
jobs.append(util.load_job(self.cook_url, job_uuid))
job_uuid, resp = util.submit_job(self.cook_url, pool=pool_name, name=name, command='exit 0')
self.assertEqual(201, resp.status_code)
# We wait for the job to start running, and only then start waiting for it to
# complete; otherwise we could get a false-negative on wait_for_job 'completed'
# because of a scheduling delay. Having two separate waits also disambiguates
# the root cause of a wait-timeout failure.
util.wait_for_job_in_statuses(self.cook_url, job_uuid, ['completed', 'running'])
jobs.append(util.wait_for_job(self.cook_url, job_uuid, 'completed'))
end = util.current_milli_time() + 1

@@ -1690,7 +1695,8 @@ def test_basic_docker_job(self):
command='cat /.dockerenv',
container={'type': 'DOCKER',
'docker': {'image': image}})
'docker': {'image': image}},
self.assertEqual(resp.status_code, 201)
job = util.wait_for_job(self.cook_url, job_uuid, 'completed')
self.assertIn('success', [i['status'] for i in job['instances']])

0 comments on commit 94a26b8

Please sign in to comment.
You can’t perform that action at this time.