2037
@Skip(svntest.main.is_fs_type_fsx)
1845
2038
def recover_old_empty(sbox):
1846
2039
"recover empty --compatible-version=1.3"
1847
svntest.main.safe_rmtree(sbox.repo_dir, 1)
1848
svntest.main.create_repos(sbox.repo_dir, minor_version=3)
1849
svntest.actions.run_and_verify_svnadmin(None, None, [],
2040
sbox.build(create_wc=False, empty=True, minor_version=3)
2041
svntest.actions.run_and_verify_svnadmin(None, [],
1850
2042
"recover", sbox.repo_dir)
1853
2045
@SkipUnless(svntest.main.is_fs_type_fsfs)
2046
def verify_keep_going(sbox):
2047
"svnadmin verify --keep-going test"
2049
sbox.build(create_wc = False)
2050
repo_url = sbox.repo_url
2051
B_url = sbox.repo_url + '/B'
2052
C_url = sbox.repo_url + '/C'
2054
# Create A/B/E/bravo in r2.
2055
svntest.actions.run_and_verify_svn(None, [],
2056
'mkdir', '-m', 'log_msg',
2059
svntest.actions.run_and_verify_svn(None, [],
2060
'mkdir', '-m', 'log_msg',
2063
r2 = fsfs_file(sbox.repo_dir, 'revs', '2')
2064
fp = open(r2, 'r+b')
2065
fp.write("""inserting junk to corrupt the rev""")
2067
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2071
exp_out = svntest.verify.RegexListOutput([".*Verified revision 0.",
2072
".*Verified revision 1.",
2078
".*r3: E160004:.*"])
2080
if (svntest.main.fs_has_rep_sharing()):
2081
exp_out.insert(0, ".*Verifying.*metadata.*")
2083
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2084
"svnadmin: E160004:.*",
2085
"svnadmin: E160004:.*",
2086
".*Error verifying revision 3.",
2087
"svnadmin: E160004:.*",
2088
"svnadmin: E160004:.*",
2089
"svnadmin: E205012:.*"], False)
2091
if (svntest.main.is_fs_log_addressing()):
2092
exp_err.insert(0, ".*Error verifying repository metadata.")
2093
exp_err.insert(1, "svnadmin: E160004:.*")
2095
if svntest.verify.verify_outputs("Unexpected error while running 'svnadmin verify'.",
2096
output, errput, exp_out, exp_err):
2097
raise svntest.Failure
2099
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2102
if (svntest.main.is_fs_log_addressing()):
2103
exp_out = svntest.verify.RegexListOutput([".*Verifying metadata at revision 0"])
2105
exp_out = svntest.verify.RegexListOutput([".*Verified revision 0.",
2106
".*Verified revision 1."])
2107
if (svntest.main.fs_has_rep_sharing()):
2108
exp_out.insert(0, ".*Verifying repository metadata.*")
2110
if (svntest.main.is_fs_log_addressing()):
2111
exp_err = svntest.verify.RegexListOutput([
2112
".*Error verifying repository metadata.",
2113
"svnadmin: E160004:.*"], False)
2115
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2116
"svnadmin: E160004:.*",
2117
"svnadmin: E160004:.*"], False)
2119
if svntest.verify.verify_outputs("Unexpected error while running 'svnadmin verify'.",
2120
output, errput, exp_out, exp_err):
2121
raise svntest.Failure
2124
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2128
if (svntest.main.is_fs_log_addressing()):
2129
exp_err = svntest.verify.RegexListOutput([
2130
".*Error verifying repository metadata.",
2131
"svnadmin: E160004:.*"], False)
2133
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2134
"svnadmin: E160004:.*",
2135
"svnadmin: E160004:.*"], False)
2137
if svntest.verify.verify_outputs("Output of 'svnadmin verify' is unexpected.",
2138
None, errput, None, exp_err):
2139
raise svntest.Failure
2141
# Don't leave a corrupt repository
2142
svntest.main.safe_rmtree(sbox.repo_dir, True)
2145
@SkipUnless(svntest.main.is_fs_type_fsfs)
2146
def verify_keep_going_quiet(sbox):
2147
"svnadmin verify --keep-going --quiet test"
2149
sbox.build(create_wc = False)
2150
repo_url = sbox.repo_url
2151
B_url = sbox.repo_url + '/B'
2152
C_url = sbox.repo_url + '/C'
2154
# Create A/B/E/bravo in r2.
2155
svntest.actions.run_and_verify_svn(None, [],
2156
'mkdir', '-m', 'log_msg',
2159
svntest.actions.run_and_verify_svn(None, [],
2160
'mkdir', '-m', 'log_msg',
2163
r2 = fsfs_file(sbox.repo_dir, 'revs', '2')
2164
fp = open(r2, 'r+b')
2165
fp.write("""inserting junk to corrupt the rev""")
2168
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2173
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2174
"svnadmin: E160004:.*",
2175
"svnadmin: E160004:.*",
2176
".*Error verifying revision 3.",
2177
"svnadmin: E160004:.*",
2178
"svnadmin: E160004:.*",
2179
"svnadmin: E205012:.*"], False)
2181
# Insert another expected error from checksum verification
2182
if (svntest.main.is_fs_log_addressing()):
2183
exp_err.insert(0, ".*Error verifying repository metadata.")
2184
exp_err.insert(1, "svnadmin: E160004:.*")
2186
if svntest.verify.verify_outputs(
2187
"Unexpected error while running 'svnadmin verify'.",
2188
output, errput, None, exp_err):
2189
raise svntest.Failure
2191
# Don't leave a corrupt repository
2192
svntest.main.safe_rmtree(sbox.repo_dir, True)
2195
@SkipUnless(svntest.main.is_fs_type_fsfs)
2196
def verify_invalid_path_changes(sbox):
2197
"detect invalid changed path list entries"
2199
sbox.build(create_wc = False)
2200
repo_url = sbox.repo_url
2202
# Create a number of revisions each adding a single path
2203
for r in range(2,20):
2204
svntest.actions.run_and_verify_svn(None, [],
2205
'mkdir', '-m', 'log_msg',
2206
sbox.repo_url + '/B' + str(r))
2208
# modify every other revision to make sure that errors are not simply
2209
# "carried over" but that all corrupts we get detected independently
2212
set_changed_path_list(sbox, 2,
2213
"_0.0.t1-1 add-dir false false /A\n\n")
2215
# add into non-existent parent
2216
set_changed_path_list(sbox, 4,
2217
"_0.0.t3-2 add-dir false false /C/X\n\n")
2219
# del non-existent node
2220
set_changed_path_list(sbox, 6,
2221
"_0.0.t5-2 delete-dir false false /C\n\n")
2223
# del existent node of the wrong kind
2225
# THIS WILL NOT BE DETECTED
2226
# since dump mechanism and file don't care about the types of deleted nodes
2227
set_changed_path_list(sbox, 8,
2228
"_0.0.t7-2 delete-file false false /B3\n\n")
2230
# copy from non-existent node
2231
set_changed_path_list(sbox, 10,
2232
"_0.0.t9-2 add-dir false false /B10\n"
2235
# copy from existing node of the wrong kind
2236
set_changed_path_list(sbox, 12,
2237
"_0.0.t11-2 add-file false false /B12\n"
2240
# modify non-existent node
2241
set_changed_path_list(sbox, 14,
2242
"_0.0.t13-2 modify-file false false /A/D/H/foo\n\n")
2244
# modify existent node of the wrong kind
2245
set_changed_path_list(sbox, 16,
2246
"_0.0.t15-2 modify-file false false /B12\n\n")
2248
# replace non-existent node
2249
set_changed_path_list(sbox, 18,
2250
"_0.0.t17-2 replace-file false false /A/D/H/foo\n\n")
2253
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2257
exp_out = svntest.verify.RegexListOutput([".*Verified revision 0.",
2258
".*Verified revision 1.",
2259
".*Verified revision 3.",
2260
".*Verified revision 5.",
2261
".*Verified revision 7.",
2262
".*Verified revision 8.",
2263
".*Verified revision 9.",
2264
".*Verified revision 11.",
2265
".*Verified revision 13.",
2266
".*Verified revision 15.",
2267
".*Verified revision 17.",
2268
".*Verified revision 19.",
2276
".*r10: E160013:.*",
2277
".*r10: E160013:.*",
2278
".*r12: E145001:.*",
2279
".*r12: E145001:.*",
2280
".*r14: E160013:.*",
2281
".*r14: E160013:.*",
2282
".*r16: E145001:.*",
2283
".*r16: E145001:.*",
2284
".*r18: E160013:.*",
2285
".*r18: E160013:.*"])
2286
if (svntest.main.fs_has_rep_sharing()):
2287
exp_out.insert(0, ".*Verifying.*metadata.*")
2288
if svntest.main.is_fs_log_addressing():
2289
exp_out.insert(1, ".*Verifying.*metadata.*")
2291
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2292
"svnadmin: E160020:.*",
2293
"svnadmin: E160020:.*",
2294
".*Error verifying revision 4.",
2295
"svnadmin: E160013:.*",
2296
".*Error verifying revision 6.",
2297
"svnadmin: E160013:.*",
2298
"svnadmin: E160013:.*",
2299
".*Error verifying revision 10.",
2300
"svnadmin: E160013:.*",
2301
"svnadmin: E160013:.*",
2302
".*Error verifying revision 12.",
2303
"svnadmin: E145001:.*",
2304
"svnadmin: E145001:.*",
2305
".*Error verifying revision 14.",
2306
"svnadmin: E160013:.*",
2307
"svnadmin: E160013:.*",
2308
".*Error verifying revision 16.",
2309
"svnadmin: E145001:.*",
2310
"svnadmin: E145001:.*",
2311
".*Error verifying revision 18.",
2312
"svnadmin: E160013:.*",
2313
"svnadmin: E160013:.*",
2314
"svnadmin: E205012:.*"], False)
2317
if svntest.verify.verify_outputs("Unexpected error while running 'svnadmin verify'.",
2318
output, errput, exp_out, exp_err):
2319
raise svntest.Failure
2321
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2324
exp_out = svntest.verify.RegexListOutput([".*Verified revision 0.",
2325
".*Verified revision 1."])
2326
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2327
"svnadmin: E160020:.*",
2328
"svnadmin: E160020:.*"], False)
2330
if (svntest.main.fs_has_rep_sharing()):
2331
exp_out.insert(0, ".*Verifying.*metadata.*")
2332
if svntest.main.is_fs_log_addressing():
2333
exp_out.insert(1, ".*Verifying.*metadata.*")
2334
if svntest.verify.verify_outputs("Unexpected error while running 'svnadmin verify'.",
2335
output, errput, exp_out, exp_err):
2336
raise svntest.Failure
2339
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2344
exp_err = svntest.verify.RegexListOutput([".*Error verifying revision 2.",
2345
"svnadmin: E160020:.*",
2346
"svnadmin: E160020:.*"], False)
2348
if svntest.verify.verify_outputs("Output of 'svnadmin verify' is unexpected.",
2349
output, errput, exp_out, exp_err):
2350
raise svntest.Failure
2352
# Don't leave a corrupt repository
2353
svntest.main.safe_rmtree(sbox.repo_dir, True)
2356
def verify_denormalized_names(sbox):
2357
"detect denormalized names and name collisions"
2359
sbox.build(create_wc=False, empty=True)
2361
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
2362
'svnadmin_tests_data',
2363
'normalization_check.dump')
2364
load_dumpstream(sbox, open(dumpfile_location).read())
2366
exit_code, output, errput = svntest.main.run_svnadmin(
2367
"verify", "--check-normalization", sbox.repo_dir)
2369
expected_output_regex_list = [
2370
".*Verified revision 0.",
2371
".*Verified revision 1.",
2372
".*Verified revision 2.",
2373
".*Verified revision 3.",
2374
# A/{Eacute}/{aring}lpha
2375
"WARNING 0x0003: Duplicate representation of path 'A/.*/.*lpha'",
2376
".*Verified revision 4.",
2377
".*Verified revision 5.",
2379
"WARNING 0x0004: Duplicate representation of path '/Q/.*lpha'"
2381
" in svn:mergeinfo property of 'A/.*'",
2382
".*Verified revision 6.",
2383
".*Verified revision 7."]
2385
# The BDB backend doesn't do global metadata verification.
2386
if (svntest.main.fs_has_rep_sharing()):
2387
expected_output_regex_list.insert(0, ".*Verifying repository metadata.*")
2389
if svntest.main.is_fs_log_addressing():
2390
expected_output_regex_list.insert(0, ".* Verifying metadata at revision 0.*")
2392
exp_out = svntest.verify.RegexListOutput(expected_output_regex_list)
2393
exp_err = svntest.verify.ExpectedOutput([])
2395
svntest.verify.verify_outputs(
2396
"Unexpected error while running 'svnadmin verify'.",
2397
output, errput, exp_out, exp_err)
2400
@SkipUnless(svntest.main.is_fs_type_fsfs)
1854
2401
def fsfs_recover_old_non_empty(sbox):
1855
2402
"fsfs recover non-empty --compatible-version=1.3"
1874
2421
sbox.build(create_wc=False, minor_version=3)
1875
2422
backup_dir, backup_url = sbox.add_repo_path('backup')
1876
svntest.actions.run_and_verify_svnadmin(None, None, [], "hotcopy",
1877
sbox.repo_dir, backup_dir)
1879
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2423
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2424
sbox.repo_dir, backup_dir)
2426
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2429
def load_ignore_dates(sbox):
2430
"svnadmin load --ignore-dates"
2432
# All revisions in the loaded repository should come after this time.
2433
start_time = time.localtime()
2436
sbox.build(create_wc=False, empty=True)
2438
dumpfile_skeleton = open(os.path.join(os.path.dirname(sys.argv[0]),
2439
'svnadmin_tests_data',
2440
'skeleton_repos.dump')).read()
2442
load_dumpstream(sbox, dumpfile_skeleton, '--ignore-dates')
2443
svntest.actions.run_and_verify_svnlook(['6\n'],
2444
None, 'youngest', sbox.repo_dir)
2445
for rev in range(1, 6):
2446
exit_code, output, errput = svntest.main.run_svnlook('date', '-r', rev,
2449
raise SVNUnexpectedStderr(errput)
2450
rev_time = time.strptime(output[0].rstrip()[:19], '%Y-%m-%d %H:%M:%S')
2451
if rev_time < start_time:
2452
raise svntest.Failure("Revision time for r%d older than load start time\n"
2455
% (rev, str(rev_time), str(start_time)))
2458
@SkipUnless(svntest.main.is_fs_type_fsfs)
2459
def fsfs_hotcopy_old_with_id_changes(sbox):
2460
"fsfs hotcopy old with node-id and copy-id changes"
2462
# Around trunk@1573728, running 'svnadmin hotcopy' for the
2463
# --compatible-version=1.3 repository with certain node-id and copy-id
2464
# changes ended with mismatching db/current in source and destination:
2466
# source: "2 l 1" destination: "2 k 1",
2470
# We test this case by creating a --compatible-version=1.3 repository
2471
# and committing things that result in node-id and copy-id changes.
2472
# After every commit, we hotcopy the repository to a new destination
2473
# and check whether the source of the backup and the backup itself are
2474
# identical. We also maintain a separate --incremental backup, which
2475
# is updated and checked after every commit.
2476
sbox.build(create_wc=True, minor_version=3)
2478
inc_backup_dir, inc_backup_url = sbox.add_repo_path('incremental-backup')
2480
# r1 = Initial greek tree sandbox.
2481
backup_dir, backup_url = sbox.add_repo_path('backup-after-r1')
2482
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2483
sbox.repo_dir, backup_dir)
2484
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2486
sbox.repo_dir, inc_backup_dir)
2487
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2488
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2490
# r2 = Add a new property.
2491
sbox.simple_propset('foo', 'bar', 'A/mu')
2492
sbox.simple_commit(message='r2')
2494
backup_dir, backup_url = sbox.add_repo_path('backup-after-r2')
2495
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2496
sbox.repo_dir, backup_dir)
2497
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2499
sbox.repo_dir, inc_backup_dir)
2500
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2501
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2504
sbox.simple_copy('A/B/E', 'A/B/E1')
2505
sbox.simple_commit(message='r3')
2507
backup_dir, backup_url = sbox.add_repo_path('backup-after-r3')
2508
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2509
sbox.repo_dir, backup_dir)
2510
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2512
sbox.repo_dir, inc_backup_dir)
2513
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2514
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2516
# r4 = Remove an existing file ...
2517
sbox.simple_rm('A/D/gamma')
2518
sbox.simple_commit(message='r4')
2520
backup_dir, backup_url = sbox.add_repo_path('backup-after-r4')
2521
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2522
sbox.repo_dir, backup_dir)
2523
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2525
sbox.repo_dir, inc_backup_dir)
2526
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2527
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2529
# r5 = ...and replace it with a new file here.
2530
sbox.simple_add_text("This is the replaced file.\n", 'A/D/gamma')
2531
sbox.simple_commit(message='r5')
2533
backup_dir, backup_url = sbox.add_repo_path('backup-after-r5')
2534
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2535
sbox.repo_dir, backup_dir)
2536
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2538
sbox.repo_dir, inc_backup_dir)
2539
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2540
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2542
# r6 = Add an entirely new file.
2543
sbox.simple_add_text('This is an entirely new file.\n', 'A/C/mu1')
2544
sbox.simple_commit(message='r6')
2546
backup_dir, backup_url = sbox.add_repo_path('backup-after-r6')
2547
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2548
sbox.repo_dir, backup_dir)
2549
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2551
sbox.repo_dir, inc_backup_dir)
2552
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2553
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2555
# r7 = Change the content of the existing file (this changeset does
2556
# not bump the next-id and copy-id counters in the repository).
2557
sbox.simple_append('A/mu', 'This is change in the existing file.\n')
2558
sbox.simple_commit(message='r7')
2560
backup_dir, backup_url = sbox.add_repo_path('backup-after-r7')
2561
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2562
sbox.repo_dir, backup_dir)
2563
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2565
sbox.repo_dir, inc_backup_dir)
2566
check_hotcopy_fsfs(sbox.repo_dir, backup_dir)
2567
check_hotcopy_fsfs(sbox.repo_dir, inc_backup_dir)
2570
@SkipUnless(svntest.main.fs_has_pack)
2571
def verify_packed(sbox):
2572
"verify packed with small shards"
2574
# Configure two files per shard to trigger packing.
2576
patch_format(sbox.repo_dir, shard_size=2)
2578
# Play with our greek tree. These changesets fall into two
2579
# separate shards with r2 and r3 being in shard 1 ...
2580
sbox.simple_append('iota', "Line.\n")
2581
sbox.simple_append('A/D/gamma', "Another line.\n")
2582
sbox.simple_commit(message='r2')
2583
sbox.simple_propset('foo', 'bar', 'iota')
2584
sbox.simple_propset('foo', 'baz', 'A/mu')
2585
sbox.simple_commit(message='r3')
2587
# ...and r4 and r5 being in shard 2.
2588
sbox.simple_rm('A/C')
2589
sbox.simple_copy('A/B/E', 'A/B/E1')
2590
sbox.simple_move('A/mu', 'A/B/mu')
2591
sbox.simple_commit(message='r4')
2592
sbox.simple_propdel('foo', 'A/B/mu')
2593
sbox.simple_commit(message='r5')
2595
if svntest.main.is_fs_type_fsfs and svntest.main.options.fsfs_packing:
2596
# With --fsfs-packing, everything is already packed and we
2597
# can skip this part.
2600
expected_output = ["Packing revisions in shard 0...done.\n",
2601
"Packing revisions in shard 1...done.\n",
2602
"Packing revisions in shard 2...done.\n"]
2603
svntest.actions.run_and_verify_svnadmin(expected_output, [],
2604
"pack", sbox.repo_dir)
2606
if svntest.main.is_fs_log_addressing():
2607
expected_output = ["* Verifying metadata at revision 0 ...\n",
2608
"* Verifying metadata at revision 2 ...\n",
2609
"* Verifying metadata at revision 4 ...\n",
2610
"* Verifying repository metadata ...\n",
2611
"* Verified revision 0.\n",
2612
"* Verified revision 1.\n",
2613
"* Verified revision 2.\n",
2614
"* Verified revision 3.\n",
2615
"* Verified revision 4.\n",
2616
"* Verified revision 5.\n"]
2618
expected_output = ["* Verifying repository metadata ...\n",
2619
"* Verified revision 0.\n",
2620
"* Verified revision 1.\n",
2621
"* Verified revision 2.\n",
2622
"* Verified revision 3.\n",
2623
"* Verified revision 4.\n",
2624
"* Verified revision 5.\n"]
2626
svntest.actions.run_and_verify_svnadmin(expected_output, [],
2627
"verify", sbox.repo_dir)
2629
# Test that 'svnadmin freeze' is nestable. (For example, this ensures it
2630
# won't take system-global locks, only repository-scoped ones.)
2632
# This could be useful to easily freeze a small number of repositories at once.
2634
# ### We don't actually test that freeze takes a write lock anywhere (not even
2636
def freeze_freeze(sbox):
2637
"svnadmin freeze svnadmin freeze (some-cmd)"
2639
sbox.build(create_wc=False, read_only=True)
2640
second_repo_dir, _ = sbox.add_repo_path('backup')
2641
svntest.actions.run_and_verify_svnadmin(None, [], "hotcopy",
2642
sbox.repo_dir, second_repo_dir)
2644
if svntest.main.is_fs_type_fsx() or \
2645
(svntest.main.is_fs_type_fsfs() and \
2646
svntest.main.options.server_minor_version < 9):
2647
# FSFS repositories created with --compatible-version=1.8 and less
2648
# erroneously share the filesystem data (locks, shared transaction
2649
# data, ...) between hotcopy source and destination. This is fixed
2650
# for new FS formats, but in order to avoid a deadlock for old formats,
2651
# we have to manually assign a new UUID for the hotcopy destination.
2652
# As of trunk@1618024, the same applies to FSX repositories.
2653
svntest.actions.run_and_verify_svnadmin([], None,
2654
'setuuid', second_repo_dir)
2656
svntest.actions.run_and_verify_svnadmin(None, [],
2657
'freeze', '--', sbox.repo_dir,
2658
svntest.main.svnadmin_binary, 'freeze', '--', second_repo_dir,
2659
sys.executable, '-c', 'True')
2661
arg_file = sbox.get_tempname()
2662
svntest.main.file_write(arg_file,
2663
"%s\n%s\n" % (sbox.repo_dir, second_repo_dir))
2665
svntest.actions.run_and_verify_svnadmin(None, [],
2666
'freeze', '-F', arg_file, '--',
2667
sys.executable, '-c', 'True')
2669
def verify_metadata_only(sbox):
2670
"verify metadata only"
2672
sbox.build(create_wc = False)
2673
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2677
raise SVNUnexpectedStderr(errput)
2679
# Unfortunately, older formats won't test as thoroughly than newer ones
2680
# resulting in different progress output. BDB will do a full check but
2681
# not produce any output.
2682
if svntest.main.is_fs_log_addressing():
2683
svntest.verify.compare_and_display_lines(
2684
"Unexpected error while running 'svnadmin verify'.",
2685
'STDOUT', ["* Verifying metadata at revision 0 ...\n",
2686
"* Verifying repository metadata ...\n"], output)
2687
elif svntest.main.fs_has_rep_sharing() \
2688
and not svntest.main.is_fs_type_bdb():
2689
svntest.verify.compare_and_display_lines(
2690
"Unexpected error while running 'svnadmin verify'.",
2691
'STDOUT', ["* Verifying repository metadata ...\n"], output)
2693
svntest.verify.compare_and_display_lines(
2694
"Unexpected error while running 'svnadmin verify'.",
2695
'STDOUT', [], output)
2698
@Skip(svntest.main.is_fs_type_bdb)
2699
def verify_quickly(sbox):
2700
"verify quickly using metadata"
2702
sbox.build(create_wc = False)
2703
rev_file = open(fsfs_file(sbox.repo_dir, 'revs', '1'), 'r+b')
2710
exit_code, output, errput = svntest.main.run_svnadmin("verify",
2714
# unfortunately, some backends needs to do more checks than other
2715
# resulting in different progress output
2716
if svntest.main.is_fs_log_addressing():
2717
exp_out = svntest.verify.RegexListOutput([])
2718
exp_err = svntest.verify.RegexListOutput(["svnadmin: E160004:.*"], False)
2720
exp_out = svntest.verify.RegexListOutput([])
2721
exp_err = svntest.verify.RegexListOutput([])
2723
if (svntest.main.fs_has_rep_sharing()):
2724
exp_out.insert(0, ".*Verifying.*metadata.*")
2725
if svntest.verify.verify_outputs("Unexpected error while running 'svnadmin verify'.",
2726
output, errput, exp_out, exp_err):
2727
raise svntest.Failure
2729
# Don't leave a corrupt repository
2730
svntest.main.safe_rmtree(sbox.repo_dir, True)
2733
@SkipUnless(svntest.main.is_fs_type_fsfs)
2734
@SkipUnless(svntest.main.fs_has_pack)
2735
def fsfs_hotcopy_progress(sbox):
2736
"hotcopy progress reporting"
2738
# Check how 'svnadmin hotcopy' reports progress for non-incremental
2739
# and incremental scenarios. The progress output can be affected by
2740
# the --fsfs-packing option, so skip the test if that is the case.
2741
if svntest.main.options.fsfs_packing:
2744
# Create an empty repository, configure three files per shard.
2745
sbox.build(create_wc=False, empty=True)
2746
patch_format(sbox.repo_dir, shard_size=3)
2748
inc_backup_dir, inc_backup_url = sbox.add_repo_path('incremental-backup')
2750
# Nothing really exciting for the empty repository.
2752
"* Copied revision 0.\n"
2754
expected_incremental = [
2755
"* Copied revision 0.\n",
2758
backup_dir, backup_url = sbox.add_repo_path('backup-0')
2759
svntest.actions.run_and_verify_svnadmin(expected_full, [],
2761
sbox.repo_dir, backup_dir)
2762
svntest.actions.run_and_verify_svnadmin(expected_incremental, [],
2763
'hotcopy', '--incremental',
2764
sbox.repo_dir, inc_backup_dir)
2766
# Commit three revisions. After this step we have a full shard
2767
# (r0, r1, r2) and the second shard (r3) with a single revision.
2769
svntest.actions.run_and_verify_svn(None, [], 'mkdir',
2770
'-m', svntest.main.make_log_msg(),
2771
sbox.repo_url + '/dir-%i' % i)
2773
"* Copied revision 0.\n",
2774
"* Copied revision 1.\n",
2775
"* Copied revision 2.\n",
2776
"* Copied revision 3.\n",
2778
expected_incremental = [
2779
"* Copied revision 1.\n",
2780
"* Copied revision 2.\n",
2781
"* Copied revision 3.\n",
2784
backup_dir, backup_url = sbox.add_repo_path('backup-1')
2785
svntest.actions.run_and_verify_svnadmin(expected_full, [],
2787
sbox.repo_dir, backup_dir)
2788
svntest.actions.run_and_verify_svnadmin(expected_incremental, [],
2789
'hotcopy', '--incremental',
2790
sbox.repo_dir, inc_backup_dir)
2792
# Pack everything (r3 is still unpacked) and hotcopy again. In this case,
2793
# the --incremental output should track the incoming (r0, r1, r2) pack and
2794
# should not mention r3, because it is already a part of the destination
2795
# and is *not* a part of the incoming pack.
2796
svntest.actions.run_and_verify_svnadmin(None, [], 'pack',
2799
"* Copied revisions from 0 to 2.\n",
2800
"* Copied revision 3.\n",
2802
expected_incremental = [
2803
"* Copied revisions from 0 to 2.\n",
2806
backup_dir, backup_url = sbox.add_repo_path('backup-2')
2807
svntest.actions.run_and_verify_svnadmin(expected_full, [],
2809
sbox.repo_dir, backup_dir)
2810
svntest.actions.run_and_verify_svnadmin(expected_incremental, [],
2811
'hotcopy', '--incremental',
2812
sbox.repo_dir, inc_backup_dir)
2814
# Fill the second shard, pack again, commit several unpacked revisions
2815
# on top of it. Rerun the hotcopy and check the progress output.
2816
for i in range(4, 6):
2817
svntest.actions.run_and_verify_svn(None, [], 'mkdir',
2818
'-m', svntest.main.make_log_msg(),
2819
sbox.repo_url + '/dir-%i' % i)
2821
svntest.actions.run_and_verify_svnadmin(None, [], 'pack',
2824
for i in range(6, 8):
2825
svntest.actions.run_and_verify_svn(None, [], 'mkdir',
2826
'-m', svntest.main.make_log_msg(),
2827
sbox.repo_url + '/dir-%i' % i)
2829
"* Copied revisions from 0 to 2.\n",
2830
"* Copied revisions from 3 to 5.\n",
2831
"* Copied revision 6.\n",
2832
"* Copied revision 7.\n",
2834
expected_incremental = [
2835
"* Copied revisions from 3 to 5.\n",
2836
"* Copied revision 6.\n",
2837
"* Copied revision 7.\n",
2840
backup_dir, backup_url = sbox.add_repo_path('backup-3')
2841
svntest.actions.run_and_verify_svnadmin(expected_full, [],
2843
sbox.repo_dir, backup_dir)
2844
svntest.actions.run_and_verify_svnadmin(expected_incremental, [],
2845
'hotcopy', '--incremental',
2846
sbox.repo_dir, inc_backup_dir)
2849
@SkipUnless(svntest.main.is_fs_type_fsfs)
2850
def fsfs_hotcopy_progress_with_revprop_changes(sbox):
2851
"incremental hotcopy progress with changed revprops"
2853
# The progress output can be affected by the --fsfs-packing
2854
# option, so skip the test if that is the case.
2855
if svntest.main.options.fsfs_packing:
2858
# Create an empty repository, commit several revisions and hotcopy it.
2859
sbox.build(create_wc=False, empty=True)
2862
svntest.actions.run_and_verify_svn(None, [], 'mkdir',
2863
'-m', svntest.main.make_log_msg(),
2864
sbox.repo_url + '/dir-%i' % i)
2866
"* Copied revision 0.\n",
2867
"* Copied revision 1.\n",
2868
"* Copied revision 2.\n",
2869
"* Copied revision 3.\n",
2870
"* Copied revision 4.\n",
2871
"* Copied revision 5.\n",
2872
"* Copied revision 6.\n",
2875
backup_dir, backup_url = sbox.add_repo_path('backup')
2876
svntest.actions.run_and_verify_svnadmin(expected_output, [],
2878
sbox.repo_dir, backup_dir)
2880
# Amend a few log messages in the source, run the --incremental hotcopy.
2881
# The progress output should only mention the corresponding revisions.
2882
revprop_file = sbox.get_tempname()
2883
svntest.main.file_write(revprop_file, "Modified log message.")
2886
svntest.actions.run_and_verify_svnadmin(None, [],
2888
sbox.repo_dir, '-r', i,
2889
'svn:log', revprop_file)
2891
"* Copied revision 1.\n",
2892
"* Copied revision 3.\n",
2893
"* Copied revision 6.\n",
2895
svntest.actions.run_and_verify_svnadmin(expected_output, [],
2896
'hotcopy', '--incremental',
2897
sbox.repo_dir, backup_dir)
2900
@SkipUnless(svntest.main.is_fs_type_fsfs)
2901
def fsfs_hotcopy_progress_old(sbox):
2902
"hotcopy --compatible-version=1.3 progress"
2904
sbox.build(create_wc=False, empty=True, minor_version=3)
2906
inc_backup_dir, inc_backup_url = sbox.add_repo_path('incremental-backup')
2908
# Nothing really exciting for the empty repository.
2910
"* Copied revision 0.\n"
2912
expected_incremental = [
2913
"* Copied revision 0.\n",
2916
backup_dir, backup_url = sbox.add_repo_path('backup-0')
2917
svntest.actions.run_and_verify_svnadmin(expected_full, [],
2919
sbox.repo_dir, backup_dir)
2920
svntest.actions.run_and_verify_svnadmin(expected_incremental, [],
2921
'hotcopy', '--incremental',
2922
sbox.repo_dir, inc_backup_dir)
2924
# Commit three revisions, hotcopy and check the progress output.
2926
svntest.actions.run_and_verify_svn(None, [], 'mkdir',
2927
'-m', svntest.main.make_log_msg(),
2928
sbox.repo_url + '/dir-%i' % i)
2931
"* Copied revision 0.\n",
2932
"* Copied revision 1.\n",
2933
"* Copied revision 2.\n",
2934
"* Copied revision 3.\n",
2936
expected_incremental = [
2937
"* Copied revision 1.\n",
2938
"* Copied revision 2.\n",
2939
"* Copied revision 3.\n",
2942
backup_dir, backup_url = sbox.add_repo_path('backup-1')
2943
svntest.actions.run_and_verify_svnadmin(expected_full, [],
2945
sbox.repo_dir, backup_dir)
2946
svntest.actions.run_and_verify_svnadmin(expected_incremental, [],
2947
'hotcopy', '--incremental',
2948
sbox.repo_dir, inc_backup_dir)
2951
@SkipUnless(svntest.main.fs_has_unique_freeze)
2952
def freeze_same_uuid(sbox):
2953
"freeze multiple repositories with same UUID"
2955
sbox.build(create_wc=False)
2957
first_repo_dir, _ = sbox.add_repo_path('first')
2958
second_repo_dir, _ = sbox.add_repo_path('second')
2960
# Test that 'svnadmin freeze A (svnadmin freeze B)' does not deadlock for
2961
# new FSFS formats, even if 'A' and 'B' share the same UUID. Create two
2962
# repositories by loading the same dump file, ...
2963
svntest.main.create_repos(first_repo_dir)
2964
svntest.main.create_repos(second_repo_dir)
2966
dump_path = os.path.join(os.path.dirname(sys.argv[0]),
2967
'svnadmin_tests_data',
2968
'skeleton_repos.dump')
2969
dump_contents = open(dump_path, 'rb').readlines()
2970
svntest.actions.run_and_verify_load(first_repo_dir, dump_contents)
2971
svntest.actions.run_and_verify_load(second_repo_dir, dump_contents)
2973
# ...and execute the 'svnadmin freeze -F' command.
2974
arg_file = sbox.get_tempname()
2975
svntest.main.file_write(arg_file,
2976
"%s\n%s\n" % (first_repo_dir, second_repo_dir))
2978
svntest.actions.run_and_verify_svnadmin(None, None,
2979
'freeze', '-F', arg_file, '--',
2980
sys.executable, '-c', 'True')
2983
@Skip(svntest.main.is_fs_type_fsx)
2985
"upgrade --compatible-version=1.3"
2987
sbox.build(create_wc=False, minor_version=3)
2988
svntest.actions.run_and_verify_svnadmin(None, [], "upgrade",
2990
# Does the repository work after upgrade?
2991
svntest.actions.run_and_verify_svn(['Committing transaction...\n',
2992
'Committed revision 2.\n'], [], 'mkdir',
2993
'-m', svntest.main.make_log_msg(),
2994
sbox.repo_url + '/dir')
2996
def load_txdelta(sbox):
2997
"exercising svn_txdelta_target on BDB"
2999
sbox.build(empty=True)
3001
# This dumpfile produced a BDB repository that generated cheksum
3002
# mismatches on read caused by the improper handling of
3003
# svn_txdelta_target ops. The bug was fixed by r1640832.
3005
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
3006
'svnadmin_tests_data',
3007
'load_txdelta.dump.gz')
3008
dumpfile = gzip.open(dumpfile_location).read()
3010
load_dumpstream(sbox, dumpfile)
3012
# Verify would fail with a checksum mismatch:
3013
# * Error verifying revision 14.
3014
# svnadmin: E200014: MD5 checksum mismatch on representation 'r':
3015
# expected: 5182e8876ed894dc7fe28f6ff5b2fee6
3016
# actual: 5121f82875508863ad70daa8244e6947
3018
exit_code, output, errput = svntest.main.run_svnadmin("verify", sbox.repo_dir)
3020
raise SVNUnexpectedStderr(errput)
3021
if svntest.verify.verify_outputs(
3022
"Output of 'svnadmin verify' is unexpected.", None, output, None,
3023
".*Verified revision *"):
3024
raise svntest.Failure
3027
def load_no_svndate_r0(sbox):
3028
"load without svn:date on r0"
3030
sbox.build(create_wc=False, empty=True)
3033
svntest.actions.run_and_verify_svnlook([' svn:date\n'], [],
3034
'proplist', '--revprop', '-r0',
3037
dump_old = ["SVN-fs-dump-format-version: 2\n", "\n",
3038
"UUID: bf52886d-358d-4493-a414-944a6e5ad4f5\n", "\n",
3039
"Revision-number: 0\n",
3040
"Prop-content-length: 10\n",
3041
"Content-length: 10\n", "\n",
3042
"PROPS-END\n", "\n"]
3043
svntest.actions.run_and_verify_load(sbox.repo_dir, dump_old)
3045
# svn:date should have been removed
3046
svntest.actions.run_and_verify_svnlook([], [],
3047
'proplist', '--revprop', '-r0',
3050
# This is only supported for FSFS
3051
# The port to FSX is still pending, BDB won't support it.
3052
@SkipUnless(svntest.main.is_fs_type_fsfs)
3053
def hotcopy_read_only(sbox):
3054
"'svnadmin hotcopy' a read-only source repository"
3056
svntest.main.chmod_tree(sbox.repo_dir, 0, 0222)
3058
backup_dir, backup_url = sbox.add_repo_path('backup')
3059
exit_code, output, errput = svntest.main.run_svnadmin("hotcopy",
3063
# r/o repos are hard to clean up. Make it writable again.
3064
svntest.main.chmod_tree(sbox.repo_dir, 0222, 0222)
3066
logger.warn("Error: hotcopy failed")
3067
raise SVNUnexpectedStderr(errput)
1882
3069
########################################################################
1883
3070
# Run the tests