~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/tests/cmdline/svnrdump_tests.py

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
from svntest.verify import SVNExpectedStderr
35
35
from svntest.main import write_restrictive_svnserve_conf
36
36
from svntest.main import server_has_partial_replay
37
 
from svnadmin_tests import test_create
38
37
 
39
38
# (abbreviation)
40
39
Skip = svntest.testcase.Skip_deco
61
60
######################################################################
62
61
# Helper routines
63
62
 
64
 
def build_repos(sbox):
65
 
  """Build an empty sandbox repository"""
66
 
 
67
 
  # Cleanup after the last run by removing any left-over repository.
68
 
  svntest.main.safe_rmtree(sbox.repo_dir)
69
 
 
70
 
  # Create an empty repository.
71
 
  svntest.main.create_repos(sbox.repo_dir)
72
 
 
73
 
def compare_repos_dumps(svnrdump_sbox, svnadmin_dumpfile):
74
 
  """Compare two dumpfiles, one created from SVNRDUMP_SBOX, and other given
75
 
  by SVNADMIN_DUMPFILE.  The dumpfiles do not need to match linewise, as the
76
 
  SVNADMIN_DUMPFILE contents will first be loaded into a repository and then
 
63
def compare_repos_dumps(sbox, other_dumpfile,
 
64
                        bypass_prop_validation=False):
 
65
  """Compare two dumpfiles, one created from SBOX, and other given
 
66
  by OTHER_DUMPFILE.  The dumpfiles do not need to match linewise, as the
 
67
  OTHER_DUMPFILE contents will first be loaded into a repository and then
77
68
  re-dumped to do the match, which should generate the same dumpfile as
78
 
  dumping SVNRDUMP_SBOX."""
79
 
 
80
 
  svnrdump_contents = svntest.actions.run_and_verify_dump(
81
 
                                                    svnrdump_sbox.repo_dir)
82
 
 
83
 
  svnadmin_sbox = svnrdump_sbox.clone_dependent()
84
 
  svntest.main.safe_rmtree(svnadmin_sbox.repo_dir)
85
 
  svntest.main.create_repos(svnadmin_sbox.repo_dir)
86
 
 
87
 
  svntest.actions.run_and_verify_load(svnadmin_sbox.repo_dir, svnadmin_dumpfile)
88
 
 
89
 
  svnadmin_contents = svntest.actions.run_and_verify_dump(
90
 
                                                    svnadmin_sbox.repo_dir)
91
 
 
 
69
  dumping SBOX."""
 
70
 
 
71
 
 
72
  sbox_dumpfile = svntest.actions.run_and_verify_dump(sbox.repo_dir)
 
73
 
 
74
  # Load and dump the other dumpfile (using svnadmin)
 
75
  other_sbox = sbox.clone_dependent()
 
76
  other_sbox.build(create_wc=False, empty=True)
 
77
  svntest.actions.run_and_verify_load(other_sbox.repo_dir, other_dumpfile,
 
78
                                      bypass_prop_validation)
 
79
  other_dumpfile = svntest.actions.run_and_verify_dump(other_sbox.repo_dir)
 
80
 
 
81
  ### This call kind-of assumes EXPECTED is first and ACTUAL is second.
92
82
  svntest.verify.compare_dump_files(
93
 
    "Dump files", "DUMP", svnadmin_contents, svnrdump_contents)
 
83
    "Dump files", "DUMP", other_dumpfile, sbox_dumpfile)
94
84
 
