Diagnose test 35 failure
[svnrdump.git] / svnrdump_tests.py
blob7d785f6cf3670dc3670184dd42592ca1ea4d060a
1 #!/usr/bin/env python
3 # svnrdump_tests.py: Tests svnrdump's remote repository dumping capabilities.
5 # Subversion is a tool for revision control.
6 # See http://subversion.apache.org for more information.
8 # ====================================================================
9 # Licensed to the Apache Software Foundation (ASF) under one
10 # or more contributor license agreements. See the NOTICE file
11 # distributed with this work for additional information
12 # regarding copyright ownership. The ASF licenses this file
13 # to you under the Apache License, Version 2.0 (the
14 # "License"); you may not use this file except in compliance
15 # with the License. You may obtain a copy of the License at
17 # http://www.apache.org/licenses/LICENSE-2.0
19 # Unless required by applicable law or agreed to in writing,
20 # software distributed under the License is distributed on an
21 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 # KIND, either express or implied. See the License for the
23 # specific language governing permissions and limitations
24 # under the License.
25 ######################################################################
27 # General modules
28 import sys, os
30 # Our testing module
31 import svntest
32 from svntest.verify import SVNUnexpectedStdout, SVNUnexpectedStderr
33 from svntest.verify import SVNExpectedStderr
34 from svntest.main import write_restrictive_svnserve_conf
35 from svntest.main import server_has_partial_replay
37 # (abbreviation)
38 Skip = svntest.testcase.Skip
39 SkipUnless = svntest.testcase.SkipUnless
40 XFail = svntest.testcase.XFail
41 Item = svntest.wc.StateItem
42 Wimp = svntest.testcase.Wimp
44 ## Mismatched headers during dumping operation
45 # Text-copy-source-* and *-sha1 headers are not provided by the RA
46 # layer. `svnadmin dump` is able to provide them because it works on
47 # the FS layer. Also, svnrdump attaches "Prop-delta: true" with
48 # everything whether it's really a delta or a new prop (delta from
49 # /dev/null). This is really harmless, but `svnadmin dump` contains
50 # the logic for differentiating between these two cases.
52 mismatched_headers_re = \
53 "Prop-delta: |Text-content-sha1: |Text-copy-source-md5: |" \
54 "Text-copy-source-sha1: |Text-delta-base-sha1: .*"
56 ######################################################################
57 # Helper routines
59 def build_repos(sbox):
60 """Build an empty sandbox repository"""
62 # Cleanup after the last run by removing any left-over repository.
63 svntest.main.safe_rmtree(sbox.repo_dir)
65 # Create an empty repository.
66 svntest.main.create_repos(sbox.repo_dir)
68 def run_dump_test(sbox, dumpfile_name, expected_dumpfile_name = None,
69 subdir = None):
70 """Load a dumpfile using 'svnadmin load', dump it with 'svnrdump
71 dump' and check that the same dumpfile is produced or that
72 expected_dumpfile_name is produced if provided. Additionally, the
73 subdir argument appends itself to the URL"""
75 # Create an empty sanbox repository
76 build_repos(sbox)
78 # This directory contains all the dump files
79 svnrdump_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
80 'svnrdump_tests_data')
82 # Load the specified dump file into the sbox repository using
83 # svnadmin load
84 svnadmin_dumpfile = open(os.path.join(svnrdump_tests_dir,
85 dumpfile_name),
86 'rb').readlines()
88 svntest.actions.run_and_verify_load(sbox.repo_dir, svnadmin_dumpfile)
90 repo_url = sbox.repo_url
91 if subdir:
92 repo_url = repo_url + subdir
94 # Create a dump file using svnrdump
95 svnrdump_dumpfile = \
96 svntest.actions.run_and_verify_svnrdump(None, svntest.verify.AnyOutput,
97 [], 0, '-q', 'dump',
98 repo_url)
100 if expected_dumpfile_name:
101 svnadmin_dumpfile = open(os.path.join(svnrdump_tests_dir,
102 expected_dumpfile_name),
103 'rb').readlines()
105 # Compare the output from stdout
106 svntest.verify.compare_and_display_lines(
107 "Dump files", "DUMP", svnadmin_dumpfile, svnrdump_dumpfile,
108 None, mismatched_headers_re)
110 def run_load_test(sbox, dumpfile_name, expected_dumpfile_name = None):
111 """Load a dumpfile using 'svnrdump load', dump it with 'svnadmin
112 dump' and check that the same dumpfile is produced"""
114 # Create an empty sanbox repository
115 build_repos(sbox)
117 # Create the revprop-change hook for this test
118 svntest.actions.enable_revprop_changes(sbox.repo_dir)
120 # This directory contains all the dump files
121 svnrdump_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
122 'svnrdump_tests_data')
124 # Load the specified dump file into the sbox repository using
125 # svnrdump load
126 svnrdump_dumpfile = open(os.path.join(svnrdump_tests_dir,
127 dumpfile_name),
128 'rb').readlines()
130 # Set the UUID of the sbox repository to the UUID specified in the
131 # dumpfile ### RA layer doesn't have a set_uuid functionality
132 uuid = svnrdump_dumpfile[2].split(' ')[1][:-1]
133 svntest.actions.run_and_verify_svnadmin2("Setting UUID", None, None, 0,
134 'setuuid', sbox.repo_dir,
135 uuid)
137 svntest.actions.run_and_verify_svnrdump(svnrdump_dumpfile,
138 svntest.verify.AnyOutput,
139 [], 0, '-q', 'load',
140 sbox.repo_url)
142 # Create a dump file using svnadmin dump
143 svnadmin_dumpfile = svntest.actions.run_and_verify_dump(sbox.repo_dir, True)
145 if expected_dumpfile_name:
146 svnrdump_dumpfile = open(os.path.join(svnrdump_tests_dir,
147 expected_dumpfile_name),
148 'rb').readlines()
150 # Compare the output from stdout
151 svntest.verify.compare_and_display_lines(
152 "Dump files", "DUMP", svntest.verify.UnorderedOutput(svnrdump_dumpfile),
153 svnadmin_dumpfile)
155 ######################################################################
156 # Tests
158 def basic_dump(sbox):
159 "dump: standard sbox repos"
160 sbox.build(read_only = True, create_wc = False)
162 out = \
163 svntest.actions.run_and_verify_svnrdump(None, svntest.verify.AnyOutput,
164 [], 0, '-q', 'dump',
165 sbox.repo_url)
167 if not out[0].startswith('SVN-fs-dump-format-version:'):
168 raise svntest.Failure('No valid output')
170 def revision_0_dump(sbox):
171 "dump: revision zero"
172 run_dump_test(sbox, "revision-0.dump")
174 def revision_0_load(sbox):
175 "load: revision zero"
176 run_load_test(sbox, "revision-0.dump")
178 # skeleton.dump repository layout
180 # Projects/ (Added r1)
181 # README (Added r2)
182 # Project-X (Added r3)
183 # Project-Y (Added r4)
184 # Project-Z (Added r5)
185 # docs/ (Added r6)
186 # README (Added r6)
188 def skeleton_dump(sbox):
189 "dump: skeleton repository"
190 run_dump_test(sbox, "skeleton.dump")
192 def skeleton_load(sbox):
193 "load: skeleton repository"
194 run_load_test(sbox, "skeleton.dump")
196 def copy_and_modify_dump(sbox):
197 "dump: copy and modify"
198 run_dump_test(sbox, "copy-and-modify.dump")
200 def copy_and_modify_load(sbox):
201 "load: copy and modify"
202 run_load_test(sbox, "copy-and-modify.dump")
204 def no_author_dump(sbox):
205 "dump: copy revs with no svn:author revprops"
206 run_dump_test(sbox, "no-author.dump")
208 def no_author_load(sbox):
209 "load: copy revs with no svn:author revprops"
210 run_load_test(sbox, "no-author.dump")
212 def copy_from_previous_version_and_modify_dump(sbox):
213 "dump: copy from previous version and modify"
214 run_dump_test(sbox, "copy-from-previous-version-and-modify.dump")
216 def copy_from_previous_version_and_modify_load(sbox):
217 "load: copy from previous version and modify"
218 run_load_test(sbox, "copy-from-previous-version-and-modify.dump")
220 def modified_in_place_dump(sbox):
221 "dump: modified in place"
222 run_dump_test(sbox, "modified-in-place.dump")
224 def modified_in_place_load(sbox):
225 "load: modified in place"
226 run_load_test(sbox, "modified-in-place.dump")
228 def move_and_modify_in_the_same_revision_dump(sbox):
229 "dump: move parent & modify child file in same rev"
230 run_dump_test(sbox, "move-and-modify.dump")
232 def move_and_modify_in_the_same_revision_load(sbox):
233 "load: move parent & modify child file in same rev"
234 run_load_test(sbox, "move-and-modify.dump")
236 def tag_empty_trunk_dump(sbox):
237 "dump: tag empty trunk"
238 run_dump_test(sbox, "tag-empty-trunk.dump")
240 def tag_empty_trunk_load(sbox):
241 "load: tag empty trunk"
242 run_load_test(sbox, "tag-empty-trunk.dump")
244 def tag_trunk_with_file_dump(sbox):
245 "dump: tag trunk containing a file"
246 run_dump_test(sbox, "tag-trunk-with-file.dump")
248 def tag_trunk_with_file_load(sbox):
249 "load: tag trunk containing a file"
250 run_load_test(sbox, "tag-trunk-with-file.dump")
252 def tag_trunk_with_file2_dump(sbox):
253 "dump: tag trunk containing a file (#2)"
254 run_dump_test(sbox, "tag-trunk-with-file2.dump")
256 def tag_trunk_with_file2_load(sbox):
257 "load: tag trunk containing a file (#2)"
258 run_load_test(sbox, "tag-trunk-with-file2.dump")
260 def dir_prop_change_dump(sbox):
261 "dump: directory property changes"
262 run_dump_test(sbox, "dir-prop-change.dump")
264 def dir_prop_change_load(sbox):
265 "load: directory property changes"
266 run_load_test(sbox, "dir-prop-change.dump")
268 def copy_parent_modify_prop_dump(sbox):
269 "dump: copy parent and modify prop"
270 run_dump_test(sbox, "copy-parent-modify-prop.dump")
272 def copy_parent_modify_prop_load(sbox):
273 "load: copy parent and modify prop"
274 run_load_test(sbox, "copy-parent-modify-prop.dump")
276 def copy_revprops_dump(sbox):
277 "dump: copy revprops other than svn:*"
278 run_dump_test(sbox, "revprops.dump")
280 def copy_revprops_load(sbox):
281 "load: copy revprops other than svn:*"
282 run_load_test(sbox, "revprops.dump")
284 def only_trunk_dump(sbox):
285 "dump: subdirectory"
286 run_dump_test(sbox, "trunk-only.dump", subdir="/trunk",
287 expected_dumpfile_name="trunk-only.expected.dump")
289 def only_trunk_A_with_changes_dump(sbox):
290 "dump: subdirectory with changes on root"
291 run_dump_test(sbox, "trunk-A-changes.dump", subdir="/trunk/A",
292 expected_dumpfile_name="trunk-A-changes.expected.dump")
294 def url_encoding_dump(sbox):
295 "dump: url encoding issues"
296 run_dump_test(sbox, "url-encoding-bug.dump")
298 def url_encoding_load(sbox):
299 "load: url encoding issues"
300 run_load_test(sbox, "url-encoding-bug.dump")
302 def copy_bad_line_endings_dump(sbox):
303 "dump: inconsistent line endings in svn:props"
304 run_dump_test(sbox, "copy-bad-line-endings.dump",
305 expected_dumpfile_name="copy-bad-line-endings.expected.dump")
307 def commit_a_copy_of_root_dump(sbox):
308 "dump: commit a copy of root"
309 run_dump_test(sbox, "repo-with-copy-of-root-dir.dump")
311 def commit_a_copy_of_root_load(sbox):
312 "load: commit a copy of root"
313 run_load_test(sbox, "repo-with-copy-of-root-dir.dump")
315 def descend_into_replace_dump(sbox):
316 "dump: descending into replaced dir looks in src"
317 run_dump_test(sbox, "descend-into-replace.dump", subdir='/trunk/H',
318 expected_dumpfile_name = "descend-into-replace.expected.dump")
320 ########################################################################
321 # Run the tests
324 # list all tests here, starting with None:
325 test_list = [ None,
326 basic_dump,
327 revision_0_dump,
328 revision_0_load,
329 skeleton_dump,
330 skeleton_load,
331 copy_and_modify_dump,
332 copy_and_modify_load,
333 copy_from_previous_version_and_modify_dump,
334 copy_from_previous_version_and_modify_load,
335 modified_in_place_dump,
336 modified_in_place_load,
337 tag_empty_trunk_dump,
338 tag_empty_trunk_load,
339 tag_trunk_with_file_dump,
340 tag_trunk_with_file_load,
341 tag_trunk_with_file2_dump,
342 tag_trunk_with_file2_load,
343 dir_prop_change_dump,
344 Wimp("TODO", dir_prop_change_load, svntest.main.is_ra_type_dav),
345 copy_parent_modify_prop_dump,
346 copy_parent_modify_prop_load,
347 url_encoding_dump,
348 url_encoding_load,
349 copy_revprops_dump,
350 copy_revprops_load,
351 only_trunk_dump,
352 only_trunk_A_with_changes_dump,
353 no_author_dump,
354 no_author_load,
355 move_and_modify_in_the_same_revision_dump,
356 move_and_modify_in_the_same_revision_load,
357 copy_bad_line_endings_dump,
358 commit_a_copy_of_root_dump,
359 commit_a_copy_of_root_load,
360 Wimp("Issue 3641", descend_into_replace_dump),
363 if __name__ == '__main__':
364 svntest.main.run_tests(test_list)
365 # NOTREACHED
368 ### End of file.