[ARVADOS] updated: fa53e795f0d842dbbd9f861f269e5ba2913917df

git at public.curoverse.com git at public.curoverse.com
Thu Oct 8 15:14:24 EDT 2015


Summary of changes:
 sdk/python/arvados/__init__.py             |  6 +----
 sdk/python/tests/test_task_output_retry.py | 41 +++++++++++-------------------
 2 files changed, 16 insertions(+), 31 deletions(-)

       via  fa53e795f0d842dbbd9f861f269e5ba2913917df (commit)
      from  369724b0dce040664d3d84b40029c6c1f426fa8e (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 fa53e795f0d842dbbd9f861f269e5ba2913917df
Author: Bryan Cosca <bcosc at curoverse.com>
Date:   Thu Oct 8 15:14:17 2015 -0400

    6600: task_set_output tests work

diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 1367ccd..68a9578 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -43,9 +43,8 @@ def task_set_output(self,s,api_client=None,num_retries=5):
     if not api_client:
         api_client = api('v1')
 
-    for tries_left in RetryLoop(num_retries=num_retries, backoff_start=0): # change this to 2 after tests are finished
+    for tries_left in RetryLoop(num_retries=num_retries, backoff_start=2): # change this to 2 after tests are finished
         try:
-            print "we tried"
             api_client.job_tasks().update(uuid=self['uuid'],
                                                  body={
                                                       'output':s,
@@ -53,10 +52,7 @@ def task_set_output(self,s,api_client=None,num_retries=5):
                                                       'progress':1.0
                                                      }).execute()
         except errors.ApiError as error:
-            print "we raised"
-            print error
             if retry.check_http_response_success(error.resp.status) is None and tries_left > 0: #status_code for HttpError
-                print "task_set_output: job_tasks().update() raised {}, retrying with {} tries left".format(repr(error),tries_left)
                 logger.debug("task_set_output: job_tasks().update() raised {}, retrying with {} tries left".format(repr(error),tries_left))
             else:
                 raise
diff --git a/sdk/python/tests/test_task_output_retry.py b/sdk/python/tests/test_task_output_retry.py
index d75ba50..58af403 100644
--- a/sdk/python/tests/test_task_output_retry.py
+++ b/sdk/python/tests/test_task_output_retry.py
@@ -26,11 +26,7 @@ class ApiClientRetrytestMixin(object):
             'arvados.job_tasks().update().execute': (tutil.fake_httplib2_response(500, **cls.ERROR_HEADERS), "")
         }
         req_builder = apiclient_http.RequestMockBuilder(mock_responses)
-        cls.api = arvados.api('v1',
-                              host=os.environ['ARVADOS_API_HOST'],
-                              token='discovery-doc-only-no-token-needed',
-                              insecure=True,
-                              requestBuilder=req_builder)
+        cls.api = arvados.api('v1', requestBuilder=req_builder)
 
     def tearDown(cls):
         run_test_server.reset()
@@ -44,13 +40,14 @@ class ApiClientRetrytestMixin(object):
     def check_success(self, expected=None, *args, **kwargs):
         if expected is None:
             expected = self.DEFAULT_EXPECT
-        self.assertEqual(expected, self.run_method)
+        try:
+            self.run_method
+        except: # This seems really iffy, because random exceptions can occur.
+            self.assertTrue(False)
 
     def check_exception(self, error_class=None, *args, **kwargs):
         if error_class is None:
             error_class = self.DEFAULT_EXCEPTION
-        print "we raised error class"
-        print error_class
         self.assertRaises(error_class, self.run_method)
 
     def test_immediate_success(self):
@@ -58,33 +55,25 @@ class ApiClientRetrytestMixin(object):
             self.check_success()
 
     def test_immediate_failure(self):
-        with tutil.mock_responses('', 500, 400):
+        with tutil.mock_responses('', 400):
             self.check_exception()
 
-#    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_retry_then_success(self):
+        with tutil.mock_responses('', 500, 200):
+            self.check_success()
 
-#    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_error_after_default_retries_exhausted(self):
+        with tutil.mock_responses('', 500, 500, 500, 500, 500, 500):
+            self.check_exception()
 
-#    def test_no_retry_after_immediate_success(self):
-#        with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200, 400):
-#            self.check_success()
+    def test_no_retry_after_immediate_success(self):
+        with tutil.mock_responses('', 200, 400):
+            self.check_success()
 
 class TaskSetOutputTestCase(ApiClientRetrytestMixin, unittest.TestCase):
 
     ERROR_HEADERS = {'Content-Type': mimetypes.types_map['.json']}
-    DEFAULT_EXPECT = None
-    DEFAULT_RETURN = True
     DEFAULT_EXCEPTION = arvados.errors.ApiError
-    #TEST_API_PATCHER = staticmethod(tutil.mock_api_responses)
 
     def run_method(self, locator=ApiClientRetrytestMixin.TEST_LOCATOR, api_client=None, *args, **kwargs):
         arvados.task_set_output({'uuid':self.TEST_UUID},s=locator,api_client=api_client)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list