[ARVADOS] updated: cb29d6e2bc428f72a5913037de26016bd702ac94

git at public.curoverse.com git at public.curoverse.com
Wed Oct 21 16:57:39 EDT 2015


Summary of changes:
 sdk/python/tests/test_retry_job_helpers.py | 93 ++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 sdk/python/tests/test_retry_job_helpers.py

       via  cb29d6e2bc428f72a5913037de26016bd702ac94 (commit)
      from  479bb4c903b8780f017b0b63dfa59354353255ac (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 cb29d6e2bc428f72a5913037de26016bd702ac94
Author: Bryan Cosca <bcosc at curoverse.com>
Date:   Wed Oct 21 16:57:33 2015 -0400

    6600: Added test_retry_job_helpers

diff --git a/sdk/python/tests/test_retry_job_helpers.py b/sdk/python/tests/test_retry_job_helpers.py
new file mode 100644
index 0000000..747a1af
--- /dev/null
+++ b/sdk/python/tests/test_retry_job_helpers.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+import mock
+import os
+import unittest
+import hashlib
+import run_test_server
+import json
+import arvados
+import arvados_testutil as tutil
+from apiclient import http as apiclient_http
+
+
+ at tutil.skip_sleep
+class ApiClientRetryTestMixin(object):
+
+    TEST_UUID = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+    TEST_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
+
+    @classmethod
+    def setUpClass(cls):
+        run_test_server.run()
+        cls.api = arvados.api('v1')
+
+    def tearDown(self):
+        run_test_server.reset()
+
+    def run_method(self):
+        raise NotImplementedError("test subclasses must define run_method")
+
+#    def check_success(self, expected=None, *args, **kwargs):
+#        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
+#        self.assertRaises(error_class, self.run_method)
+
+    def test_immediate_success(self):
+        with tutil.mock_responses('{}', 200):
+            self.run_method()
+
+    def test_immediate_failure(self):
+        with tutil.mock_responses('{}', 400), self.assertRaises(self.DEFAULT_EXCEPTION):
+            self.run_method()
+
+    def test_retry_then_success(self):
+        with tutil.mock_responses('{}', 500, 200):
+            self.run_method()
+
+    def test_error_after_default_retries_exhausted(self):
+        with tutil.mock_responses('{}', 500, 500, 500, 500, 500, 500, 200), self.assertRaises(self.DEFAULT_EXCEPTION):
+            self.run_method()
+
+    def test_no_retry_after_immediate_success(self):
+        with tutil.mock_responses('{}', 200, 400):
+            self.run_method()
+
+
+class TaskSetOutputTestCase(ApiClientRetryTestMixin, unittest.TestCase):
+
+    DEFAULT_EXCEPTION = arvados.errors.ApiError
+
+    def run_method(self, locator=ApiClientRetryTestMixin.TEST_LOCATOR):
+        arvados.task_set_output({'uuid':self.TEST_UUID},s=locator)
+
+
+class CurrentJobTestCase(ApiClientRetryTestMixin, unittest.TestCase):
+
+    DEFAULT_EXCEPTION = arvados.errors.ApiError
+
+    def setUp(self):
+        os.environ['JOB_UUID'] = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+        os.environ['JOB_WORK'] = '.'
+
+    def run_method(self):
+        arvados.current_job()
+
+
+class CurrentTaskTestCase(ApiClientRetryTestMixin, unittest.TestCase):
+
+    DEFAULT_EXCEPTION = arvados.errors.ApiError
+
+    def setUp(self):
+        os.environ['TASK_UUID'] = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+        os.environ['TASK_WORK'] = '.'
+
+    def run_method(self):
+        arvados.current_task()
+

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list