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

[PATCH] To automate the svnsshcheck

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-02-12 19:46:12 CET

Hi All,
The attached patch automates the svnsshcheck and make makes '100%' of
testsuite as with other access mechanisms.

With regards
Kamesh Jayachandran

[[[
Automate the svnsshcheck and make sure ssh tunnel understands
--user = jconstant/jrandom accordingly.

Patch by: Kamesh Jayachandran <kamesh@collab.net>

* Makefile.in
  (createtestsshsetup): Automatically creates public/private keys
  for jconstant/jrandom adds localhost to known_hosts.
  (restoresshsetup): Restores the original configuration upon test
completion.
  (svnsshcheck): depends on 'createtestsshsetup' and 'restoresshsetup'
* subversion/tests/cmdline/README
  Small doc on this svnsshcheck automation.
* subversion/tests/cmdline/svntest/main.py
  (setup_tunnel): Sets up the SVN_SSH environment variable with
  'ssh -p port -i /path/to/jconstant_or_jrandom_private_key
  [based on --username argument] hostname[localhost]
  (run_svn): calls setup_tunnel
  (run_svnsync): calls setup_tunnel
]]]

Index: Makefile.in
===================================================================
--- Makefile.in (revision 18390)
+++ Makefile.in (working copy)
@@ -33,6 +33,11 @@
 SWIG_SRC_DIR = $(abs_srcdir)/subversion/bindings/swig
 SWIG_BUILD_DIR = $(abs_builddir)/subversion/bindings/swig
 
+JCONSTANT_PUBLIC_KEY = $(abs_builddir)/subversion/tests/cmdline/jconstant.pub
+JCONSTANT_PRIVATE_KEY = $(abs_builddir)/subversion/tests/cmdline/jconstant
+JRANDOM_PUBLIC_KEY = $(abs_builddir)/subversion/tests/cmdline/jrandom.pub
+JRANDOM_PRIVATE_KEY = $(abs_builddir)/subversion/tests/cmdline/jrandom
+
 SVN_EXTERNAL_PROJECT_SUBDIRS = @SVN_EXTERNAL_PROJECT_SUBDIRS@
 
 SCHEMA_DIR = subversion/svn/schema
@@ -410,11 +415,39 @@
 svncheck6:
         @$(MAKE) check BASE_URL=svn://\[::1\]
 
-# First make sure you can ssh to localhost and that "svnserve" is in
-# the path of the resulting shell.
-svnsshcheck:
+createtestsshsetup:
+ rm -f $(JCONSTANT_PRIVATE_KEY) $(JCONSTANT_PUBLIC_KEY)
+ rm -f $(JRANDOM_PRIVATE_KEY) $(JRANDOM_PUBLIC_KEY)
+ ssh-keygen -t dsa -f $(JCONSTANT_PRIVATE_KEY) -P ''
+ ssh-keygen -t dsa -f $(JRANDOM_PRIVATE_KEY) -P ''
+ -@if ! test -d ~/.ssh; then \
+ mkdir ~/.ssh;\
+ chmod 700 ~/.ssh;\
+ fi
+ -@if test -f ~/.ssh/authorized_keys; then \
+ mv -f ~/.ssh/authorized_keys ~/.ssh/authorized_keys.pristine;\
+ fi
+ #small hack to make ssh not to prompt for whether to save or not
+ #kind of interactions while the tests are running.
+ echo "command=\"exit 0;\" `cat $(JCONSTANT_PUBLIC_KEY)`" > ~/.ssh/authorized_keys
+ chmod 644 ~/.ssh/authorized_keys
+ ssh -o StrictHostKeyChecking=no -i $(JCONSTANT_PRIVATE_KEY) localhost
+ -@if test -f ~/.ssh/authorized_keys.pristine; then \
+ cp -f ~/.ssh/authorized_keys.pristine ~/.ssh/authorized_keys;\
+ fi
+ echo "command=\"$(abs_builddir)/subversion/svnserve/svnserve -t --tunnel-user=jrandom\" `cat $(JRANDOM_PUBLIC_KEY)`" >> ~/.ssh/authorized_keys
+ echo "command=\"$(abs_builddir)/subversion/svnserve/svnserve -t --tunnel-user=jconstant\" `cat $(JCONSTANT_PUBLIC_KEY)`" >> ~/.ssh/authorized_keys
+ chmod 644 ~/.ssh/authorized_keys
+
+restoresshsetup:
+ -@if test -f ~/.ssh/authorized_keys.pristine; then \
+ mv -f ~/.ssh/authorized_keys.pristine ~/.ssh/authorized_keys;\
+ fi
+svnsshcheck:
+ @$(MAKE) createtestsshsetup
         @$(MAKE) check \
           BASE_URL=svn+ssh://localhost`pwd`/subversion/tests/cmdline
