[ARVADOS] updated: ec540668025ee8fecf2ccd58b5e571767c32b61a
Git user
git at public.curoverse.com
Fri Sep 23 14:58:41 EDT 2016
Summary of changes:
services/fuse/tests/test_mount.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
discards 293618ac3452994f07accea3ffddd4867e4a6176 (commit)
via ec540668025ee8fecf2ccd58b5e571767c32b61a (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (293618ac3452994f07accea3ffddd4867e4a6176)
\
N -- N -- N (ec540668025ee8fecf2ccd58b5e571767c32b61a)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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 ec540668025ee8fecf2ccd58b5e571767c32b61a
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Sep 23 14:50:23 2016 -0400
10124: Replace "sleep 1, then assert" with "retry assertion for up to 10 seconds".
diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py
index 79e7948..8b6d019 100644
--- a/services/fuse/tests/test_mount.py
+++ b/services/fuse/tests/test_mount.py
@@ -23,6 +23,33 @@ from mount_test_base import MountTestBase
logger = logging.getLogger('arvados.arv-mount')
+class AssertWithTimeout(object):
+ """Allow some time for an assertion to pass."""
+
+ def __init__(self, timeout=0):
+ self.timeout = timeout
+
+ def __iter__(self):
+ self.deadline = time.time() + self.timeout
+ self.done = False
+ return self
+
+ def next(self):
+ if self.done:
+ raise StopIteration
+ return self.attempt
+
+ def attempt(self, fn, *args, **kwargs):
+ try:
+ fn(*args, **kwargs)
+ except AssertionError:
+ if time.time() > self.deadline:
+ raise
+ time.sleep(0.1)
+ else:
+ self.done = True
+
+
class FuseMountTest(MountTestBase):
def setUp(self):
super(FuseMountTest, self).setUp()
@@ -182,18 +209,18 @@ class FuseTagsUpdateTest(MountTestBase):
bar_uuid = run_test_server.fixture('collections')['bar_file']['uuid']
self.tag_collection(bar_uuid, 'fuse_test_tag')
- time.sleep(1)
- self.assertIn('fuse_test_tag', llfuse.listdir(self.mounttmp))
+ for attempt in AssertWithTimeout(10):
+ attempt(self.assertIn, 'fuse_test_tag', llfuse.listdir(self.mounttmp))
self.assertDirContents('fuse_test_tag', [bar_uuid])
baz_uuid = run_test_server.fixture('collections')['baz_file']['uuid']
l = self.tag_collection(baz_uuid, 'fuse_test_tag')
- time.sleep(1)
- self.assertDirContents('fuse_test_tag', [bar_uuid, baz_uuid])
+ for attempt in AssertWithTimeout(10):
+ attempt(self.assertDirContents, 'fuse_test_tag', [bar_uuid, baz_uuid])
self.api.links().delete(uuid=l['uuid']).execute()
- time.sleep(1)
- self.assertDirContents('fuse_test_tag', [bar_uuid])
+ for attempt in AssertWithTimeout(10):
+ attempt(self.assertDirContents, 'fuse_test_tag', [bar_uuid])
class FuseSharedTest(MountTestBase):
@@ -713,15 +740,8 @@ class FuseUpdateFromEventTest(MountTestBase):
with collection2.open("file1.txt", "w") as f:
f.write("foo")
- # should show up in <10s via event bus notify
- expect = ["file1.txt"]
- for _ in range(100):
- d1 = sorted(llfuse.listdir(os.path.join(self.mounttmp)))
- if d1 == expect:
- break
- time.sleep(0.1)
-
- self.assertEqual(expect, d1)
+ for attempt in AssertWithTimeout(10):
+ attempt(self.assertEqual, ["file1.txt"], llfuse.listdir(os.path.join(self.mounttmp)))
def fuseFileConflictTestHelper(mounttmp):
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list