X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b3fe30840e96e7fa77de047fae2488d703a49d89..001757381fd370a563599ca70ca9b451a71e9726:/services/fuse/tests/test_unmount.py?ds=sidebyside diff --git a/services/fuse/tests/test_unmount.py b/services/fuse/tests/test_unmount.py index 9e2ebd7128..716a0e00d7 100644 --- a/services/fuse/tests/test_unmount.py +++ b/services/fuse/tests/test_unmount.py @@ -1,5 +1,6 @@ import os import subprocess +import time from integration_test import IntegrationTest @@ -16,29 +17,71 @@ class UnmountTest(IntegrationTest): def test_replace(self): subprocess.check_call( - ['arv-mount', '--subtype', 'test', '--replace', + ['./bin/arv-mount', '--subtype', 'test', '--replace', self.mnt]) subprocess.check_call( - ['arv-mount', '--subtype', 'test', '--replace', + ['./bin/arv-mount', '--subtype', 'test', '--replace', '--unmount-timeout', '10', self.mnt]) subprocess.check_call( - ['arv-mount', '--subtype', 'test', '--replace', + ['./bin/arv-mount', '--subtype', 'test', '--replace', '--unmount-timeout', '10', self.mnt, '--exec', 'true']) for m in subprocess.check_output(['mount']).splitlines(): self.assertNotIn(' '+self.mnt+' ', m) + def _mounted(self, mounts): + all_mounts = subprocess.check_output(['mount']) + return [m for m in mounts + if ' '+m+' ' in all_mounts] + + def _wait_for_mounts(self, mounts): + deadline = time.time() + 10 + while self._mounted(mounts) != mounts: + time.sleep(0.1) + self.assertLess(time.time(), deadline) + + def test_unmount_subtype(self): + mounts = [] + for d in ['foo', 'bar']: + mnt = self.tmp+'/'+d + os.mkdir(mnt) + self.to_delete.insert(0, mnt) + mounts.append(mnt) + subprocess.check_call( + ['./bin/arv-mount', '--subtype', d, mnt]) + + self._wait_for_mounts(mounts) + self.assertEqual(mounts, self._mounted(mounts)) + subprocess.call(['./bin/arv-mount', '--subtype', 'baz', '--unmount-all', self.tmp]) + self.assertEqual(mounts, self._mounted(mounts)) + subprocess.call(['./bin/arv-mount', '--subtype', 'bar', '--unmount', mounts[0]]) + self.assertEqual(mounts, self._mounted(mounts)) + subprocess.call(['./bin/arv-mount', '--subtype', '', '--unmount', self.tmp]) + self.assertEqual(mounts, self._mounted(mounts)) + subprocess.check_call(['./bin/arv-mount', '--subtype', 'foo', '--unmount', mounts[0]]) + self.assertEqual(mounts[1:], self._mounted(mounts)) + subprocess.check_call(['./bin/arv-mount', '--subtype', '', '--unmount-all', mounts[0]]) + self.assertEqual(mounts[1:], self._mounted(mounts)) + subprocess.check_call(['./bin/arv-mount', '--subtype', 'bar', '--unmount-all', self.tmp]) + self.assertEqual([], self._mounted(mounts)) + def test_unmount_children(self): for d in ['foo', 'foo/bar', 'bar']: mnt = self.tmp+'/'+d os.mkdir(mnt) self.to_delete.insert(0, mnt) + mounts = [] for d in ['bar', 'foo/bar']: mnt = self.tmp+'/'+d + mounts.append(mnt) subprocess.check_call( - ['arv-mount', '--subtype', 'test', mnt]) - subprocess.check_call(['arv-mount', '--unmount', self.tmp+'/...']) - for m in subprocess.check_output(['mount']).splitlines(): - self.assertNotIn(' '+self.tmp+'/', m) + ['./bin/arv-mount', '--subtype', 'test', mnt]) + + self._wait_for_mounts(mounts) + self.assertEqual(mounts, self._mounted(mounts)) + subprocess.check_call(['./bin/arv-mount', '--unmount', self.tmp]) + self.assertEqual(mounts, self._mounted(mounts)) + subprocess.check_call(['./bin/arv-mount', '--unmount-all', self.tmp]) + self.assertEqual([], self._mounted(mounts))