You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2010/08/02 21:47:18 UTC

svn commit: r981666 - in /subversion/branches/issue-2779-dev/subversion: libsvn_client/ tests/cmdline/ tests/cmdline/svntest/

Author: cmpilato
Date: Mon Aug  2 19:47:17 2010
New Revision: 981666

URL: http://svn.apache.org/viewvc?rev=981666&view=rev
Log:
On the issue-2779-dev branch:  Add some testing framework changes, and
some new tests, for the automatic redirection stuff.

* subversion/libsvn_client/relocate.c
  (validator_func): Check for the magic environment variable
    SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_RELOCATE_VALIDATION,
    which, if set to "yes", disables the URL and UUID validation that
    svn_client_relocate() performs.

* subversion/tests/cmdline/svntest/sandbox.py
  (Sandbox.redirected_root_url): New function.

* subversion/tests/cmdline/svntest/actions.py
  (no_relocate_validation, do_relocate_validation): New functions.

* subversion/tests/cmdline/svntest/main.py
  (TestRunner.run): Enable (forcibly) relocation validation.

* subversion/tests/cmdline/redirect_tests.py
  New test script.

* subversion/tests/cmdline/README,
* subversion/tests/cmdline/davautocheck.sh
  Update httpd.conf snippet to show RedirectMatch statement.

Added:
    subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py   (with props)
