From 641b275aa424421591833f6a3bce3ebd8b358017 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 3 Dec 2015 16:33:45 +0000 Subject: [PATCH] Wait on jobs and history in certain API test cases. This strategy proved to work around certain race conditions in tool testing so hopefully it will solve the transiently failing job searching and filtering test cases. --- test/api/helpers.py | 10 +++++++--- test/api/test_jobs.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/api/helpers.py b/test/api/helpers.py index 98087760950..799c790ee9b 100644 --- a/test/api/helpers.py +++ b/test/api/helpers.py @@ -70,10 +70,14 @@ class BaseDatasetPopulator( object ): Galaxy - implementations must implement _get and _post. """ - def new_dataset( self, history_id, content='TestData123', **kwds ): + def new_dataset( self, history_id, content='TestData123', wait=False, **kwds ): payload = self.upload_payload( history_id, content, **kwds ) - run_response = self._post( "tools", data=payload ) - return run_response.json()["outputs"][0] + run_response = self._post( "tools", data=payload ).json() + if wait: + job = run_response["jobs"][0] + self.wait_for_job(job["id"]) + self.wait_for_history(history_id) + return run_response["outputs"][0] def wait_for_history( self, history_id, assert_ok=False, timeout=DEFAULT_TIMEOUT ): try: diff --git a/test/api/test_jobs.py b/test/api/test_jobs.py index cba31d68b6f..18c850f65bc 100644 --- a/test/api/test_jobs.py +++ b/test/api/test_jobs.py @@ -200,8 +200,8 @@ class JobsApiTestCase( api.ApiTestCase, TestsDatasets ): return history_id, dataset_id def __history_with_ok_dataset( self ): - history_id, dataset_id = self.__history_with_new_dataset() - self._wait_for_history( history_id, assert_ok=True ) + history_id = self._new_history() + dataset_id = self._new_dataset( history_id, wait=True )[ "id" ] return history_id, dataset_id def __jobs_index( self, **kwds ):