[ARVADOS] updated: f564c0d4009bf687f3d6f5b9a1a93a8a6bed5e70
git at public.curoverse.com
git at public.curoverse.com
Mon Sep 21 16:42:43 EDT 2015
Summary of changes:
sdk/python/arvados/__init__.py | 9 +++--
sdk/python/tests/arvados_testutil.py | 8 +++--
sdk/python/tests/test_task_output_retry.py | 56 ++++++++++++++++++------------
3 files changed, 47 insertions(+), 26 deletions(-)
via f564c0d4009bf687f3d6f5b9a1a93a8a6bed5e70 (commit)
from 629ea34aca61475f3d551644127028769fc0928c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit f564c0d4009bf687f3d6f5b9a1a93a8a6bed5e70
Author: Bryan Cosca <bcosc at curoverse.com>
Date: Mon Sep 21 16:42:38 2015 -0400
6600: flailing, still trying to figure out how to inject api
diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 736f41f..2c2be31 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -39,13 +39,17 @@ logger.setLevel(logging.DEBUG if config.get('ARVADOS_DEBUG')
else logging.WARNING)
def task_set_output(self,s,api_client=None,num_retries=5):
-
+
if not api_client:
api_client = api('v1')
+ print "tso"
+ print api_client.job_tasks().update().execute
+
+
for tries_left in RetryLoop(num_retries=num_retries, backoff_start=0): # change this to 2 after tests are finished
- print tries_left
try:
+ print "we tried"
return api_client.job_tasks().update(uuid=self['uuid'],
body={
'output':s,
@@ -53,6 +57,7 @@ def task_set_output(self,s,api_client=None,num_retries=5):
'progress':1.0
}).execute()
except errors.HttpError as error:
+ print "we threw the error"
if retry.check_http_response_success(error.status_code) is None and tries_left > 0:
logger.debug("task_set_output: job_tasks().update() raised {}, retrying with {} tries left".format(repr(error),tries_left))
else:
diff --git a/sdk/python/tests/arvados_testutil.py b/sdk/python/tests/arvados_testutil.py
index 53e5ba5..be0d0c0 100644
--- a/sdk/python/tests/arvados_testutil.py
+++ b/sdk/python/tests/arvados_testutil.py
@@ -116,8 +116,12 @@ def mock_keep_responses(body, *codes, **headers):
cm.responses = responses
return mock.patch('pycurl.Curl', cm)
-def mock_api_responses(body, *codes, **headers):
- cm = mock.MagicMock()
+def mock_api_responses(cm=None, body=None, *codes, **headers):
+
+ print cm
+ if cm is None:
+ cm = mock.MagicMock()
+
if isinstance(body, tuple):
codes = list(codes)
codes.insert(0, body)
diff --git a/sdk/python/tests/test_task_output_retry.py b/sdk/python/tests/test_task_output_retry.py
index 64fd9d5..e0256ac 100644
--- a/sdk/python/tests/test_task_output_retry.py
+++ b/sdk/python/tests/test_task_output_retry.py
@@ -25,32 +25,43 @@ class ApiClientRetrytestMixin(object):
def check_success(self, expected=None, api_client=None, *args, **kwargs):
if expected is None:
expected = self.DEFAULT_EXPECT
- self.assertEqual(expected, self.run_method(api_client, *args, **kwargs))
+ self.assertEqual(expected, self.run_method(api_client=api_client, *args, **kwargs))
def check_exception(self, error_class=None, api_client=None, *args, **kwargs):
if error_class is None:
error_class = self.DEFAULT_EXCEPTION
- self.assertRaises(error_class, self.run_method(api_client), *args, **kwargs)
-
- def test_immediate_success(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200) as api_client:
- self.check_success(api_client)
-
- def test_retry_then_success(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 200):
- self.check_success(num_retries=3)
-
- def test_success_after_default_retries_exhausted(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 200):
- self.check_success(num_retries=5)
-
- def test_error_after_default_retries_exhausted(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXCEPTION, 500, 500, 500, 500, 500, 200) as api_client:
- self.check_exception(api_client)
-
- def test_no_retry_after_immediate_success(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200, 400):
- self.check_success()
+ print error_class
+ self.run_method(api_client=api_client)
+ self.assertRaises(error_class, self.run_method(api_client=api_client), *args, **kwargs)
+
+# def test_immediate_success(self):
+# with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200) as api_client:
+# self.check_success(api_client=api_client)
+
+ def test_immediate_failure(self):
+ api_client = mock.MagicMock()
+ with self.TEST_API_PATCHER(api_client.job_tasks().update().execute, self.DEFAULT_EXPECT, 400) as api_client:
+ print api_client.job_tasks().update().execute.side_effect
+ print dir(api_client.job_tasks().update().execute.side_effect)
+ #api_client.job_tasks().update().execute.side_effect = arvados.errors.HttpError(400, "{}")
+ self.check_exception(api_client=api_client)
+
+# def test_retry_then_success(self):
+# with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 200):
+# self.check_success(num_retries=3)
+
+# def test_success_after_default_retries_exhausted(self):
+# with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 200):
+# self.check_success(num_retries=5)
+
+# def test_error_after_default_retries_exhausted(self):
+# with self.TEST_API_PATCHER(self.DEFAULT_EXCEPTION, 500, 500, 500, 500, 500, 200) as api_client:
+# print api_client
+# self.check_exception(api_client=api_client)
+
+# def test_no_retry_after_immediate_success(self):
+# with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200, 400):
+# self.check_success()
class TaskSetOutputTestCase(ApiClientRetrytestMixin, unittest.TestCase):
@@ -60,5 +71,6 @@ class TaskSetOutputTestCase(ApiClientRetrytestMixin, unittest.TestCase):
TEST_API_PATCHER = staticmethod(tutil.mock_api_responses)
def run_method(self, locator=ApiClientRetrytestMixin.TEST_LOCATOR, api_client=None, *args, **kwargs):
+ # Have some way to change api_client to use api_client.job_tasks().update().side_effect changes to httplib2 calls
arvados.task_set_output({'uuid':self.TEST_UUID},s=locator,api_client=api_client)
# If this returns none, we are successful, if it throws an HttpError, see error check.
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list