X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b73a5d296669ae58c8cd5a7d2e1aedd19f0c0029..0eb72b526bf8bbb011551ecf019f604e17a534f1:/services/fuse/tests/test_retry.py diff --git a/services/fuse/tests/test_retry.py b/services/fuse/tests/test_retry.py index f6c0807678..1c2ade2717 100644 --- a/services/fuse/tests/test_retry.py +++ b/services/fuse/tests/test_retry.py @@ -1,11 +1,21 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + import arvados import arvados_fuse.command +import json import mock import os +import pycurl +import Queue import run_test_server import tempfile import unittest +from .integration_test import IntegrationTest + + class KeepClientRetry(unittest.TestCase): origKeepClient = arvados.keep.KeepClient @@ -33,3 +43,22 @@ class KeepClientRetry(unittest.TestCase): def test_no_retry(self): self._test_retry(0, ['--retries=0']) + +class RetryPUT(IntegrationTest): + @mock.patch('time.sleep') + @IntegrationTest.mount(argv=['--read-write', '--mount-tmp=zzz']) + def test_retry_write(self, sleep): + mockedCurl = mock.Mock(spec=pycurl.Curl(), wraps=pycurl.Curl()) + mockedCurl.perform.side_effect = Exception('mock error (ok)') + q = Queue.Queue() + q.put(mockedCurl) + q.put(pycurl.Curl()) + q.put(pycurl.Curl()) + with mock.patch('arvados.keep.KeepClient.KeepService._get_user_agent', side_effect=q.get_nowait): + self.pool_test(os.path.join(self.mnt, 'zzz')) + self.assertTrue(mockedCurl.perform.called) + @staticmethod + def _test_retry_write(self, tmp): + with open(os.path.join(tmp, 'foo'), 'w') as f: + f.write('foo') + json.load(open(os.path.join(tmp, '.arvados#collection')))