Added test to test multivolume corruption at restore
authorDaniel Garcia Moreno <danigm@wadobo.com>
Tue, 1 Jul 2014 18:16:52 +0000 (20:16 +0200)
committerDaniel Garcia Moreno <danigm@wadobo.com>
Tue, 1 Jul 2014 18:16:52 +0000 (20:16 +0200)
testing/test_deltatar.py

index 1f97eee..20c6397 100644 (file)
@@ -173,6 +173,48 @@ class DeltaTarTest(BaseTest):
             if value:
                 assert value == self.md5sum(key)
 
+    def test_restore_multivol_split(self):
+        '''
+        Creates a full backup without any filtering with multiple volumes
+        with big files bigger than the max volume size and
+        restore it.
+        '''
+        deltatar = DeltaTar(mode=self.MODE, password=self.PASSWORD,
+                            logger=self.consoleLogger)
+
+
+        self.hash = dict()
+        os.makedirs('source_dir2')
+        self.hash["source_dir2/big"]  = self.create_file("source_dir2/big", 4*1024*1024)
+        self.hash["source_dir2/huge"]  = self.create_file("source_dir2/huge", 4*1024*1024)
+        self.hash["source_dir2/huge2"]  = self.create_file("source_dir2/huge2", 4*1024*1024)
+
+        # create first backup
+        deltatar.create_full_backup(
+            source_path="source_dir2",
+            backup_path="backup_dir",
+            max_volume_size=2)
+
+        assert os.path.exists("backup_dir")
+        assert os.path.exists(os.path.join("backup_dir",
+            deltatar.volume_name_func("backup_dir", True, 0)))
+        assert os.path.exists(os.path.join("backup_dir",
+            deltatar.volume_name_func("backup_dir", True, 1)))
+
+        shutil.rmtree("source_dir2")
+
+        index_filename = deltatar.index_name_func(True)
+        index_path = os.path.join("backup_dir", index_filename)
+
+        deltatar.restore_backup(target_path="source_dir2",
+            backup_indexes_paths=[index_path])
+
+        for key, value in self.hash.items():
+            assert os.path.exists(key)
+            if value:
+                assert value == self.md5sum(key)
+
+
     def test_full_backup_index_extra_data(self):
         '''
         Tests that the index file for a full backup can store extra_data and
@@ -1379,4 +1421,4 @@ class DeltaTarAes256ConcatTest(DeltaTarTest):
     Same as DeltaTar but with specific aes128 concat stream mode
     '''
     MODE = '#aes256'
-    PASSWORD = 'some magic key'
\ No newline at end of file
+    PASSWORD = 'some magic key'