[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] New test for 'svnadmin lslocks' and 'svnadmin rmlocks'

From: Noorul Islam K M <noorul_at_collab.net>
Date: Mon, 11 Jul 2011 19:25:48 +0530

Philip Martin <philip.martin_at_wandisco.com> writes:

> Noorul Islam K M <noorul_at_collab.net> writes:
>
>> +def test_lslocks_and_rmlocks(sbox):
>> + "test 'svnadmin lslocks' and 'svnadmin rmlocks'"
>> +
>> + def verify_lslocks_output(expected, actual):
>> + """Verify expected output and actual output match."""
>> + if len(expected) != len(actual):
>> + raise svntest.verify.SVNUnexpectedStdout(
>> + "Expected %d lines, found %d lines"
>> + % (len(expected), len(actual)))
>> +
>> + for index in range(len(actual)):
>> + if not re.match(expected[index], actual[index]):
>> + raise svntest.verify.SVNUnexpectedStdout(
>> + "\nEXPECTED:\n%s\nACTUAL:\n%s"
>> + % ('\n'.join(expected), ''.join(actual)))
>
> Can't we use the verify.py stuff instead?
>

I don't think so, because I am using regular expressions because lock
token is a generated item.

>> +
>> + sbox.build(create_wc=False)
>> + iota_url = sbox.repo_url + '/iota'
>> + lambda_url = sbox.repo_url + '/A/B/lambda'
>> +
>> + exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
>> + sbox.repo_dir)
>> +
>> + if exit_code or errput or output:
>> + print("Error: 'lslocks' failed")
>> + raise svntest.Failure
>> +
>> + expected_output = ["'A/B/lambda' locked by user 'jrandom'.\n",
>> + "'iota' locked by user 'jrandom'.\n"]
>
> What determines the order of the locks? I think it should be using
> UnorderedOutput.
>

Ok.

>> + # Lock iota and A/B/lambda using svn client
>> + svntest.actions.run_and_verify_svn(None, expected_output,
>> + [], "lock", "-m", "Locking files",
>> + iota_url, lambda_url)
>> +
>> + expected_output = [
>> + "Path: /A/B/lambdas",
>
> 'lamdbas' ?
>

My fault by sending an incorrect version of patch which I used for
testing one of the case.

>> + "UUID Token: opaquelocktoken.*",
>> + "Owner: jrandom",
>> + "Created: .*",
>> + "Expires: ",
>> + "Comment \(1 line\):",
>> + "Locking files",
>> + "\n", # empty line
>> + "Path: /iota",
>> + "UUID Token: opaquelocktoken.*",
>> + "Owner: jrandom",
>> + "Created: .*",
>> + "Expires: ",
>> + "Comment \(1 line\):",
>> + "Locking files",
>> + "\n" # empty line
>> + ]
>
> That's probably a reasonably well-defined order.
>
>> +
>> + # List all locks
>> + exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
>> + sbox.repo_dir)
>> +
>> + if errput:
>> + print("Error: 'lsocks' failed")
>> + raise svntest.Failure
>> +
>> + verify_lslocks_output(expected_output, output)
>> +
>> + # List lock in path /A
>> + exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
>> + sbox.repo_dir,
>> + "A")
>> + if errput:
>> + print("Error: 'lsocks' failed")
>> + raise svntest.Failure
>> +
>> + verify_lslocks_output(expected_output[:len(output)], output)
>> +
>> + # Remove locks
>> + exit_code, output, errput = svntest.main.run_svnadmin("rmlocks",
>> + sbox.repo_dir,
>> + "iota",
>> + "A/B/lambda")
>> + expected_output = ["Removed lock on '/iota'.\n",
>> + "Removed lock on '/A/B/lambda'.\n"]
>
> That also looks like it should be using UnorderedOutput.
>

Ok.

Please find attached updated patch.

Thanks and Regards
Noorul

