Skip to content

Commit 2663e86

Browse files
Updated Testing And Code
1 parent e467e8e commit 2663e86

File tree

7 files changed

+659
-212
lines changed

7 files changed

+659
-212
lines changed

examples/ex_local.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def main(argv):
4040
for p in poolset:
4141
print_all_datasets(p)
4242

43+
4344
if __name__ == '__main__':
4445
main(sys.argv[1:])
4546

tests/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def optimize_coalesce(operation_schedule):
9999
elif opgroup[0][0] == 'incremental': # incremental
100100
# 1->2->3->4 => 1->4
101101
new_ops = [ (srcs, dsts) for _, _, _, srcs, dsts in opgroup ]
102-
new_ops = simplify(new_ops)
102+
new_ops = zfs.simplify(new_ops)
103103
for srcs, dsts in new_ops:
104104
new.append(tuple(opgroup[0][:3] + (srcs, dsts)))
105105
else:

tests/test_sync.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class TestRecursiveReplicate(unittest.TestCase):
2020
maxDiff = None
2121

2222
# def test_does_nothing(self):
23-
# src = zfs.TestPoolSet()
24-
# dst = zfs.TestPoolSet()
23+
# src = TestPoolSet()
24+
# dst = TestPoolSet()
2525
# src.parse_zfs_r_output(
2626
# x('''karen 1359351119
2727
# karen/ROOT 1359351169
@@ -47,8 +47,8 @@ class TestRecursiveReplicate(unittest.TestCase):
4747
# self.assertFalse(result)
4848

