[ARVADOS] created: 604ee58b314b217fed6cd49f3e8548acc2ae46ab

git at public.curoverse.com git at public.curoverse.com
Thu Jan 21 02:06:53 EST 2016


        at  604ee58b314b217fed6cd49f3e8548acc2ae46ab (commit)


commit 604ee58b314b217fed6cd49f3e8548acc2ae46ab
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jan 21 02:06:38 2016 -0500

    8250: Add tests for --retries=0 (passes) and --retries=1 (fails).

diff --git a/services/fuse/tests/test_retry.py b/services/fuse/tests/test_retry.py
new file mode 100644
index 0000000..e58b9e7
--- /dev/null
+++ b/services/fuse/tests/test_retry.py
@@ -0,0 +1,48 @@
+import arvados.errors
+import json
+import mock
+import os
+
+from .integration_test import IntegrationTest
+
+expect_manifest = '. acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n'
+
+def current_manifest(tmp):
+    return json.load(
+        open(os.path.join(tmp, '.arvados#collection'))
+    )['manifest_text']
+
+
+class Retry(IntegrationTest):
+    mnt_args = ['--read-write', '--mount-tmp', 'tmp']
+
+    @mock.patch('arvados.keep.KeepClient.put')
+    @IntegrationTest.mount(argv=mnt_args+['--retries=1'])
+    def test_retry_write(self, mocked_put):
+        mocked_put.side_effect = [
+            arvados.errors.KeepWriteError('mock error (ok)'),
+            'acbd18db4cc2f85cedef654fccc4a4d8+3']
+        self.pool_test(os.path.join(self.mnt, 'tmp'))
+    @staticmethod
+    def _test_retry_write(self, tmp):
+        with open(os.path.join(tmp, 'foo'), 'w') as f:
+            f.write('foo')
+        self.assertEqual(current_manifest(tmp), expect_manifest)
+
+    @mock.patch('arvados.keep.KeepClient.put')
+    @IntegrationTest.mount(argv=mnt_args+['--retries=0'])
+    def test_no_retry_write(self, mocked_put):
+        mocked_put.side_effect = [
+            arvados.errors.KeepWriteError('mock error (ok)'),
+            'acbd18db4cc2f85cedef654fccc4a4d8+3',
+            arvados.errors.KeepWriteError('mock error (fail!)')]
+        self.pool_test(os.path.join(self.mnt, 'tmp'))
+    @staticmethod
+    def _test_no_retry_write(self, tmp):
+        with open(os.path.join(tmp, 'foo'), 'w') as f:
+            f.write('foo')
+        # First attempt fails and raises IOError instead of retrying
+        with self.assertRaises(IOError):
+            open(os.path.join(tmp, '.arvados#collection')).read()
+        # Second attempt retries and succeeds
+        self.assertEqual(current_manifest(tmp), expect_manifest)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list