You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2014/03/20 13:37:30 UTC
svn commit: r1579606 - in /subversion/trunk: build.conf
subversion/tests/cmdline/lock-helper.c subversion/tests/cmdline/lock_tests.py
subversion/tests/cmdline/svntest/main.py
Author: philip
Date: Thu Mar 20 12:37:30 2014
New Revision: 1579606
URL: http://svn.apache.org/r1579606
Log:
Extend the test handling locks with expiration dates.
* subversion/tests/cmdline/lock_tests.py
(dav_lock_timeout): Extend and run for all RA layers.
* build.conf
(lock-helper): New.
(__ALL_TESTS__): Add lock-helper.
* subversion/tests/cmdline/lock-helper.c: New.
* subversion/tests/cmdline/svntest/main.py
(lock_helper_binary, run_lock_helper): New.
Added:
subversion/trunk/subversion/tests/cmdline/lock-helper.c (with props)
Modified:
subversion/trunk/build.conf
subversion/trunk/subversion/tests/cmdline/lock_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/main.py
Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1579606&r1=1579605&r2=1579606&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Thu Mar 20 12:37:30 2014
@@ -1285,6 +1285,14 @@ install = test
libs = libsvn_ra libsvn_subr apriconv apr
testing = skip
+[lock-helper]
+type = exe
+path = subversion/tests/cmdline
+sources = lock-helper.c
+install = test
+libs = libsvn_fs libsvn_subr apriconv apr
+testing = skip
+
[wc-lock-tester]
type = exe
path = subversion/tests/libsvn_wc
@@ -1448,6 +1456,7 @@ libs = __ALL__
sqlite-test
svndiff-test vdelta-test
entries-dump atomic-ra-revprop-change wc-lock-tester wc-incomplete-tester
+ lock-helper
client-test mtcc-test
conflict-data-test db-test pristine-store-test entries-compat-test
op-depth-test dirent_uri-test wc-queries-test wc-test
Added: subversion/trunk/subversion/tests/cmdline/lock-helper.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/lock-helper.c?rev=1579606&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/lock-helper.c (added)
+++ subversion/trunk/subversion/tests/cmdline/lock-helper.c Thu Mar 20 12:37:30 2014
@@ -0,0 +1,76 @@
+/*
+ * lock-helper.c : create locks with an expiry date
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ */
+
+#include <stdlib.h>
+
+#include "svn_pools.h"
+#include "svn_dirent_uri.h"
+#include "svn_fs.h"
+#include "svn_fs.h"
+
+int
+main(int argc, const char *argv[])
+{
+ apr_pool_t *pool;
+ const char *fs_path, *file_path, *username;
+ apr_int64_t seconds;
+ apr_time_t expiration_date;
+ svn_fs_t *fs;
+ svn_fs_access_t *access;
+ svn_lock_t *lock;
+
+ if (argc != 5)
+ {
+ fprintf(stderr, "usage: lock-helper repo_path file_path user seconds\n");
+ exit(1);
+ }
+
+ if (apr_initialize() != APR_SUCCESS)
+ {
+ fprintf(stderr, "apr_initialize() failed.\n");
+ exit(1);
+ }
+
+ pool = svn_pool_create(NULL);
+
+ fs_path = svn_dirent_internal_style(argv[1], pool);
+ fs_path = svn_dirent_join(fs_path, "db", pool);
+ file_path = svn_dirent_canonicalize(argv[2], pool);
+ username = argv[3];
+ SVN_INT_ERR(svn_cstring_atoi64(&seconds, argv[4]));
+
+ SVN_INT_ERR(svn_fs_open(&fs, fs_path, NULL, pool));
+ SVN_INT_ERR(svn_fs_create_access(&access, username, pool));
+ SVN_INT_ERR(svn_fs_set_access(fs, access));
+
+ expiration_date = apr_time_now() + apr_time_from_sec(seconds);
+
+ SVN_INT_ERR(svn_fs_lock(&lock, fs, file_path, NULL, "created by lock-helper",
+ FALSE, expiration_date, SVN_INVALID_REVNUM, FALSE,
+ pool));
+
+ svn_pool_destroy(pool);
+ apr_terminate();
+
+ return EXIT_SUCCESS;
+}
Propchange: subversion/trunk/subversion/tests/cmdline/lock-helper.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: subversion/trunk/subversion/tests/cmdline/lock_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/lock_tests.py?rev=1579606&r1=1579605&r2=1579606&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/lock_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/lock_tests.py Thu Mar 20 12:37:30 2014
@@ -2028,55 +2028,58 @@ def break_delete_add(sbox):
expected_status.tweak('A/mu', status=' ', wc_rev=3)
svntest.actions.run_and_verify_status(wc_dir, expected_status)
-@SkipUnless(svntest.main.is_ra_type_dav)
def dav_lock_timeout(sbox):
"unlock a lock with timeout"
- import httplib
- from urlparse import urlparse
- import base64
+ # Locks with timeouts are only created by generic DAV clients but a
+ # Subversion client may need to view or unlock one over any RA
+ # layer.
sbox.build()
- loc = urlparse(sbox.repo_url)
+ wc_dir = sbox.wc_dir
- if loc.scheme == 'http':
- h = httplib.HTTPConnection(loc.hostname, loc.port)
- else:
- h = httplib.HTTPSConnection(loc.hostname, loc.port)
-
- lock_body = '<?xml version="1.0" encoding="utf-8" ?>' \
- '<D:lockinfo xmlns:D="DAV:">' \
- ' <D:lockscope><D:exclusive/></D:lockscope>' \
- ' <D:locktype><D:write/></D:locktype>' \
- ' <D:owner>' \
- ' <D:href>http://a/test</D:href>' \
- ' </D:owner>' \
- '</D:lockinfo>'
-
- lock_headers = {
- 'Authorization': 'Basic ' + base64.b64encode('jconstant:rayjandom'),
- 'Timeout': 'Second-86400'
- }
-
- # Enabling the following line makes this test easier to debug
- h.set_debuglevel(9)
-
- h.request('LOCK', sbox.repo_url + '/iota', lock_body, lock_headers)
-
- r = h.getresponse()
+ svntest.main.run_lock_helper(sbox.repo_dir, 'iota', 'some_user', 999)
# Verify that there is a lock, by trying to obtain one
svntest.actions.run_and_verify_svn2(None, None, ".*locked by user", 0,
'lock', '-m', '', sbox.ospath('iota'))
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ expected_status.tweak('iota', writelocked='O')
+ svntest.actions.run_and_verify_status(wc_dir, expected_status)
- # Before this patch this used to fail with a parse error of the timeout
- svntest.actions.run_and_verify_svn2(None, None, ".*Unlock.*iota' failed", 0,
+ # This used to fail over serf with a parse error of the timeout.
+ expected_err = "svn: warning: W160039:"
+ svntest.actions.run_and_verify_svn2(None, None, expected_err, 0,
'unlock', sbox.repo_url + '/iota')
+ # Force unlock via working copy, this also used to fail over serf.
svntest.actions.run_and_verify_svn(None, None, [],
'unlock', sbox.ospath('iota'), '--force')
+ expected_status.tweak('iota', writelocked=None)
+ svntest.actions.run_and_verify_status(wc_dir, expected_status)
+ # Lock again
+ svntest.main.run_lock_helper(sbox.repo_dir, 'iota', 'some_user', 999)
+ expected_status.tweak('iota', writelocked='O')
+ svntest.actions.run_and_verify_status(wc_dir, expected_status)
+ # Force unlock via URL, this also used to fail over serf
+ svntest.actions.run_and_verify_svn(None, None, [],
+ 'unlock', sbox.repo_url + '/iota',
+ '--force')
+ expected_status.tweak('iota', writelocked=None)
+ svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+ # Lock again
+ svntest.main.run_lock_helper(sbox.repo_dir, 'iota', 'some_user', 999)
+ expected_status.tweak('iota', writelocked='O')
+ svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+ # Force lock via working copy, this also used to fail over serf.
+ svntest.actions.run_and_verify_svn(None, None, [],
+ 'lock', sbox.ospath('iota'), '--force')
+ expected_status.tweak('iota', writelocked='K')
+ svntest.actions.run_and_verify_status(wc_dir, expected_status)
########################################################################
# Run the tests
Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1579606&r1=1579605&r2=1579606&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Thu Mar 20 12:37:30 2014
@@ -155,6 +155,7 @@ svndumpfilter_binary = os.path.abspath('
_exe)
svnmucc_binary=os.path.abspath('../../svnmucc/svnmucc' + _exe)
entriesdump_binary = os.path.abspath('entries-dump' + _exe)
+lock_helper_binary = os.path.abspath('lock-helper' + _exe)
atomic_ra_revprop_change_binary = os.path.abspath('atomic-ra-revprop-change' + \
_exe)
wc_lock_tester_binary = os.path.abspath('../libsvn_wc/wc-lock-tester' + _exe)
@@ -747,6 +748,11 @@ def run_svnauthz_validate(*varargs):
stderr as list of lines (including line terminators)."""
return run_command(svnauthz_validate_binary, 1, False, *varargs)
+def run_lock_helper(repo, path, user, seconds):
+ """Run lock-helper to lock path in repo by username for seconds"""
+
+ return run_command(lock_helper_binary, 1, False, repo, path, user, seconds)
+
def run_entriesdump(path):
"""Run the entries-dump helper, returning a dict of Entry objects."""
# use spawn_process rather than run_command to avoid copying all the data