diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common.py | 10 | ||||
-rwxr-xr-x | tests/t2_block_cache.py | 3 | ||||
-rwxr-xr-x | tests/t4_fuse.py | 46 | ||||
-rwxr-xr-x | tests/t5_failsafe.py | 1 | ||||
-rwxr-xr-x | tests/t5_full.py | 1 | ||||
-rwxr-xr-x | tests/t6_upgrade.py | 1 |
6 files changed, 36 insertions, 26 deletions
diff --git a/tests/common.py b/tests/common.py index 2b1e8b3..8c3be59 100644 --- a/tests/common.py +++ b/tests/common.py @@ -213,9 +213,13 @@ def populate_dir(path, entries=1000, size=20*1024*1024, srcname = os.path.join(pooldir, poolnames[idx]) if not os.path.isfile(srcname): continue - with open(srcname, 'rb') as src: - buf = src.read(size) - dst.write(buf) + try: + with open(srcname, 'rb') as src: + buf = src.read(size) + except PermissionError: + # Source not readable.. + continue + dst.write(buf) size -= len(buf) files.append(name) diff --git a/tests/t2_block_cache.py b/tests/t2_block_cache.py index 453a58b..ebdc7fe 100755 --- a/tests/t2_block_cache.py +++ b/tests/t2_block_cache.py @@ -541,6 +541,8 @@ class MockMultiLock: self.release(*key) def acquire(self, *key, timeout=None): + if timeout == 0: + return False me = threading.current_thread() log.debug('%s blocked in acquire()', me.name) with self.cond: @@ -548,6 +550,7 @@ class MockMultiLock: pytest.fail('Timeout waiting for lock') self.real_mlock.locked_keys.add(key) log.debug('%s got lock', me.name) + return True def release(self, *key, noerror=False): me = threading.current_thread() diff --git a/tests/t4_fuse.py b/tests/t4_fuse.py index d529c77..75f8322 100755 --- a/tests/t4_fuse.py +++ b/tests/t4_fuse.py @@ -114,29 +114,18 @@ class TestFuse: assert not os.path.ismount(self.mnt_dir) def fsck(self): - # Use fsck to test authinfo reading - with tempfile.NamedTemporaryFile('wt') as authinfo_fh: - print('[entry1]', - 'storage-url: %s' % self.storage_url[:6], - 'fs-passphrase: clearly wrong', - 'backend-login: bla', - 'backend-password: not much better', - '', - '[entry2]', - 'storage-url: %s' % self.storage_url, - 'fs-passphrase: %s' % self.passphrase, - 'backend-login: %s' % self.backend_login, - 'backend-password:%s' % self.backend_passphrase, - file=authinfo_fh, sep='\n') - authinfo_fh.flush() - - proc = subprocess.Popen(self.s3ql_cmd_argv('fsck.s3ql') + - [ '--force', '--quiet', '--log', 'none', '--cachedir', - self.cache_dir, '--authfile', - authinfo_fh.name, self.storage_url ], - stdin=subprocess.PIPE, universal_newlines=True) - proc.stdin.close() - assert proc.wait() == 0 + proc = subprocess.Popen(self.s3ql_cmd_argv('fsck.s3ql') + + [ '--force', '--quiet', '--log', 'none', '--cachedir', + self.cache_dir, '--authfile', '/dev/null', + self.storage_url ], + stdin=subprocess.PIPE, universal_newlines=True) + if self.backend_login is not None: + print(self.backend_login, file=proc.stdin) + print(self.backend_passphrase, file=proc.stdin) + if self.passphrase is not None: + print(self.passphrase, file=proc.stdin) + proc.stdin.close() + assert proc.wait() == 0 def teardown_method(self, method): with open('/dev/null', 'wb') as devnull: @@ -178,6 +167,17 @@ class TestFuse: self.umount() self.fsck() + # Test metadata recovery + shutil.rmtree(self.cache_dir) + self.cache_dir = tempfile.mkdtemp(prefix='s3ql-cache-') + self.fsck() + + shutil.rmtree(self.cache_dir) + self.cache_dir = tempfile.mkdtemp(prefix='s3ql-cache-') + self.mount() + self.umount() + + def newname(self): self.name_cnt += 1 return "s3ql_%d" % self.name_cnt diff --git a/tests/t5_failsafe.py b/tests/t5_failsafe.py index af7fbea..ba9c83a 100755 --- a/tests/t5_failsafe.py +++ b/tests/t5_failsafe.py @@ -42,6 +42,7 @@ class TestFailsafe(t4_fuse.TestFuse): (backend_login, backend_pw, self.storage_url) = get_remote_test_info('gs-test') except NoTestSection as exc: + super().teardown_method(method) pytest.skip(exc.reason) self.backend_login = backend_login diff --git a/tests/t5_full.py b/tests/t5_full.py index e3011e2..5dcf5e8 100755 --- a/tests/t5_full.py +++ b/tests/t5_full.py @@ -74,6 +74,7 @@ class RemoteTest: (backend_login, backend_pw, self.storage_url) = get_remote_test_info(name) except NoTestSection as exc: + super().teardown_method(method) pytest.skip(exc.reason) self.backend_login = backend_login self.backend_passphrase = backend_pw diff --git a/tests/t6_upgrade.py b/tests/t6_upgrade.py index ffbc387..d58eea5 100755 --- a/tests/t6_upgrade.py +++ b/tests/t6_upgrade.py @@ -185,6 +185,7 @@ class RemoteUpgradeTest: (backend_login, backend_pw, self.storage_url) = get_remote_test_info(name) except NoTestSection as exc: + super().teardown_method(method) pytest.skip(exc.reason) self.backend_login = backend_login self.backend_passphrase = backend_pw |