95
85
def run_dump_test(sbox, dumpfile_name, expected_dumpfile_name = None,
96
86
                  subdir = None, bypass_prop_validation = False,
103
93
  array of optional additional options to pass to 'svnrdump dump'."""
104
94
 
105
95
  # Create an empty sandbox repository
106
 
  build_repos(sbox)
 
96
  sbox.build(create_wc=False, empty=True)
107
97
 
108
98
  # This directory contains all the dump files
109
99
  svnrdump_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
111
101
 
112
102
  # Load the specified dump file into the sbox repository using
113
103
  # svnadmin load
114
 
  svnadmin_dumpfile = open(os.path.join(svnrdump_tests_dir,
 
104
  original_dumpfile = open(os.path.join(svnrdump_tests_dir,
115
105
                                        dumpfile_name),
116
106
                           'rb').readlines()
117
 
 
118
 
  svntest.actions.run_and_verify_load(sbox.repo_dir, svnadmin_dumpfile,
 
107
  svntest.actions.run_and_verify_load(sbox.repo_dir, original_dumpfile,
119
108
                                      bypass_prop_validation)
120
109
 
121
110
  repo_url = sbox.repo_url
129
118
                                              [], 0, *opts)
130
119
 
131
120
  if expected_dumpfile_name:
132
 
    svnadmin_dumpfile = open(os.path.join(svnrdump_tests_dir,
 
121
    expected_dumpfile = open(os.path.join(svnrdump_tests_dir,
133
122
                                          expected_dumpfile_name),
134
123
                             'rb').readlines()
135
124
    # Compare the output from stdout
136
125
    if ignore_base_checksums:
137
 
      svnadmin_dumpfile = [l for l in svnadmin_dumpfile
 
126
      expected_dumpfile = [l for l in expected_dumpfile
138
127
                                    if not l.startswith('Text-delta-base-md5')]
139
128
      svnrdump_dumpfile = [l for l in svnrdump_dumpfile
140
129
                                    if not l.startswith('Text-delta-base-md5')]
141
 
    svnadmin_dumpfile = [l for l in svnadmin_dumpfile
 
130
    expected_dumpfile = [l for l in expected_dumpfile
142
131
                                  if not mismatched_headers_re.match(l)]
143
132
    svnrdump_dumpfile = [l for l in svnrdump_dumpfile
144
133
                                  if not mismatched_headers_re.match(l)]
145
134
 
146
 
    svnadmin_dumpfile = svntest.verify.UnorderedOutput(svnadmin_dumpfile)
 
135
    expected_dumpfile = svntest.verify.UnorderedOutput(expected_dumpfile)
147
136
 
148
137
    svntest.verify.compare_and_display_lines(
149
 
      "Dump files", "DUMP", svnadmin_dumpfile, svnrdump_dumpfile,
 
138
      "Dump files", "DUMP", expected_dumpfile, svnrdump_dumpfile,
150
139
      None)
151
140
 
152
141
  else:
153
 
    compare_repos_dumps(sbox, svnadmin_dumpfile)
 
142
    # The expected dumpfile is the result of dumping SBOX.
 
143
    compare_repos_dumps(sbox, svnrdump_dumpfile, bypass_prop_validation)
154
144
 
155
145
def run_load_test(sbox, dumpfile_name, expected_dumpfile_name = None,
156
146
                  expect_deltas = True):
158
148
  dump' and check that the same dumpfile is produced"""
159
149
 
160
150
  # Create an empty sandbox repository
161
 
  build_repos(sbox)
 
151
  sbox.build(create_wc=False, empty=True)
162
152
 
163
153
  # Create the revprop-change hook for this test
164
154
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
169
159
 
170
160
  # Load the specified dump file into the sbox repository using
171
161
  # svnrdump load
172
 
  svnrdump_dumpfile = open(os.path.join(svnrdump_tests_dir,
 
162
  original_dumpfile = open(os.path.join(svnrdump_tests_dir,
173
163
                                        dumpfile_name),
174
164
                           'rb').readlines()
175
165
 
176
166
  # Set the UUID of the sbox repository to the UUID specified in the
177
167
  # dumpfile ### RA layer doesn't have a set_uuid functionality
178
 
  uuid = svnrdump_dumpfile[2].split(' ')[1][:-1]
179
 
  svntest.actions.run_and_verify_svnadmin2("Setting UUID", None, None, 0,
 
168
  uuid = original_dumpfile[2].split(' ')[1][:-1]
 
169
  svntest.actions.run_and_verify_svnadmin2(None, None, 0,
180
170
                                           'setuuid', sbox.repo_dir,
181
171
                                           uuid)
182
172
 
183
 
  svntest.actions.run_and_verify_svnrdump(svnrdump_dumpfile,
 
173
  svntest.actions.run_and_verify_svnrdump(original_dumpfile,
184
174
                                          svntest.verify.AnyOutput,
185
175
                                          [], 0, 'load', sbox.repo_url)
186
176
 
187
 
  # Create a dump file using svnadmin dump
188
 
  svnadmin_dumpfile = svntest.actions.run_and_verify_dump(sbox.repo_dir,
 
177
  # Re-dump the rdump-loaded repo using svnadmin dump
 
178
  resulted_dumpfile = svntest.actions.run_and_verify_dump(sbox.repo_dir,
189
179
                                                          expect_deltas)
190
180
 
191
181
  if expected_dumpfile_name:
192
 
    svnrdump_dumpfile = open(os.path.join(svnrdump_tests_dir,
 
182
    expected_dumpfile = open(os.path.join(svnrdump_tests_dir,
193
183
                                          expected_dumpfile_name),
194
184
                             'rb').readlines()
195
185
 
196
186
    # Compare the output from stdout
197
187
    svntest.verify.compare_and_display_lines(
198
 
      "Dump files", "DUMP", svnrdump_dumpfile, svnadmin_dumpfile)
 
188
      "Dump files", "DUMP", expected_dumpfile, resulted_dumpfile)
199
189
 
200
190
  else:
201
 
    compare_repos_dumps(sbox, svnrdump_dumpfile)
 
191
    expected_dumpfile = original_dumpfile
 
192
    compare_repos_dumps(sbox, expected_dumpfile)
202
193
 
203
194
######################################################################
204
195
# Tests
410
401
  "svnrdump renumbers dropped revs in mergeinfo"
411
402
 
412
403
  # Create an empty sandbox repository
413
 
  build_repos(sbox)
 
404
  sbox.build(create_wc=False, empty=True)
414
405
 
415
406
  # Create the revprop-change hook for this test
416
407
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
431
422
 
432
423
  # Create the 'toplevel' directory in repository and then load the same
433
424
  # dumpfile into that subtree.
434
 
  svntest.actions.run_and_verify_svn(None, ['\n', 'Committed revision 10.\n'],
 
425
  svntest.actions.run_and_verify_svn(['Committing transaction...\n',
 
426
                                            'Committed revision 10.\n'],
435
427
                                    [], "mkdir", sbox.repo_url + "/toplevel",
436
428
                                     "-m", "Create toplevel dir to load into")
437
429
  svntest.actions.run_and_verify_svnrdump(svnrdump_dumpfile,
444
436
    url + "/trunk - /branch1:4-8\n",
445
437
    url + "/toplevel/trunk - /toplevel/branch1:14-18\n",
446
438
    ])
447
 
  svntest.actions.run_and_verify_svn(None, expected_output, [],
 
439
  svntest.actions.run_and_verify_svn(expected_output, [],
448
440
                                     'propget', 'svn:mergeinfo', '-R',
449
441
                                     sbox.repo_url)
450
442
 
473
465
  "don't drop mergeinfo revs in incremental svnrdump"
474
466
 
475
467
  # Create an empty repos.
476
 
  test_create(sbox)
 
468
  sbox.build(empty=True)
477
469
 
478
470
  # Create the revprop-change hook for this test
479
471
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
488
480
  #                      |            |                            |     |
489
481
  # trunk---r2---r3-----r5---r6-------r8---r9--------------->      |     |
490
482
  #   r1             |        |     |       |                      |     |
491
 
  # intial           |        |     |       |______                |     |
 
483
  # initial          |        |     |       |______                |     |
492
484
  # import         copy       |   copy             |            merge   merge
493
485
  #                  |        |     |            merge           (r5)   (r8)
494
486
  #                  |        |     |            (r9)              |     |
542
534
    url + "B2 - /trunk:9\n",
543
535
    url + "B1/B/E - /branches/B2/B/E:11-12\n",
544
536
    "/trunk/B/E:5-6,8-9\n"])
545
 
  svntest.actions.run_and_verify_svn(None, expected_output, [],
 
537
  svntest.actions.run_and_verify_svn(expected_output, [],
546
538
                                     'propget', 'svn:mergeinfo', '-R',
547
539
                                     sbox.repo_url)
548
540
 
579
571
  dump_fp.close()
580
572
 
581
573
  # Blow away the current repos and create an empty one in its place.
582
 
  test_create(sbox)
 
574
  svntest.main.safe_rmtree(sbox.repo_dir, True) # Fix race with bdb in svnserve
 
575
  sbox.build(empty=True)
583
576
 
584
577
  # Create the revprop-change hook for this test
585
578
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
604
597
  # Check the mergeinfo, we use the same expected output as before,
605
598
  # as it (duh!) should be exactly the same as when we loaded the
606
599
  # repos in one shot.
607
 
  svntest.actions.run_and_verify_svn(None, expected_output, [],
 
600
  svntest.actions.run_and_verify_svn(expected_output, [],
608
601
                                     'propget', 'svn:mergeinfo', '-R',
609
602
                                     sbox.repo_url)
610
603
 
614
607
  # PART 3: Load a full dump to an non-empty repository.
615
608
  #
616
609
  # Reset our sandbox.
617
 
  test_create(sbox)
 
610
  svntest.main.safe_rmtree(sbox.repo_dir, True) # Fix race with bdb in svnserve
 
611
  sbox.build(empty=True)
618
612
 
619
613
  # Create the revprop-change hook for this test
620
614
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
668
662
    url + "B2 - /Projects/Project-X/trunk:15\n",
669
663
    url + "B1/B/E - /Projects/Project-X/branches/B2/B/E:17-18\n",
670
664
    "/Projects/Project-X/trunk/B/E:11-12,14-15\n"])
671
 
  svntest.actions.run_and_verify_svn(None, expected_output, [],
 
665
  svntest.actions.run_and_verify_svn(expected_output, [],
672
666
                                     'propget', 'svn:mergeinfo', '-R',
673
667
                                     sbox.repo_url)
674
668
 
675
669
  # PART 4: Load a a series of incremental dumps to an non-empty repository.
676
670
  #
677
671
  # Reset our sandbox.
678
 
  test_create(sbox)
 
672
  svntest.main.safe_rmtree(sbox.repo_dir, True) # Fix race with bdb in svnserve
 
673
  sbox.build(empty=True)
679
674
 
680
675
  # Create the revprop-change hook for this test
681
676
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
710
705
  # Check the resulting mergeinfo.  We expect the exact same results
711
706
  # as Part 3.
712
707
  # See http://subversion.tigris.org/issues/show_bug.cgi?id=3020#desc16.
713
 
  svntest.actions.run_and_verify_svn(None, expected_output, [],
 
708
  svntest.actions.run_and_verify_svn(expected_output, [],
714
709
                                     'propget', 'svn:mergeinfo', '-R',
715
710
                                     sbox.repo_url)
716
711
 
720
715
  "svnrdump load partial incremental dump"
721
716
 
722
717
  # Create an empty sandbox repository
723
 
  build_repos(sbox)
 
718
  sbox.build(create_wc=False, empty=True)
724
719
 
725
720
  # Create the revprop-change hook for this test
726
721
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
727
722
 
728
723
  # Create the 'A' directory in repository and then load the partial
729
724
  # incremental dump into the root of the repository.
730
 
  svntest.actions.run_and_verify_svn(None, ['\n', 'Committed revision 1.\n'],
 
725
  svntest.actions.run_and_verify_svn(['Committing transaction...\n',
 
726
                                            'Committed revision 1.\n'],
731
727
                                    [], "mkdir", sbox.repo_url + "/A",
732
728
                                     "-m", "Create toplevel dir to load into")
733
729
 
769
765
 
770
766
#----------------------------------------------------------------------
771
767
 
 
768
@Issue(4490)
 
769
def load_prop_change_in_non_deltas_dump(sbox):
 
770
  "load: prop change in non-deltas dump"
 
771
  # 'svnrdump load' crashed when processing a node record with a non-delta
 
772
  # properties block if the node previously had any svn:* properties.
 
773
 
 
774
  sbox.build()
 
775
  sbox.simple_propset('svn:eol-style', 'native', 'iota', 'A/mu', 'A/B/lambda')
 
776
  sbox.simple_commit()
 
777
 
 
778
  # Any prop change on a node that had an svn:* prop triggered the crash,
 
779
  # so test an svn:* prop deletion and also some other prop changes.
 
780
  sbox.simple_propdel('svn:eol-style', 'iota')
 
781
  sbox.simple_propset('svn:eol-style', 'LF', 'A/mu')
 
782
  sbox.simple_propset('p1', 'v1', 'A/B/lambda')
 
783
  sbox.simple_commit()
 
784
 
 
785
  # Create a non-deltas dump. Use 'svnadmin', as svnrdump doesn't have that
 
786
  # option.
 
787
  dump = svntest.actions.run_and_verify_dump(sbox.repo_dir, deltas=False)
 
788
 
 
789
  # Try to load that dump.
 
790
  sbox.build(create_wc=False, empty=True)
 
791
  svntest.actions.enable_revprop_changes(sbox.repo_dir)
 
792
  svntest.actions.run_and_verify_svnrdump(dump,
 
793
                                          [], [], 0,
 
794
                                          '-q', 'load', sbox.repo_url)
 
795
 
 
796
#----------------------------------------------------------------------
 
797
 
 
798
@Issue(4476)
 
799
def dump_mergeinfo_contains_r0(sbox):
 
800
  "dump: mergeinfo that contains r0"
 
801
  ### We pass the original dump file name as 'expected_dumpfile_name' because
 
802
  ### run_dump_test is currently broken when we don't.
 
803
  run_dump_test(sbox, "mergeinfo-contains-r0.dump",
 
804
                bypass_prop_validation=True)
 
805
 
 
806
#----------------------------------------------------------------------
 
807
 
 
808
@XFail()
 
809
@Issue(4476)
 
810
def load_mergeinfo_contains_r0(sbox):
 
811
  "load: mergeinfo that contains r0"
 
812
  run_load_test(sbox, "mergeinfo-contains-r0.dump",
 
813
                expected_dumpfile_name="mergeinfo-contains-r0.expected.dump")
 
814
 
772
815
#----------------------------------------------------------------------
773
816
 
774
817
# Regression test for issue 4551 "svnrdump load commits wrong properties,
870
913
    actual = map(str.strip, out)
871
914
    svntest.verify.compare_and_display_lines(None, 'PROPS', expected, actual)
872
915
 
 
916
# Regression test for issue #4552 "svnrdump writes duplicate headers for a
 
917
# replace-with-copy". 'svnrdump dump' wrote the Node-path and Node-kind
 
918
# headers twice for the 'delete' record of a replace-with-copy.
 
919
@Issue(4552)
 
920
def dump_replace_with_copy(sbox):
 
921
  "dump replace with copy"
 
922
  sbox.build()
 
923
 
 
924
  # Copy file/dir, replacing something
 
925
  sbox.simple_rm('A/D/gamma', 'A/C')
 
926
  sbox.simple_copy('A/mu@1', 'A/D/gamma')
 
927
  sbox.simple_copy('A/B@1', 'A/C')
 
928
  sbox.simple_commit()
 
929
 
 
930
  # Dump with 'svnrdump'
 
931
  dumpfile = svntest.actions.run_and_verify_svnrdump(
 
932
                               None, svntest.verify.AnyOutput, [], 0,
 
933
                               'dump', '--quiet', '--incremental', '-r2',
 
934
                               sbox.repo_url)
 
935
 
 
936
  # Check the 'delete' record headers: expect this parse to fail if headers
 
937
  # are duplicated
 
938
  svntest.verify.DumpParser(dumpfile).parse()
 
939
 
873
940
# Regression test for issue 4551 "svnrdump load commits wrong properties,
874
941
# or fails, on a non-deltas dumpfile". In this test, a node's props are
875
942
# modified, and the failure mode is that RA-serf would end up deleting
969
1036
              range_dump,
970
1037
              only_trunk_range_dump,
971
1038
              only_trunk_A_range_dump,
 
1039
              load_prop_change_in_non_deltas_dump,
 
1040
              dump_mergeinfo_contains_r0,
 
1041
              load_mergeinfo_contains_r0,
972
1042
              load_non_deltas_copy_with_props,
973
1043
              load_non_deltas_replace_copy_with_props,
 
1044
              dump_replace_with_copy,
974
1045
              load_non_deltas_with_props,
975
1046
             ]
976
1047