[ARVADOS] updated: c6a0f9cb0b21d4c960c3fb172f5e7982997b1072

git at public.curoverse.com git at public.curoverse.com
Wed Aug 26 16:04:31 EDT 2015


Summary of changes:
 sdk/python/arvados/__init__.py |  7 ++++-
 sdk/python/tests/test_init.py  | 63 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 59 insertions(+), 11 deletions(-)

       via  c6a0f9cb0b21d4c960c3fb172f5e7982997b1072 (commit)
      from  03f9677371f7c502b65c950bb48aafc37c72c39d (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 c6a0f9cb0b21d4c960c3fb172f5e7982997b1072
Author: Bryan Cosca <bcosc at curoverse.com>
Date:   Wed Aug 26 16:04:23 2015 -0400

    6600: task_set_output unit tests for retry/success/fail cases

diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 8e3af9f..5f1864a 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -69,7 +69,9 @@ def task_set_output(self,s,api_client=None,num_retries=None):
                     if tries_left > 0:
                         print "Retrying with {} tries left".format(tries_left)
             else:
-                print "Retrying with {} tries left".format(tries_left)
+                print "Output success"
+                output_retry_loop.save_result(result)
+                output_retry_loop.success = True
         except errors.HttpError as error:
             print "HttpError raised"
             if not retry.check_http_response_success(error.status_code):
@@ -81,6 +83,9 @@ def task_set_output(self,s,api_client=None,num_retries=None):
                     if tries_left > 0:
                         print "Retrying with {} tries left".format(tries_left+1)
                     #logger.debug("HttpError returned {}, retrying with {} tries left".format(error.status_code,tries_left+1))
+            else:
+                print "Output success"
+                output_retry_loop.save_result(result)
         else:
             print "Output is good"
             output_retry_loop.save_result(result)
diff --git a/sdk/python/tests/test_init.py b/sdk/python/tests/test_init.py
index 081e653..a70d315 100644
--- a/sdk/python/tests/test_init.py
+++ b/sdk/python/tests/test_init.py
@@ -23,25 +23,68 @@ class SDKTestCase(unittest.TestCase, tutil.ApiClientMock):
         self.mock_call_update(api_client.job_tasks().update, status, 'foo_file')
         return api_client
 
-    def mock_multi(self, body, *codes, **headers):
-        headers.setdefault('x-keep-replicas-stored', 2)        
-        return tutil.mock_keep_responses(body, *codes, **headers)    
+    #def create_side_effect(self, mock_api, *codes):
+        #mock_api.job_tasks().update().execute.side_effect = []
+        #for code in codes:
+        #mock_api.job_tasks().update().execute.side_effect = [arvados.errors.ApiError(tutil.fake_httplib2_response(codes), "{}")]
+        #return mock_api
 
-    def test_mock_500(self,code=500):
+    def test_mock_retry_until_break(self,code=500):
         api_client = self.api_client_mock(code)
         with self.assertRaises(arvados.errors.ApiError) as err_check:
             arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
 
-    def test_mock_200(self,code=200):
+    def test_mock_success(self,code=200):
         api_client = self.api_client_mock(code)
         arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
 
-    def test_mock_400(self,code=400):
+    def test_mock_fail(self,code=400):
         api_client = self.api_client_mock(code)
         with self.assertRaises(arvados.errors.ApiError) as err_check:
             arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
 
-    def test_mock_200_500(self,code=400):
-        api_client = self.api_client_mock(code)
-        with tutil.mock_responses('', 500, 404, 1) as patch:
-            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client.patch,num_retries=1)
+    def test_mock_retry_success(self):
+        api_client = mock.MagicMock()
+        # api_client = self.api_client_mock(code)
+        # with self.create_side_effect(api_client,500,200):
+        #api_client.job_tasks().update().execute.side_effect = [arvados.errors.ApiError(tutil.fake_httplib2_response(500), "{}"), 
+        #                                                       arvados.errors.ApiError(tutil.fake_httplib2_response(200), "{}")]
+        with tutil.mock_keep_responses(self,500,200):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=1)
+            #api_client.job_tasks().update().execute.assert_called_with(num_retries=1)
+
+    def test_mock_retry_fail(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,500,400):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=1)
+
+    def test_mock_retry_retry(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,500,500):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=1)
+
+    def test_mock_retry_success_retry(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,500,200,500):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
+
+    def test_mock_retry_fail_retry(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,500,400,500):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
+
+    def test_mock_sucess_retry_retry(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,200,500,500):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
+
+    def test_mock_retry_retry_success(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,500,500,200):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
+
+    def test_mock_retry_retry_fail(self):
+        api_client = mock.MagicMock()
+        with tutil.mock_keep_responses(self,500,500,400):
+            arvados.task_set_output({'uuid':'zzzzz-zzzzz-zzzzzzzzzzzzzzz'},s='d41d8cd98f00b204e9800998ecf8427e+0',api_client=api_client,num_retries=2)
+

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list