diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2016-03-09 10:09:35 -0800 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2016-03-09 10:09:35 -0800 |
commit | 181ca7febce49f2c2ee17e4615cc528ad03431b6 (patch) | |
tree | 5c076ba85f3e8b8c17c6531d2e4af9cec1072007 /tests/t6_upgrade.py | |
parent | ac9526150a54ca66ed041376e3081d719f77ce49 (diff) |
Import s3ql_2.10.1+dfsg.orig.tar.gz
Diffstat (limited to 'tests/t6_upgrade.py')
-rwxr-xr-x | tests/t6_upgrade.py | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/tests/t6_upgrade.py b/tests/t6_upgrade.py index e530e29..3dafaec 100755 --- a/tests/t6_upgrade.py +++ b/tests/t6_upgrade.py @@ -2,7 +2,7 @@ ''' t6_upgrade.py - this file is part of S3QL (http://s3ql.googlecode.com) -Copyright (C) Nikolaus Rath <Nikolaus@rath.org> +Copyright © 2008 Nikolaus Rath <Nikolaus@rath.org> This program can be distributed under the terms of the GNU GPLv3. ''' @@ -14,6 +14,7 @@ if __name__ == '__main__': from common import populate_dir, skip_without_rsync, retry from t1_backends import get_remote_test_info, NoTestSection +from s3ql import backends import shutil import subprocess from subprocess import check_output, CalledProcessError @@ -44,12 +45,14 @@ class UpgradeTest(t4_fuse.fuse_tests): shutil.rmtree(self.ref_dir) shutil.rmtree(self.bak_dir) - def mkfs_old(self): - proc = subprocess.Popen([os.path.join(self.basedir_old, 'bin', 'mkfs.s3ql'), - '-L', 'test fs', '--max-obj-size', '500', '--authfile', - '/dev/null', '--cachedir', self.cache_dir, '--quiet', - self.storage_url ], stdin=subprocess.PIPE, - universal_newlines=True) + def mkfs_old(self, force=False, max_obj_size=500): + argv = [ os.path.join(self.basedir_old, 'bin', 'mkfs.s3ql'), + '-L', 'test fs', '--max-obj-size', str(max_obj_size), + '--fatal-warnings', '--cachedir', self.cache_dir, '--quiet', + '--authfile', '/dev/null', self.storage_url ] + if force: + argv.append('--force') + proc = subprocess.Popen(argv, stdin=subprocess.PIPE, universal_newlines=True) if self.backend_login is not None: print(self.backend_login, file=proc.stdin) @@ -120,33 +123,43 @@ class UpgradeTest(t4_fuse.fuse_tests): self.umount() - def runTest(self): + def populate(self): populate_dir(self.ref_dir) + def runTest(self): + self.populate() + # Create and mount using previous S3QL version self.mkfs_old() self.mount_old() subprocess.check_call(['rsync', '-aHAX', self.ref_dir + '/', self.mnt_dir + '/']) self.umount_old() - # Copy old bucket - shutil.copytree(self.backend_dir, os.path.join(self.bak_dir, 'copy'), - symlinks=True) + # Try to access with new version (should fail) + self.mount(expect_fail=32) # Upgrade and compare with cache self.upgrade() self.compare() - # Upgrade and compare without cache - shutil.rmtree(self.backend_dir) + # Now do the same thing again, but without cached db + shutil.rmtree(self.cache_dir) + self.cache_dir = tempfile.mkdtemp(prefix='s3ql-cache-') + self.mkfs_old(force=True) + self.mount_old() + subprocess.check_call(['rsync', '-aHAX', self.ref_dir + '/', self.mnt_dir + '/']) + self.umount_old() + + # There does not seem a way to avoid the checksum error when + # upgrading from rev 20 to rev 21. + shutil.rmtree(self.cache_dir) + self.cache_dir = tempfile.mkdtemp(prefix='s3ql-cache-') + self.mount(expect_fail=32) shutil.rmtree(self.cache_dir) self.cache_dir = tempfile.mkdtemp(prefix='s3ql-cache-') - shutil.copytree(os.path.join(self.bak_dir, 'copy'), - self.backend_dir, symlinks=True) self.upgrade() self.compare() - class RemoteUpgradeTest: def setUp(self, name): super().setUp() @@ -158,21 +171,9 @@ class RemoteUpgradeTest: self.backend_login = backend_login self.backend_passphrase = backend_pw - def runTest(self): + def populate(self): populate_dir(self.ref_dir, entries=50, size=5*1024*1024) - # Create and mount using previous S3QL version - self.mkfs_old() - self.mount_old() - subprocess.check_call(['rsync', '-aHAX', self.ref_dir + '/', self.mnt_dir + '/']) - self.umount_old() - - # Upgrade and compare without cache - shutil.rmtree(self.cache_dir) - self.cache_dir = tempfile.mkdtemp(prefix='s3ql-cache-') - self.upgrade() - self.compare() - def tearDown(self): super().tearDown() @@ -188,10 +189,13 @@ class RemoteUpgradeTest: self.assertEqual(proc.wait(), 0) -class S3UpgradeTest(RemoteUpgradeTest, UpgradeTest): - def setUp(self): - super().setUp('s3-test') - -class SwiftUpgradeTest(RemoteUpgradeTest, UpgradeTest): - def setUp(self): - super().setUp('swift-test') +# Dynamically generate tests for other backends +for backend_name in backends.prefix_map: + if backend_name == 'local': + continue + def setUp(self, backend_name=backend_name): + RemoteUpgradeTest.setUp(self, backend_name + '-test') + test_class_name = backend_name + 'UpgradeTests' + globals()[test_class_name] = type(test_class_name, + (RemoteUpgradeTest, UpgradeTest), + { 'setUp': setUp }) |