|
|
|
@ -17,19 +17,19 @@ from copy import copy
|
|
|
|
|
import json
|
|
|
|
|
import os
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
import common
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
from freezer.tests.integration import common
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestSimpleExecution(common.TestFS):
|
|
|
|
|
|
|
|
|
|
def test_freezerc_executes(self):
|
|
|
|
|
result = common.execute_freezerc('-h')
|
|
|
|
|
result = common.execute_freezerc({})
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
|
|
|
|
|
def test_freezerc_fails_with_wrong_params(self):
|
|
|
|
|
result = common.execute_freezerc('--blabla', must_fail=True,
|
|
|
|
|
result = common.execute_freezerc({'blabla': ''}, must_fail=True,
|
|
|
|
|
merge_stderr=True)
|
|
|
|
|
self.assertIn('unrecognized arguments', result)
|
|
|
|
|
|
|
|
|
@ -75,9 +75,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|
|
|
|
'storage': 'local',
|
|
|
|
|
'container': storage_dir.path
|
|
|
|
|
}
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
self.do_backup_and_restore_with_check(backup_args, restore_args)
|
|
|
|
@ -114,9 +114,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|
|
|
|
'storage': 'local',
|
|
|
|
|
'container': storage_dir.path
|
|
|
|
|
}
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
@ -149,8 +149,8 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|
|
|
|
'backup_name': backup_name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args),
|
|
|
|
|
must_fail=True, merge_stderr=True)
|
|
|
|
|
result = common.execute_freezerc(
|
|
|
|
|
backup_args, must_fail=True, merge_stderr=True)
|
|
|
|
|
self.assertIn('Path to backup mismatch', result)
|
|
|
|
|
|
|
|
|
|
@unittest.skipIf(not common.TestFS.use_lvm, "No LVM support")
|
|
|
|
@ -188,9 +188,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|
|
|
|
'container': storage_dir.path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
@ -229,9 +229,9 @@ class TestBackupFSLocalstorage(common.TestFS):
|
|
|
|
|
'container': storage_dir.path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
@ -280,7 +280,7 @@ class TestBackupSSH(common.TestFS):
|
|
|
|
|
'ssh_host': self.ssh_host
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = json.loads(result)
|
|
|
|
|
sub_path = '_'.join([result['hostname'], result['backup_name']])
|
|
|
|
@ -293,7 +293,7 @@ class TestBackupSSH(common.TestFS):
|
|
|
|
|
self.assertIn('container', result)
|
|
|
|
|
self.assertEquals(result['container'], self.container)
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
@ -333,7 +333,7 @@ class TestBackupSSH(common.TestFS):
|
|
|
|
|
'ssh_username': self.ssh_username,
|
|
|
|
|
'ssh_host': self.ssh_host
|
|
|
|
|
}
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
|
|
|
|
|
result = json.loads(result)
|
|
|
|
@ -342,7 +342,7 @@ class TestBackupSSH(common.TestFS):
|
|
|
|
|
# storage directory
|
|
|
|
|
# file_list = self.get_file_list_ssh(sub_path)
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
@ -402,27 +402,27 @@ class TestBackupSSH(common.TestFS):
|
|
|
|
|
'ssh_username': self.ssh_username,
|
|
|
|
|
'ssh_host': self.ssh_host
|
|
|
|
|
}
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
|
# -- level 1
|
|
|
|
|
self.source_tree.add_random_data()
|
|
|
|
|
self.assertTreesMatchNot()
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
|
# -- level 2
|
|
|
|
|
self.source_tree.add_random_data()
|
|
|
|
|
self.assertTreesMatchNot()
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
@ -474,7 +474,7 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
'container': copy(backup_args['container']),
|
|
|
|
|
}
|
|
|
|
|
# --- backup
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = json.loads(result)
|
|
|
|
|
self.assertIn('backup_name', result)
|
|
|
|
@ -487,12 +487,12 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
# file_list = self.get_file_list_openstack(result['container'])
|
|
|
|
|
|
|
|
|
|
# --- restore
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
|
# --- remove backups and container
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(remove_args))
|
|
|
|
|
result = common.execute_freezerc(remove_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
|
|
|
|
|
result = self.remove_swift_container(backup_args['container'])
|
|
|
|
@ -537,7 +537,7 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
'container': copy(backup_args['container']),
|
|
|
|
|
}
|
|
|
|
|
# --- backup
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = json.loads(result)
|
|
|
|
|
self.assertIn('backup_name', result)
|
|
|
|
@ -550,12 +550,12 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
# file_list = self.get_file_list_openstack(result['container'])
|
|
|
|
|
|
|
|
|
|
# --- restore
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
|
# --- remove backups and container
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(remove_args))
|
|
|
|
|
result = common.execute_freezerc(remove_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
|
|
|
|
|
result = self.remove_swift_container(backup_args['container'])
|
|
|
|
@ -603,9 +603,9 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
'container': copy(backup_args['container'])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
# we cannot test if trees as a running mysql instance will modify the files
|
|
|
|
|
|
|
|
|
@ -648,7 +648,7 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
'container': copy(backup_args['container']),
|
|
|
|
|
}
|
|
|
|
|
# --- backup
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(backup_args))
|
|
|
|
|
result = common.execute_freezerc(backup_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
result = json.loads(result)
|
|
|
|
|
self.assertIn('backup_name', result)
|
|
|
|
@ -661,12 +661,12 @@ class TestBackupUsingSwiftStorage(common.TestFS):
|
|
|
|
|
# file_list = self.get_file_list_openstack(result['container'])
|
|
|
|
|
|
|
|
|
|
# --- restore
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(restore_args))
|
|
|
|
|
result = common.execute_freezerc(restore_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
self.assertTreesMatch()
|
|
|
|
|
|
|
|
|
|
# --- remove backups and container
|
|
|
|
|
result = common.execute_freezerc(self.dict_to_args(remove_args))
|
|
|
|
|
result = common.execute_freezerc(remove_args)
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
|
|
|
|
|
|
result = self.remove_swift_container(backup_args['container'])
|
|
|
|
|