Merge "fix integration tests"
This commit is contained in:
commit
fed3f1e5b6
@ -49,13 +49,13 @@ class CommandFailed(Exception):
|
|||||||
"stderr:\n%s" % (self.cmd, self.returncode,
|
"stderr:\n%s" % (self.cmd, self.returncode,
|
||||||
self.stdout, self.stderr))
|
self.stdout, self.stderr))
|
||||||
|
|
||||||
|
def execute_freezerc(args, must_fail=False, merge_stderr=False):
|
||||||
|
cmd_freezer = FREEZERC + " " + args
|
||||||
|
return execute(cmd_freezer, must_fail=must_fail, merge_stderr=merge_stderr)
|
||||||
|
|
||||||
def execute(cmd, must_fail=False, merge_stderr=False):
|
def execute(cmd, must_fail=False, merge_stderr=False):
|
||||||
"""Executes specified command for the given action."""
|
"""Executes specified command for the given action."""
|
||||||
cmd_freezer = FREEZERC + " " + cmd
|
cmdlist = shlex.split(cmd.encode('utf-8'))
|
||||||
cmdlist = shlex.split(cmd_freezer.encode('utf-8'))
|
|
||||||
result = ''
|
|
||||||
result_err = ''
|
|
||||||
stdout = subprocess.PIPE
|
stdout = subprocess.PIPE
|
||||||
stderr = subprocess.STDOUT if merge_stderr else subprocess.PIPE
|
stderr = subprocess.STDOUT if merge_stderr else subprocess.PIPE
|
||||||
proc = subprocess.Popen(cmdlist, stdout=stdout, stderr=stderr)
|
proc = subprocess.Popen(cmdlist, stdout=stdout, stderr=stderr)
|
||||||
@ -280,9 +280,9 @@ class TestFS(unittest.TestCase):
|
|||||||
def do_backup_and_restore_with_check(self, backup_args, restore_args):
|
def do_backup_and_restore_with_check(self, backup_args, restore_args):
|
||||||
self.source_tree.add_random_data()
|
self.source_tree.add_random_data()
|
||||||
self.assertTreesMatchNot()
|
self.assertTreesMatchNot()
|
||||||
result = execute(self.dict_to_args(backup_args))
|
result = execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = execute(self.dict_to_args(restore_args))
|
result = execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
return True
|
return True
|
||||||
|
@ -25,11 +25,11 @@ import uuid
|
|||||||
class TestSimpleExecution(common.TestFS):
|
class TestSimpleExecution(common.TestFS):
|
||||||
|
|
||||||
def test_freezerc_executes(self):
|
def test_freezerc_executes(self):
|
||||||
result = common.execute('-h')
|
result = common.execute_freezerc('-h')
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
def test_freezerc_fails_with_wrong_params(self):
|
def test_freezerc_fails_with_wrong_params(self):
|
||||||
result = common.execute('--blabla', must_fail=True, merge_stderr=True)
|
result = common.execute_freezerc('--blabla', must_fail=True, merge_stderr=True)
|
||||||
self.assertIn('unrecognized arguments', result)
|
self.assertIn('unrecognized arguments', result)
|
||||||
|
|
||||||
|
|
||||||
@ -74,9 +74,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|||||||
'storage': 'local',
|
'storage': 'local',
|
||||||
'container': storage_dir.path
|
'container': storage_dir.path
|
||||||
}
|
}
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
self.do_backup_and_restore_with_check(backup_args, restore_args)
|
self.do_backup_and_restore_with_check(backup_args, restore_args)
|
||||||
@ -113,9 +113,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|||||||
'storage': 'local',
|
'storage': 'local',
|
||||||
'container': storage_dir.path
|
'container': storage_dir.path
|
||||||
}
|
}
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|||||||
'backup_name': backup_name
|
'backup_name': backup_name
|
||||||
}
|
}
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(backup_args),
|
result = common.execute_freezerc(self.dict_to_args(backup_args),
|
||||||
must_fail=True, merge_stderr=True)
|
must_fail=True, merge_stderr=True)
|
||||||
self.assertIn('Path to backup mismatch', result)
|
self.assertIn('Path to backup mismatch', result)
|
||||||
|
|
||||||
@ -187,9 +187,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|||||||
'container': storage_dir.path
|
'container': storage_dir.path
|
||||||
}
|
}
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
@ -228,9 +228,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|||||||
'container': storage_dir.path
|
'container': storage_dir.path
|
||||||
}
|
}
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ class TestBackupSSH(common.TestFS):
|
|||||||
'ssh_host': self.ssh_host
|
'ssh_host': self.ssh_host
|
||||||
}
|
}
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
sub_path = '_'.join([result['hostname'], result['backup_name']])
|
sub_path = '_'.join([result['hostname'], result['backup_name']])
|
||||||
@ -292,7 +292,7 @@ class TestBackupSSH(common.TestFS):
|
|||||||
self.assertIn('container', result)
|
self.assertIn('container', result)
|
||||||
self.assertEquals(result['container'], self.container)
|
self.assertEquals(result['container'], self.container)
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ class TestBackupSSH(common.TestFS):
|
|||||||
'ssh_username': self.ssh_username,
|
'ssh_username': self.ssh_username,
|
||||||
'ssh_host': self.ssh_host
|
'ssh_host': self.ssh_host
|
||||||
}
|
}
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
@ -341,7 +341,7 @@ class TestBackupSSH(common.TestFS):
|
|||||||
# storage directory
|
# storage directory
|
||||||
# file_list = self.get_file_list_ssh(sub_path)
|
# file_list = self.get_file_list_ssh(sub_path)
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
@ -401,27 +401,27 @@ class TestBackupSSH(common.TestFS):
|
|||||||
'ssh_username': self.ssh_username,
|
'ssh_username': self.ssh_username,
|
||||||
'ssh_host': self.ssh_host
|
'ssh_host': self.ssh_host
|
||||||
}
|
}
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
# -- level 1
|
# -- level 1
|
||||||
self.source_tree.add_random_data()
|
self.source_tree.add_random_data()
|
||||||
self.assertTreesMatchNot()
|
self.assertTreesMatchNot()
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
# -- level 2
|
# -- level 2
|
||||||
self.source_tree.add_random_data()
|
self.source_tree.add_random_data()
|
||||||
self.assertTreesMatchNot()
|
self.assertTreesMatchNot()
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
'container': copy(backup_args['container']),
|
'container': copy(backup_args['container']),
|
||||||
}
|
}
|
||||||
# --- backup
|
# --- backup
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
self.assertIn('backup_name', result)
|
self.assertIn('backup_name', result)
|
||||||
@ -486,12 +486,12 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
# file_list = self.get_file_list_openstack(result['container'])
|
# file_list = self.get_file_list_openstack(result['container'])
|
||||||
|
|
||||||
# --- restore
|
# --- restore
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
# --- remove backups and container
|
# --- remove backups and container
|
||||||
result = common.execute(self.dict_to_args(remove_args))
|
result = common.execute_freezerc(self.dict_to_args(remove_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
result = self.remove_swift_container(backup_args['container'])
|
result = self.remove_swift_container(backup_args['container'])
|
||||||
@ -536,7 +536,7 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
'container': copy(backup_args['container']),
|
'container': copy(backup_args['container']),
|
||||||
}
|
}
|
||||||
# --- backup
|
# --- backup
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
self.assertIn('backup_name', result)
|
self.assertIn('backup_name', result)
|
||||||
@ -549,12 +549,12 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
# file_list = self.get_file_list_openstack(result['container'])
|
# file_list = self.get_file_list_openstack(result['container'])
|
||||||
|
|
||||||
# --- restore
|
# --- restore
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
# --- remove backups and container
|
# --- remove backups and container
|
||||||
result = common.execute(self.dict_to_args(remove_args))
|
result = common.execute_freezerc(self.dict_to_args(remove_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
result = self.remove_swift_container(backup_args['container'])
|
result = self.remove_swift_container(backup_args['container'])
|
||||||
@ -602,9 +602,9 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
'container': copy(backup_args['container'])
|
'container': copy(backup_args['container'])
|
||||||
}
|
}
|
||||||
|
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
# we cannot test if trees as a running mysql instance will modify the files
|
# we cannot test if trees as a running mysql instance will modify the files
|
||||||
|
|
||||||
@ -647,7 +647,7 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
'container': copy(backup_args['container']),
|
'container': copy(backup_args['container']),
|
||||||
}
|
}
|
||||||
# --- backup
|
# --- backup
|
||||||
result = common.execute(self.dict_to_args(backup_args))
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
self.assertIn('backup_name', result)
|
self.assertIn('backup_name', result)
|
||||||
@ -660,12 +660,12 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|||||||
# file_list = self.get_file_list_openstack(result['container'])
|
# file_list = self.get_file_list_openstack(result['container'])
|
||||||
|
|
||||||
# --- restore
|
# --- restore
|
||||||
result = common.execute(self.dict_to_args(restore_args))
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertTreesMatch()
|
self.assertTreesMatch()
|
||||||
|
|
||||||
# --- remove backups and container
|
# --- remove backups and container
|
||||||
result = common.execute(self.dict_to_args(remove_args))
|
result = common.execute_freezerc(self.dict_to_args(remove_args))
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
result = self.remove_swift_container(backup_args['container'])
|
result = self.remove_swift_container(backup_args['container'])
|
||||||
|
Loading…
Reference in New Issue
Block a user