Index: subversion/tests/cmdline/svnadmin_tests.py
===================================================================
--- subversion/tests/cmdline/svnadmin_tests.py (revision 1145169)
+++ subversion/tests/cmdline/svnadmin_tests.py (working copy)
@@ -26,6 +26,7 @@
 
 # General modules
 import os
+import re
 import shutil
 import sys
 
@@ -33,6 +34,7 @@
 import svntest
 from svntest.verify import SVNExpectedStdout, SVNExpectedStderr
 from svntest.verify import SVNUnexpectedStderr
+from svntest.verify import UnorderedOutput
 from svntest.main import SVN_PROP_MERGEINFO
 
 # (abbreviation)
@@ -1381,6 +1383,93 @@
     'STDERR', expected_stderr, errput):
     raise svntest.Failure
 
+def test_lslocks_and_rmlocks(sbox):
+ "test 'svnadmin lslocks' and 'svnadmin rmlocks'"
+
+ def verify_lslocks_output(expected, actual):
+ """Verify expected output and actual output match."""
+ if len(expected) != len(actual):
+ raise svntest.verify.SVNUnexpectedStdout(
+ "Expected %d lines, found %d lines"
+ % (len(expected), len(actual)))
+
+ for index in range(len(actual)):
+ if not re.match(expected[index], actual[index]):
+ raise svntest.verify.SVNUnexpectedStdout(
+ "\nEXPECTED:\n%s\nACTUAL:\n%s"
+ % ('\n'.join(expected), ''.join(actual)))
+
+ sbox.build(create_wc=False)
+ iota_url = sbox.repo_url + '/iota'
+ lambda_url = sbox.repo_url + '/A/B/lambda'
+
+ exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
+ sbox.repo_dir)
+
+ if exit_code or errput or output:
+ print("Error: 'lslocks' failed")
+ raise svntest.Failure
+
+ expected_output = UnorderedOutput(
+ ["'A/B/lambda' locked by user 'jrandom'.\n",
+ "'iota' locked by user 'jrandom'.\n"])
+
+ # Lock iota using svn client
+ svntest.actions.run_and_verify_svn(None, expected_output,
+ [], "lock", "-m", "Locking files",
+ iota_url, lambda_url)
+
+ expected_output = [
+ "Path: /A/B/lambda",
+ "UUID Token: opaquelocktoken.*",
+ "Owner: jrandom",
+ "Created: .*",
+ "Expires: ",
+ "Comment \(1 line\):",
+ "Locking files",
+ "\n", # empty line
+ "Path: /iota",
+ "UUID Token: opaquelocktoken.*",
+ "Owner: jrandom",
+ "Created: .*",
+ "Expires: ",
+ "Comment \(1 line\):",
+ "Locking files",
+ "\n" # empty line
+ ]
+
+ # List all locks
+ exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
+ sbox.repo_dir)
+
+ if errput:
+ print("Error: 'lsocks' failed")
+ raise svntest.Failure
+
+ verify_lslocks_output(expected_output, output)
+
+ # List lock in path /A
+ exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
+ sbox.repo_dir,
+ "A")
+ if errput:
+ print("Error: 'lsocks' failed")
+ raise svntest.Failure
+
+ verify_lslocks_output(expected_output[:len(output)], output)
+
+ # Remove locks
+ exit_code, output, errput = svntest.main.run_svnadmin("rmlocks",
+ sbox.repo_dir,
+ "iota",
+ "A/B/lambda")
+ expected_output = UnorderedOutput(["Removed lock on '/iota'.\n",
+ "Removed lock on '/A/B/lambda'.\n"])
+
+ svntest.verify.verify_outputs(
+ "Unexpected output while running 'svnadmin rmlocks'.",
+ output, [], expected_output, None)
+
 ########################################################################
 # Run the tests
 
@@ -1410,6 +1499,7 @@
               hotcopy_symlink,
               load_bad_props,
               verify_non_utf8_paths,
+ test_lslocks_and_rmlocks,
              ]
 
 if __name__ == '__main__':
Received on 2011-07-11 15:56:34 CEST

This is an archived mail posted to the Subversion Dev mailing list.