4949
def test_replicates_one_snapshot_fully(self):
50-
src = zfs.TestPoolSet()
51-
dst = zfs.TestPoolSet()
50+
src = TestPoolSet()
51+
dst = TestPoolSet()
5252
src.parse_zfs_r_output(
5353
x('''karen 1359351119
5454
karen/ROOT 1359351169
@@ -92,8 +92,8 @@ def test_replicates_one_snapshot_fully(self):
9292
)
9393

9494
def test_are_in_sync(self):
95-
src = zfs.TestPoolSet()
96-
dst = zfs.TestPoolSet()
95+
src = TestPoolSet()
96+
dst = TestPoolSet()
9797
src.parse_zfs_r_output(
9898
x('''karen 1359351119
9999
karen/ROOT 1359351169
@@ -121,8 +121,8 @@ def test_are_in_sync(self):
121121
self.assertFalse(result)
122122

123123
def test_replicates_one_snapshot_incrementally(self):
124-
src = zfs.TestPoolSet()
125-
dst = zfs.TestPoolSet()
124+
src = TestPoolSet()
125+
dst = TestPoolSet()
126126
src.parse_zfs_r_output(
127127
x('''karen 1359351119
128128
karen/ROOT 1359351169
@@ -159,8 +159,8 @@ def test_replicates_one_snapshot_incrementally(self):
159159
)
160160

161161
def test_replicates_siblings_incrementally(self):
162-
src = zfs.TestPoolSet()
163-
dst = zfs.TestPoolSet()
162+
src = TestPoolSet()
163+
dst = TestPoolSet()
164164
src.parse_zfs_r_output(
165165
x('''s 1359351119
166166
s/a 1360136643
@@ -203,8 +203,8 @@ def test_replicates_siblings_incrementally(self):
203203
self.assertEqual(expected, sync.optimize_coalesce(real))
204204

205205
def test_replicates_unequal_siblings(self):
206-
src = zfs.TestPoolSet()
207-
dst = zfs.TestPoolSet()
206+
src = TestPoolSet()
207+
dst = TestPoolSet()
208208
src.parse_zfs_r_output(
209209
x('''s 1359351119
210210
s/a 1360136643
@@ -265,8 +265,8 @@ def test_replicates_unequal_siblings(self):
265265
self.assertEqual(expected_coalesced,real_coalesced)
266266

267267
def test_replicates_recursive_snapshots_with_exceptions(self):
268-
src = zfs.TestPoolSet()
269-
dst = zfs.TestPoolSet()
268+
src = TestPoolSet()
269+
dst = TestPoolSet()
270270
src.parse_zfs_r_output(
271271
x('''s 1359351119
272272
s@1 1363676402
@@ -344,8 +344,8 @@ def test_replicates_recursive_snapshots_with_exceptions(self):
344344
self.assertEqual(expected_coalesced,real_coalesced)
345345

346346
def test_replicates_recursive_but_dest_parent_is_not_snapshotted(self):
347-
src = zfs.TestPoolSet()
348-
dst = zfs.TestPoolSet()
347+
src = TestPoolSet()
348+
dst = TestPoolSet()
349349
src.parse_zfs_r_output(\
350350
x('''s 1359351119
351351
s@1 1363676402
@@ -430,8 +430,8 @@ def test_replicates_recursive_but_dest_parent_is_not_snapshotted(self):
430430
# this test is the problematic one that causes the optimizer to fail when transforming it
431431
# into the recursive replication which shadows unsnapshotted children
432432
def test_replicates_recursive_and_child_of_replicant_has_no_snapshots(self):
433-
src = zfs.TestPoolSet()
434-
dst = zfs.TestPoolSet()
433+
src = TestPoolSet()
434+
dst = TestPoolSet()
435435
src.parse_zfs_r_output(
436436
x('''s 1359351119
437437
s@1 1363676402
@@ -593,8 +593,8 @@ def test_replicates_recursive_and_child_of_replicant_has_no_snapshots(self):
593593
# this test checks no recursivization happens
594594
# for create_stub
595595
def test_replicates_without_recursivizing_stub_creation(self):
596-
src = zfs.TestPoolSet()
597-
dst = zfs.TestPoolSet()
596+
src = TestPoolSet()
597+
dst = TestPoolSet()
598598
src.parse_zfs_r_output(
599599
x('''s 1359351119
600600
s/a 1360136643
@@ -669,8 +669,8 @@ def test_replicates_without_recursivizing_stub_creation(self):
669669

670670
# this test failed horribly, so we port it here for more compliance testing
671671
def test_replicates_complex_datasets(self):
672-
src = zfs.TestPoolSet()
673-
dst = zfs.TestPoolSet()
672+
src = TestPoolSet()
673+
dst = TestPoolSet()
674674
src.parse_zfs_r_output(
675675
x('karen\t1364533579\nkaren@zfs-auto-snap_monthly-2013-05-01-0300\t1367402402\nkaren@zfs-auto-snap_monthly-2013-06-01-0300\t1370080801\nkaren@zfs-auto-snap_monthly-2013-07-01-0300\t1372672801\nkaren@zfs-auto-snap_monthly-2013-08-01-0300\t1375351202\nkaren@zfs-auto-snap_daily-2013-08-24-0300\t1377338402\nkaren@zfs-auto-snap_daily-2013-08-25-0300\t1377424802\nkaren@zfs-auto-snap_daily-2013-08-26-0300\t1377511202\nkaren@zfs-auto-snap_daily-2013-08-27-0300\t1377597603\nkaren@zfs-auto-snap_daily-2013-08-28-0300\t1377684001\nkaren@zfs-auto-snap_daily-2013-08-29-0300\t1377770402\nkaren@zfs-auto-snap_hourly-2013-08-30-0100\t1377824401\nkaren@zfs-auto-snap_hourly-2013-08-30-0700\t1377846003\nkaren@zfs-auto-snap_daily-2013-08-30-1000\t1377856803\nkaren@zfs-auto-snap_hourly-2013-08-30-1300\t1377867602\nkaren@zfs-auto-snap_hourly-2013-08-30-1900\t1377889202\nkaren/ROOT\t1364534686\nkaren/ROOT@zfs-auto-snap_monthly-2013-05-01-0300\t1367402402\nkaren/ROOT@zfs-auto-snap_monthly-2013-06-01-0300\t1370080801\nkaren/ROOT@zfs-auto-snap_monthly-2013-07-01-0300\t1372672801\nkaren/ROOT@zfs-auto-snap_monthly-2013-08-01-0300\t1375351202\nkaren/ROOT@zfs-auto-snap_daily-2013-08-24-0300\t1377338402\nkaren/ROOT@zfs-auto-snap_daily-2013-08-25-0300\t1377424802\nkaren/ROOT@zfs-auto-snap_daily-2013-08-26-0300\t1377511202\nkaren/ROOT@zfs-auto-snap_daily-2013-08-27-0300\t1377597603\nkaren/ROOT@zfs-auto-snap_daily-2013-08-28-0300\t1377684001\nkaren/ROOT@zfs-auto-snap_daily-2013-08-29-0300\t1377770402\nkaren/ROOT@zfs-auto-snap_hourly-2013-08-30-0100\t1377824401\nkaren/ROOT@zfs-auto-snap_hourly-2013-08-30-0700\t1377846003\nkaren/ROOT@zfs-auto-snap_daily-2013-08-30-1000\t1377856803\nkaren/ROOT@zfs-auto-snap_hourly-2013-08-30-1300\t1377867602\nkaren/ROOT@zfs-auto-snap_hourly-2013-08-30-1900\t1377889202\nkaren/ROOT/fedora\t1364534686\nkaren/ROOT/fedora@zfs-auto-snap_monthly-2013-05-01-0300\t1367402402\nkaren/ROOT/fedora@zfs-auto-snap_monthly-2013-06-01-0300\t1370080801\nkaren/ROOT/fedora@zfs-auto-snap_monthly-2013-07-01-0300\t1372672801\nkaren/ROOT/fedora@zfs-auto-snap_monthly-2013-08-01-0300\t1375351202\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-24-0300\t1377338402\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-25-0300\t1377424802\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-26-0300\t1377511202\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-27-0300\t1377597603\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-28-0300\t1377684001\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-29-0300\t1377770402\nkaren/ROOT/fedora@zfs-auto-snap_hourly-2013-08-30-0100\t1377824401\nkaren/ROOT/fedora@zfs-auto-snap_hourly-2013-08-30-0700\t1377846003\nkaren/ROOT/fedora@zfs-auto-snap_daily-2013-08-30-1000\t1377856803\nkaren/ROOT/fedora@zfs-auto-snap_hourly-2013-08-30-1300\t1377867602\nkaren/ROOT/fedora@zfs-auto-snap_hourly-2013-08-30-1900\t1377889202\nkaren/ROOT/fedora/tmp\t1372565849\nkaren/home\t1364534798\nkaren/home@zfs-auto-snap_monthly-2013-05-01-0300\t1367402402\nkaren/home@zfs-auto-snap_monthly-2013-06-01-0300\t1370080801\nkaren/home@zfs-auto-snap_monthly-2013-07-01-0300\t1372672801\nkaren/home@zfs-auto-snap_monthly-2013-08-01-0300\t1375351202\nkaren/home@zfs-auto-snap_daily-2013-08-24-0300\t1377338402\nkaren/home@zfs-auto-snap_daily-2013-08-25-0300\t1377424802\nkaren/home@zfs-auto-snap_daily-2013-08-26-0300\t1377511202\nkaren/home@zfs-auto-snap_daily-2013-08-27-0300\t1377597603\nkaren/home@zfs-auto-snap_daily-2013-08-28-0300\t1377684001\nkaren/home@zfs-auto-snap_daily-2013-08-29-0300\t1377770402\nkaren/home@zfs-auto-snap_hourly-2013-08-30-0100\t1377824401\nkaren/home@zfs-auto-snap_hourly-2013-08-30-0700\t1377846003\nkaren/home@zfs-auto-snap_daily-2013-08-30-1000\t1377856803\nkaren/home@zfs-auto-snap_hourly-2013-08-30-1300\t1377867602\nkaren/home@zfs-auto-snap_hourly-2013-08-30-1900\t1377889202\nkaren/home/mail\t1374752037\nkaren/home/mail@zfs-auto-snap_monthly-2013-08-01-0300\t1375351202\nkaren/home/mail@zfs-auto-snap_daily-2013-08-24-0300\t1377338402\nkaren/home/mail@zfs-auto-snap_daily-2013-08-25-0300\t1377424802\nkaren/home/mail@zfs-auto-snap_daily-2013-08-26-0300\t1377511202\nkaren/home/mail@zfs-auto-snap_daily-2013-08-27-0300\t1377597603\nkaren/home/mail@zfs-auto-snap_daily-2013-08-28-0300\t1377684001\nkaren/home/mail@zfs-auto-snap_daily-2013-08-29-0300\t1377770402\nkaren/home/mail@zfs-auto-snap_hourly-2013-08-30-0100\t1377824401\nkaren/home/mail@zfs-auto-snap_hourly-2013-08-30-0700\t1377846003\nkaren/home/mail@zfs-auto-snap_daily-2013-08-30-1000\t1377856803\nkaren/home/mail@zfs-auto-snap_hourly-2013-08-30-1300\t1377867602\nkaren/home/mail@zfs-auto-snap_hourly-2013-08-30-1900\t1377889202\nkaren/plonezeo\t1364535620\nkaren/plonezeo@zfs-auto-snap_monthly-2013-05-01-0300\t1367402402\nkaren/plonezeo@zfs-auto-snap_monthly-2013-06-01-0300\t1370080801\nkaren/plonezeo@zfs-auto-snap_monthly-2013-07-01-0300\t1372672801\nkaren/plonezeo@zfs-auto-snap_monthly-2013-08-01-0300\t1375351202\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-24-0300\t1377338402\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-25-0300\t1377424802\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-26-0300\t1377511202\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-27-0300\t1377597603\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-28-0300\t1377684001\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-29-0300\t1377770402\nkaren/plonezeo@zfs-auto-snap_hourly-2013-08-30-0100\t1377824401\nkaren/plonezeo@zfs-auto-snap_hourly-2013-08-30-0700\t1377846003\nkaren/plonezeo@zfs-auto-snap_daily-2013-08-30-1000\t1377856803\nkaren/plonezeo@zfs-auto-snap_hourly-2013-08-30-1300\t1377867602\nkaren/plonezeo@zfs-auto-snap_hourly-2013-08-30-1900\t1377889202\nkaren/sekrit\t1371440813\nkaren/sekrit/f-business\t1371456850\nkaren/sekrit/f-proxy\t1371456866\nkaren/sekrit/f-storefront\t1371456856\nkaren/sekrit/f-template\t1371440847\nkaren/sekrit/f-template@initialsetup\t1371456786\nkaren/sekrit/f-tinc\t1371456889\nkaren/sekrit/f-vpn\t1371456860\nkaren/sekrit/f-wallet\t1371456846\nkaren/swap\t1368951906\n')
676676
)
@@ -1080,8 +1080,8 @@ class TestRecursiveClearObsolete(unittest.TestCase):
10801080
maxDiff = None
10811081

10821082
def test_does_nothing(self):
1083-
src = zfs.TestPoolSet()
1084-
dst = zfs.TestPoolSet()
1083+
src = TestPoolSet()
1084+
dst = TestPoolSet()
10851085
src.parse_zfs_r_output(
10861086
x('''karen 1359351119
10871087
karen/ROOT 1359351169
@@ -1107,8 +1107,8 @@ def test_does_nothing(self):
11071107
self.assertFalse(result)
11081108

11091109
def test_clears_nothing(self):
1110-
src = zfs.TestPoolSet()
1111-
dst = zfs.TestPoolSet()
1110+
src = TestPoolSet()
1111+
dst = TestPoolSet()
11121112
src.parse_zfs_r_output(
11131113
x('''karen 1359351119
11141114
karen/ROOT 1359351169
@@ -1135,8 +1135,8 @@ def test_clears_nothing(self):
11351135
self.assertFalse(result)
11361136

11371137
def test_clears_one(self):
1138-
src = zfs.TestPoolSet()
1139-
dst = zfs.TestPoolSet()
1138+
src = TestPoolSet()
1139+
dst = TestPoolSet()
11401140
src.parse_zfs_r_output(
11411141
x('''karen 1359351119
11421142
karen/ROOT 1359351169
@@ -1165,8 +1165,8 @@ def test_clears_one(self):
11651165
self.assertEqual(result[0][1].get_path(), 'target/karen/plonezeo@zfs-auto-snap_hourly-2013-03-19-0000')
11661166

11671167
def test_clears_three(self):
1168-
src = zfs.TestPoolSet()
1169-
dst = zfs.TestPoolSet()
1168+
src = TestPoolSet()
1169+
dst = TestPoolSet()
11701170
src.parse_zfs_r_output(
11711171
x('''karen 1359351119
11721172
karen/ROOT 1359351169
@@ -1206,8 +1206,8 @@ def test_clears_three(self):
12061206
self.assertTrue(p in dsets, "%r could not be found in %r" % (p, dsets))
12071207

12081208
def test_destroys_one_dataset_recursively(self):
1209-
src = zfs.TestPoolSet()
1210-
dst = zfs.TestPoolSet()
1209+
src = TestPoolSet()
1210+
dst = TestPoolSet()
12111211
src.parse_zfs_r_output(
12121212
x('''karen 1359351119
12131213
karen/ROOT 1359351169
@@ -1238,8 +1238,8 @@ def test_destroys_one_dataset_recursively(self):
12381238
)
12391239

12401240
def test_destroys_all_datasets_recursively(self):
1241-
src = zfs.TestPoolSet()
1242-
dst = zfs.TestPoolSet()
1241+
src = TestPoolSet()
1242+
dst = TestPoolSet()
12431243
src.parse_zfs_r_output(
12441244
x('''karen 1359351119
12451245
''')

0 commit comments

Comments
 (0)