Merge lp:~dawgfoto/duplicity/replicate into lp:~duplicity-team/duplicity/0.8-series

Proposed by Martin Nowak
Status: Merged
Merged at revision: 1245
Proposed branch: lp:~dawgfoto/duplicity/replicate
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 83 lines (+79/-0)
1 file modified
testing/functional/test_replicate.py (+79/-0)
To merge this branch: bzr merge lp:~dawgfoto/duplicity/replicate
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+326009@code.launchpad.net

Description of the change

Add integration test for newly added replicate command.
Also see https://code.launchpad.net/~dawgfoto/duplicity/replicate/+merge/322836.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'testing/functional/test_replicate.py'
2--- testing/functional/test_replicate.py 1970-01-01 00:00:00 +0000
3+++ testing/functional/test_replicate.py 2017-06-20 15:22:15 +0000
4@@ -0,0 +1,79 @@
5+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
6+#
7+# Copyright 2002 Ben Escoto <ben@emerose.org>
8+# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
9+#
10+# This file is part of duplicity.
11+#
12+# Duplicity is free software; you can redistribute it and/or modify it
13+# under the terms of the GNU General Public License as published by the
14+# Free Software Foundation; either version 2 of the License, or (at your
15+# option) any later version.
16+#
17+# Duplicity is distributed in the hope that it will be useful, but
18+# WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20+# General Public License for more details.
21+#
22+# You should have received a copy of the GNU General Public License
23+# along with duplicity; if not, write to the Free Software Foundation,
24+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25+
26+import os
27+import unittest
28+
29+from duplicity import path
30+from . import CmdError, FunctionalTestCase
31+
32+
33+class ReplicateTest(FunctionalTestCase):
34+ """
35+ Test backup/replicate/restore using duplicity binary
36+ """
37+
38+ def runtest(self, dirlist, backup_options=[], replicate_options=[], restore_options=[]):
39+ # Back up directories to local backend
40+ current_time = 100000
41+ self.backup("full", dirlist[0], current_time=current_time,
42+ options=backup_options)
43+ for new_dir in dirlist[1:]:
44+ current_time += 100000
45+ self.backup("inc", new_dir, current_time=current_time,
46+ options=backup_options)
47+
48+ # Replicate to other backend
49+ source_url = self.backend_url
50+ target_url = "file://testfiles/replicate_out"
51+ self.run_duplicity(options=["replicate"] +
52+ replicate_options + [source_url, target_url])
53+
54+ self.backend_url = target_url
55+
56+ # Restore each and compare them
57+ for i in range(len(dirlist)):
58+ dirname = dirlist[i]
59+ current_time = 100000 * (i + 1)
60+ self.restore(time=current_time, options=restore_options)
61+ self.check_same(dirname, "testfiles/restore_out")
62+ self.verify(dirname,
63+ time=current_time, options=restore_options)
64+
65+ def check_same(self, filename1, filename2):
66+ """Verify two filenames are the same"""
67+ path1, path2 = path.Path(filename1), path.Path(filename2)
68+ assert path1.compare_recursive(path2, verbose=1)
69+
70+ def test_replicate(self):
71+ """Test replication"""
72+ self.runtest(["testfiles/dir1", "testfiles/dir2"])
73+
74+ def test_replicate_noencryption(self):
75+ """Test replication with decryption"""
76+ self.runtest(["testfiles/dir1", "testfiles/dir2"],
77+ replicate_options=["--no-encryption"])
78+
79+ def test_replicate_asym(self):
80+ """Test replication with reencryption"""
81+ asym_options = ["--encrypt-key", self.encrypt_key1]
82+ self.runtest(["testfiles/dir1", "testfiles/dir2"],
83+ replicate_options=asym_options, restore_options=asym_options)

Subscribers

People subscribed via source and target branches