+ @$(MAKE) restoresshsetup
 
 fsfscheck:
         @$(MAKE) check FS_TYPE=fsfs
Index: subversion/tests/cmdline/README
===================================================================
--- subversion/tests/cmdline/README (revision 18390)
+++ subversion/tests/cmdline/README (working copy)
@@ -144,8 +144,31 @@
 $ ./basic_tests.py --url=svn://localhost 3
 
 
+Running over svn+ssh tunnel
+---------------------------
+This needs running ssh server.
 
+$make createtestsshsetup
+This automatically sets up the ssh public/private key configurations
+needed to make the testsuite to run smoothly.
 
+$make restoresshsetup
+This restores the original ssh client authentication settings.
+
+You might not want to run both explicitly unless you run,
+$make check BASE_URL=svn+ssh://localhost:port/path/to/repos
+
+$make svnsshcheck
+To run all the tests automatically taking care of the ssh configurations and
+restoration of the same.
+
+To test only the subset of testsuite, you can mention it by setting the
+'TESTS' variable while invoking a TestSuite. Something like the following
+just tests from subversion/tests/cmdline/svnsync_tests.py.
+Note: TESTS=relative_path/with/respect/to/source/dir/test.py
+(Not with respect to build dir).
+$make svnsshcheck TESTS=subversion/tests/cmdline/svnsync_tests.py
+
 Directory Contents
 ==================
 
Index: subversion/tests/cmdline/svntest/main.py
===================================================================
--- subversion/tests/cmdline/svntest/main.py (revision 18390)
+++ subversion/tests/cmdline/svntest/main.py (working copy)
@@ -110,6 +110,7 @@
 svnlook_binary = os.path.abspath('../../svnlook/svnlook' + _exe)
 svnsync_binary = os.path.abspath('../../svnsync/svnsync' + _exe)
 svnversion_binary = os.path.abspath('../../svnversion/svnversion' + _exe)
+privkey_dir = os.path.abspath('.')
 
 # Username and password used by the working copies
 wc_author = 'jrandom'
@@ -133,6 +134,10 @@
 # Global variable indicating the FS type for repository creations.
 fs_type = None
 
+# Global variable indicating the ssh tunnel program template with args
+# for repository access.
+ssh_tunnel_template = 'ssh -p %s -i %s %s'
+
 # All temporary repositories and working copies are created underneath
 # this dir, so there's one point at which to mount, e.g., a ramdisk.
 work_dir = "svn-test-work"
@@ -325,7 +330,32 @@
   fd.write(server_contents)
   fd.close()
 
+def setup_tunnel(*varargs):
+ scheme = ''
+ scheme_ends = test_area_url.find('://')
+ if scheme_ends != -1:
+ scheme = test_area_url[:scheme_ends]
+
+ if scheme == 'svn+ssh':
+ port = 22
+ hostname = 'localhost'
+ host_and_others = test_area_url[scheme_ends+3:]
+ port_starts = host_and_others.find(':')
+ path_starts = host_and_others.find('/')
+ if port_starts != -1 and (port_starts < path_starts):
+ hostname = host_and_others[:port_starts]
+ port = host_and_others[port_starts+1:path_starts]
 
+ iteration_count=0
+ for item in varargs:
+ iteration_count = iteration_count + 1
+ if item == '--username':
+ break
+ if iteration_count != len(varargs):
+ username = varargs[iteration_count]
+ SVN_SSH = ssh_tunnel_template % (port, os.path.join(privkey_dir, username), hostname)
+ os.putenv('SVN_SSH', SVN_SSH)
+
 # For running subversion and returning the output
 def run_svn(error_expected, *varargs):
   """Run svn with VARARGS; return stdout, stderr as lists of lines.
@@ -333,6 +363,7 @@
   you're just checking that something does/doesn't come out of
   stdout/stderr, you might want to use actions.run_and_verify_svn()."""
   global config_dir
+ setup_tunnel(*varargs)
   return run_command(svn_binary, error_expected, 0,
                      *varargs + ('--config-dir', config_dir))
 
@@ -348,6 +379,7 @@
 
 def run_svnsync(*varargs):
   "Run svnsync with VARARGS, returns stdout, stderr as list of lines."
+ setup_tunnel(*varargs)
   return run_command(svnsync_binary, 1, 0, *varargs)
 
 def run_svnversion(*varargs):

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Feb 12 19:46:30 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.