Modified:
    subversion/branches/issue-2779-dev/subversion/libsvn_client/relocate.c
    subversion/branches/issue-2779-dev/subversion/tests/cmdline/README
    subversion/branches/issue-2779-dev/subversion/tests/cmdline/davautocheck.sh
    subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/actions.py
    subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/main.py
    subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/sandbox.py

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/relocate.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/relocate.c?rev=981666&r1=981665&r2=981666&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/relocate.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/relocate.c Mon Aug  2 19:47:17 2010
@@ -66,6 +66,7 @@ validator_func(void *baton,
 {
   struct validator_baton_t *b = baton;
   struct url_uuid_t *url_uuid = NULL;
+  const char *disable_checks;
 
   apr_array_header_t *uuids = b->url_uuids;
   int i;
@@ -81,6 +82,16 @@ validator_func(void *baton,
         }
     }
 
+  disable_checks = getenv("SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_RELOCATE_VALIDATION");
+  if (disable_checks && (strcmp(disable_checks, "yes") == 0))
+    {
+      /* Lie about URL_UUID's components, claiming they match the
+         expectations of the validation code below.  */
+      url_uuid = apr_pcalloc(pool, sizeof(*url_uuid));
+      url_uuid->root = apr_pstrdup(pool, root_url);
+      url_uuid->uuid = apr_pstrdup(pool, uuid);
+    }
+
   /* We use an RA session in a subpool to get the UUID of the
      repository at the new URL so we can force the RA session to close
      by destroying the subpool. */

Modified: subversion/branches/issue-2779-dev/subversion/tests/cmdline/README
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/tests/cmdline/README?rev=981666&r1=981665&r2=981666&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/tests/cmdline/README (original)
+++ subversion/branches/issue-2779-dev/subversion/tests/cmdline/README Mon Aug  2 19:47:17 2010
@@ -83,6 +83,8 @@ paths adjusted appropriately:
      Require valid-user
    </Location>
 
+   RedirectMatch permanent ^/svn-test-work/repositories/REDIRECT-(.*)$ /svn-test-work/repositories/$1
+
 Httpd should be running on port 80.  You may also need to ensure that
 it's running as you, so it has read/write access to the repositories
 that are probably living in your Subversion working copy.  To do this,

Modified: subversion/branches/issue-2779-dev/subversion/tests/cmdline/davautocheck.sh
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/tests/cmdline/davautocheck.sh?rev=981666&r1=981665&r2=981666&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/tests/cmdline/davautocheck.sh (original)
+++ subversion/branches/issue-2779-dev/subversion/tests/cmdline/davautocheck.sh Mon Aug  2 19:47:17 2010
@@ -321,6 +321,7 @@ CustomLog           "$HTTPD_ROOT/ops" "%
   AuthUserFile      $HTTPD_USERS
   Require           valid-user
 </Location>
+RedirectMatch permanent ^/svn-test-work/repositories/REDIRECT-(.*)$ /svn-test-work/repositories/$1
 __EOF__
 
 START="$HTTPD -f $HTTPD_CFG"

Added: subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py?rev=981666&view=auto
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py (added)
+++ subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py Mon Aug  2 19:47:17 2010
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+#
+#  redirect_tests.py:  Test ra_dav handling of server-side redirects
+#
+#  Subversion is a tool for revision control.
+#  See http://subversion.apache.org for more information.
+#
+# ====================================================================
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements.  See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership.  The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied.  See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+######################################################################
+
+# General modules
+import os, re
+
+# Our testing module
+import svntest
+
+# (abbreviations)
+Skip = svntest.testcase.Skip
+SkipUnless = svntest.testcase.SkipUnless
+XFail = svntest.testcase.XFail
+Wimp = svntest.testcase.Wimp
+
+# Regular expression which matches the redirection notification
+redirect_regex = re.compile(r"^Redirecting to URL '.*'")
+
+# Generic UUID-matching regular expression
+uuid_regex = re.compile(r"[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}")
+
+
+def verify_url(wc_path, url, wc_path_is_file=False):
+  # check that we have a Repository Root and Repository UUID
+  name = os.path.basename(wc_path)
+  expected = {'Path' : re.escape(wc_path),
+              'URL' : url,
+              'Repository Root' : '.*',
+              'Revision' : '.*',
+              'Node Kind' : 'directory',
+              'Repository UUID' : uuid_regex,
+             }
+  if wc_path_is_file:
+    expected.update({'Name' : name,
+                     'Node Kind' : 'file',
+                     })
+  svntest.actions.run_and_verify_info([expected], wc_path)
+
+
+######################################################################
+# Tests
+#
+#   Each test must return on success or raise on failure.
+
+#----------------------------------------------------------------------
+
+def redirected_checkout(sbox):
+  "redirected checkout"
+
+  sbox.build(create_wc=False)
+  wc_dir = sbox.add_wc_path("my")
+  co_url = sbox.redirected_root_url()
+  
+  # Checkout the working copy via its redirect URL
+  exit_code, out, err = svntest.main.run_svn(None, 'co', co_url, wc_dir)
+  if err:
+    raise svntest.Failure
+  if not redirect_regex.match(out[0]):
+    raise svntest.Failure
+
+  # Verify that we have the expected URL.
+  verify_url(wc_dir, sbox.repo_url)
+  
+#----------------------------------------------------------------------
+
+def redirected_update(sbox):
+  "redirected update"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  relocate_url = sbox.redirected_root_url()
+
+  # Relocate (by cheating) the working copy to the redirect URL.  When
+  # we then update, we'll expect to find ourselves automagically back
+  # to the original URL.  (This is because we can't easily introduce a
+  # redirect to the Apache configuration from the test suite here.)
+  svntest.actions.no_relocate_validation()
+  exit_code, out, err = svntest.main.run_svn(None, 'sw', '--relocate',
+                                             sbox.repo_url, relocate_url,
+                                             wc_dir)
+  svntest.actions.do_relocate_validation()
+
+  # Now update the working copy.
+  exit_code, out, err = svntest.main.run_svn(None, 'up', wc_dir)
+  if err:
+    raise svntest.Failure
+  if not redirect_regex.match(out[0]):
+    raise svntest.Failure
+
+  # Verify that we have the expected URL.
+  verify_url(wc_dir, sbox.repo_url)
+  
+#----------------------------------------------------------------------
+
+########################################################################
+# Run the tests
+
+# list all tests here, starting with None:
+test_list = [ None,
+              SkipUnless(redirected_checkout,
+                         svntest.main.is_ra_type_dav),
+              SkipUnless(redirected_update,
+                         svntest.main.is_ra_type_dav),
+             ]
+
+if __name__ == '__main__':
+  svntest.main.run_tests(test_list)
+  # NOTREACHED
+
+
+### End of file.

Propchange: subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: subversion/branches/issue-2779-dev/subversion/tests/cmdline/redirect_tests.py
------------------------------------------------------------------------------
    svn:mime-type = text/x-python

Modified: subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/actions.py?rev=981666&r1=981665&r2=981666&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/actions.py Mon Aug  2 19:47:17 2010
@@ -38,6 +38,12 @@ def no_sleep_for_timestamps():
 def do_sleep_for_timestamps():
   os.environ['SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_SLEEP_FOR_TIMESTAMPS'] = 'no'
 
+def no_relocate_validation():
+  os.environ['SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_RELOCATE_VALIDATION'] = 'yes'
+
+def do_relocate_validation():
+  os.environ['SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_RELOCATE_VALIDATION'] = 'no'
+
 def setup_pristine_repository():
   """Create the pristine repository and 'svn import' the greek tree"""
 

Modified: subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/main.py?rev=981666&r1=981665&r2=981666&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/main.py Mon Aug  2 19:47:17 2010
@@ -1190,6 +1190,7 @@ class TestRunner:
                                       str(self.index)
 
     svntest.actions.no_sleep_for_timestamps()
+    svntest.actions.do_relocate_validation()
 
     saved_dir = os.getcwd()
     try:

Modified: subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/sandbox.py?rev=981666&r1=981665&r2=981666&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/branches/issue-2779-dev/subversion/tests/cmdline/svntest/sandbox.py Mon Aug  2 19:47:17 2010
@@ -153,6 +153,14 @@ class Sandbox:
       wc_dir = self.wc_dir
     return os.path.join(wc_dir, svntest.wc.to_ospath(relpath))
 
+  def redirected_root_url(self):
+    """Return the URL which should be configured to redirect to the root
+       of this repository."""
+    assert not self.read_only
+    assert self.repo_url.startswith("http")
+    parts = self.repo_url.rsplit('/', 1)
+    return parts[0] + '/REDIRECT-' + parts[1]
+    
   def simple_commit(self, target=None):
     assert not self.read_only
     if target is None: