X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e768a05df9fd75cee3724e6b68cb65beeebaaa38..b17f04b7797eda5a5d888264f7d480d762a9966f:/sdk/python/tests/test_keep_client.py diff --git a/sdk/python/tests/test_keep_client.py b/sdk/python/tests/test_keep_client.py index e0bb734b21..872c93bae2 100644 --- a/sdk/python/tests/test_keep_client.py +++ b/sdk/python/tests/test_keep_client.py @@ -1171,7 +1171,7 @@ class AvoidOverreplication(unittest.TestCase, tutil.ApiClientMock): def finished(self): return False - + def setUp(self): self.copies = 3 self.pool = arvados.KeepClient.KeepWriterThreadPool( @@ -1215,7 +1215,7 @@ class AvoidOverreplication(unittest.TestCase, tutil.ApiClientMock): self.pool.add_task(ks, None) self.pool.join() self.assertEqual(self.pool.done(), self.copies-1) - + @tutil.skip_sleep class RetryNeedsMultipleServices(unittest.TestCase, tutil.ApiClientMock): @@ -1250,3 +1250,27 @@ class RetryNeedsMultipleServices(unittest.TestCase, tutil.ApiClientMock): with self.assertRaises(arvados.errors.KeepWriteError): self.keep_client.put('foo', num_retries=1, copies=2) self.assertEqual(2, req_mock.call_count) + +class KeepClientAPIErrorTest(unittest.TestCase): + def test_api_fail(self): + class ApiMock(object): + def __getattr__(self, r): + if r == "api_token": + return "abc" + else: + raise arvados.errors.KeepReadError() + keep_client = arvados.KeepClient(api_client=ApiMock(), + proxy='', local_store='') + + # The bug this is testing for is that if an API (not + # keepstore) exception is thrown as part of a get(), the next + # attempt to get that same block will result in a deadlock. + # This is why there are two get()s in a row. Unfortunately, + # the failure mode for this test is that the test suite + # deadlocks, there isn't a good way to avoid that without + # adding a special case that has no use except for this test. + + with self.assertRaises(arvados.errors.KeepReadError): + keep_client.get("acbd18db4cc2f85cedef654fccc4a4d8+3") + with self.assertRaises(arvados.errors.KeepReadError): + keep_client.get("acbd18db4cc2f85cedef654fccc4a4d8+3")