subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kot...@apache.org
Subject svn commit: r1615541 - /subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
Date Mon, 04 Aug 2014 12:39:46 GMT
Author: kotkov
Date: Mon Aug  4 12:39:46 2014
New Revision: 1615541

URL: http://svn.apache.org/r1615541
Log:
Rework the way we create sharded repositories within the svnadmin command-
line tests.  Instead of hardcoding different 'db/format' contents for
different (server_minor_version, fs_type) test constraints, achieve the
same by using a separate helper function.  Do not attempt to generalize
this logic, because right now we only require this in a couple of tests.

* subversion/tests/cmdline/svnadmin_tests.py
  (write_sharded_format): New.  Patches the 'db/format' contents of the
    repository filesystem so that it would use the specified sharded layout.
    Strictly speaking, calling chmod() here is not currently required,
    because we make all test repositories world-writeable as a part of the
    their initialization.  However, this helper should also work for the
    repositories that were created indirectly, e.g. via 'svnadmin create'.
    These repositories would contain a read-only 'db/format' file, hence we
    would fail to patch it without preparative permission juggling.
  (hotcopy_incremental_packed, verify_packed, fsfs_hotcopy_progress):
    Simplify these tests by utilizing the new helper.

Modified:
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1615541&r1=1615540&r2=1615541&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Mon Aug  4 12:39:46 2014
@@ -213,6 +213,24 @@ def get_txns(repo_dir):
 
   return txns
 
+def write_sharded_format(repo_dir, shards):
+  """Rewrite the format of the FSFS or FSX repository REPO_DIR so
+  that it would use sharding with SHARDS revisions per shard."""
+
+  format_path = os.path.join(repo_dir, "db", "format")
+  contents = open(format_path, 'rb').read()
+  processed_lines = []
+
+  for line in contents.split("\n"):
+    if line.startswith("layout "):
+      processed_lines.append("layout sharded %d" % shards)
+    else:
+      processed_lines.append(line)
+
+  new_contents = "\n".join(processed_lines)
+  os.chmod(format_path, 0666)
+  open(format_path, 'wb').write(new_contents)
+
 def load_and_verify_dumpstream(sbox, expected_stdout, expected_stderr,
                                revs, check_props, dump, *varargs):
   """Load the array of lines passed in DUMP into the current tests'
@@ -1830,20 +1848,15 @@ def hotcopy_incremental(sbox):
 @SkipUnless(svntest.main.fs_has_pack)
 def hotcopy_incremental_packed(sbox):
   "'svnadmin hotcopy --incremental' with packing"
+
+  # Configure two files per shard to trigger packing.
   sbox.build()
+  write_sharded_format(sbox.repo_dir, 2)
 
   backup_dir, backup_url = sbox.add_repo_path('backup')
   os.mkdir(backup_dir)
   cwd = os.getcwd()
 
-  # Configure two files per shard to trigger packing
-  format_file = open(os.path.join(sbox.repo_dir, 'db', 'format'), 'wb')
-  if svntest.main.options.server_minor_version >= 9:
-    format_file.write("7\nlayout sharded 2\naddressing logical 0\n")
-  else:
-    format_file.write("6\nlayout sharded 2\n")
-  format_file.close()
-
   # Pack revisions 0 and 1.
   svntest.actions.run_and_verify_svnadmin(
     None, ['Packing revisions in shard 0...done.\n'], [], "pack",
@@ -2483,23 +2496,10 @@ def fsfs_hotcopy_old_with_id_changes(sbo
 @SkipUnless(svntest.main.fs_has_pack)
 def verify_packed(sbox):
   "verify packed with small shards"
-  sbox.build()
 
   # Configure two files per shard to trigger packing.
-  if svntest.main.is_fs_type_fsx():
-    format = "1\nlayout sharded 2\n"
-  elif svntest.main.is_fs_type_fsfs and \
-       svntest.main.options.server_minor_version >= 9:
-    format = "7\nlayout sharded 2\naddressing logical 0\n"
-  elif svntest.main.is_fs_type_fsfs and \
-       svntest.main.options.server_minor_version < 9:
-    format = "6\nlayout sharded 2\n"
-  else:
-    raise svntest.Failure
-
-  format_file = open(os.path.join(sbox.repo_dir, 'db', 'format'), 'wb')
-  format_file.write(format)
-  format_file.close()
+  sbox.build()
+  write_sharded_format(sbox.repo_dir, 2)
 
   # Play with our greek tree.  These changesets fall into two
   # separate shards with r2 and r3 being in shard 1 ...
@@ -2659,17 +2659,7 @@ def fsfs_hotcopy_progress(sbox):
   sbox.build(create_wc=False)
   svntest.main.safe_rmtree(sbox.repo_dir, True)
   svntest.main.create_repos(sbox.repo_dir)
-
-  if svntest.main.options.server_minor_version >= 9:
-    format = "7\nlayout sharded 3\naddressing logical 0\n"
-  elif svntest.main.options.server_minor_version < 9:
-    format = "6\nlayout sharded 3\n"
-  else:
-    raise svntest.Failure
-
-  format_file = open(os.path.join(sbox.repo_dir, 'db', 'format'), 'wb')
-  format_file.write(format)
-  format_file.close()
+  write_sharded_format(sbox.repo_dir, 3)
 
   inc_backup_dir, inc_backup_url = sbox.add_repo_path('incremental-backup')
 



Mime
View raw message