testing: Reduce testing runtime by reusing SSH sessions.

By using the ControlMaster and ControlPath options, existing SSH sessions
are reused (a session to each host is opened at the beginning of a test
run).  Also, RC4 is used as encryption algorithm to further improve the
performance.  These changes reduce the runtime by over 20%.
This commit is contained in:
Tobias Brunner 2010-10-14 14:01:26 +02:00
parent 972663ccb0
commit 7ec11936e8
5 changed files with 61 additions and 28 deletions

View File

@ -100,6 +100,16 @@ do
done
##############################################################################
# open ssh sessions
#
for host in $STRONGSWANHOSTS
do
ssh $SSHCONF -N root@`eval echo \\\$ipv4_$host` &
eval ssh_pid_$host="`echo $!`"
done
##############################################################################
# create header for the results html file
#
@ -350,7 +360,7 @@ do
iface=`echo $host_iface | awk -F ":" '{if ($2 != "") { print $2 } else { printf("eth0") }}'`
tcpdump_cmd="tcpdump -i $iface not port ssh and not port domain > /tmp/tcpdump.log 2>&1 &"
echo "${host}# $tcpdump_cmd" >> $CONSOLE_LOG
ssh root@`eval echo \\\$ipv4_$host '$tcpdump_cmd'`
ssh $SSHCONF root@`eval echo \\\$ipv4_$host '$tcpdump_cmd'`
eval TDUP_${host}="true"
done
fi
@ -367,7 +377,7 @@ do
if ($2 != "")
{
printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
}' $TESTDIR/pretest.dat` >> $CONSOLE_LOG 2>&1
@ -379,7 +389,7 @@ do
function stop_tcpdump {
echo "${1}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ipv4_${1} killall tcpdump
eval ssh $SSHCONF root@\$ipv4_${1} killall tcpdump
eval TDUP_${1}="false"
echo ""
}
@ -405,12 +415,12 @@ do
{
printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047 [%s]\"; ", host, pattern, hit)
printf("ssh root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
printf("ssh \044SSHCONF root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
}
else
{
printf("echo \"%s# %s | grep \047%s\047 [%s]\"; ", host, command, pattern, hit)
printf("ssh root@\044ipv4_%s %s | grep \"%s\"; ", host, command, pattern)
printf("ssh \044SSHCONF root@\044ipv4_%s %s | grep \"%s\"; ", host, command, pattern)
}
printf("cmd_exit=\044?; ")
printf("echo; ")
@ -465,26 +475,26 @@ do
for command in statusall listall
do
ssh $HOSTLOGIN ipsec $command \
ssh $SSHCONF $HOSTLOGIN ipsec $command \
> $TESTRESULTDIR/${host}.$command 2>/dev/null
done
for file in strongswan.conf ipsec.conf ipsec.secrets
do
scp $HOSTLOGIN:/etc/$file \
scp $SSHCONF $HOSTLOGIN:/etc/$file \
$TESTRESULTDIR/${host}.$file > /dev/null 2>&1
done
scp $HOSTLOGIN:/etc/ipsec.d/ipsec.sql \
scp $SSHCONF $HOSTLOGIN:/etc/ipsec.d/ipsec.sql \
$TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
ssh $HOSTLOGIN ip -s xfrm policy \
ssh $SSHCONF $HOSTLOGIN ip -s xfrm policy \
> $TESTRESULTDIR/${host}.ip.policy 2>/dev/null
ssh $HOSTLOGIN ip -s xfrm state \
ssh $SSHCONF $HOSTLOGIN ip -s xfrm state \
> $TESTRESULTDIR/${host}.ip.state 2>/dev/null
ssh $HOSTLOGIN ip route list table $SOURCEIP_ROUTING_TABLE \
ssh $SSHCONF $HOSTLOGIN ip route list table $SOURCEIP_ROUTING_TABLE \
> $TESTRESULTDIR/${host}.ip.route 2>/dev/null
ssh $HOSTLOGIN $IPTABLES_CMD \
ssh $SSHCONF $HOSTLOGIN $IPTABLES_CMD \
> $TESTRESULTDIR/${host}.iptables 2>/dev/null
chmod a+r $TESTRESULTDIR/*
cat >> $TESTRESULTDIR/index.html <<@EOF
@ -527,11 +537,11 @@ do
for file in clients.conf eap.conf radiusd.conf proxy.conf users
do
scp $HOSTLOGIN:/etc/raddb/$file \
scp $SSHCONF $HOSTLOGIN:/etc/raddb/$file \
$TESTRESULTDIR/${host}.$file > /dev/null 2>&1
done
scp $HOSTLOGIN:/var/log/radius/radius.log \
scp $SSHCONF $HOSTLOGIN:/var/log/radius/radius.log \
$TESTRESULTDIR/${host}.radius.log > /dev/null 2>&1
chmod a+r $TESTRESULTDIR/*
@ -585,7 +595,7 @@ do
if ($2 != "")
{
printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
}' $TESTDIR/posttest.dat` >> $CONSOLE_LOG 2>&1
@ -598,10 +608,10 @@ do
for host in $IPSECHOSTS
do
eval HOSTLOGIN=root@\$ipv4_${host}
ssh $HOSTLOGIN grep pluto /var/log/auth.log \
ssh $SSHCONF $HOSTLOGIN grep pluto /var/log/auth.log \
> $TESTRESULTDIR/${host}.auth.log
echo >> $TESTRESULTDIR/${host}.auth.log
ssh $HOSTLOGIN grep charon /var/log/auth.log \
ssh $SSHCONF $HOSTLOGIN grep charon /var/log/auth.log \
>> $TESTRESULTDIR/${host}.auth.log
done
@ -613,10 +623,10 @@ do
for host in $IPSECHOSTS
do
eval HOSTLOGIN=root@\$ipv4_${host}
ssh $HOSTLOGIN grep pluto /var/log/daemon.log \
ssh $SSHCONF $HOSTLOGIN grep pluto /var/log/daemon.log \
> $TESTRESULTDIR/${host}.daemon.log
echo >> $TESTRESULTDIR/${host}.daemon.log
ssh $HOSTLOGIN grep charon /var/log/daemon.log \
ssh $SSHCONF $HOSTLOGIN grep charon /var/log/daemon.log \
>> $TESTRESULTDIR/${host}.daemon.log
done
@ -630,7 +640,7 @@ do
if [ "`eval echo \\\$TDUP_${host}`" = "true" ]
then
echo "${host}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ipv4_$host killall tcpdump
eval ssh $SSHCONF root@\$ipv4_$host killall tcpdump
eval TDUP_${host}="false"
fi
done
@ -681,7 +691,7 @@ do
for host in $IPSECHOSTS
do
eval HOSTLOGIN=root@\$ipv4_${host}
ssh $HOSTLOGIN 'if [ -f /var/run/charon.pid ]; then rm /var/run/charon.pid; echo " removed charon.pid on `hostname`"; fi'
ssh $SSHCONF $HOSTLOGIN 'if [ -f /var/run/charon.pid ]; then rm /var/run/charon.pid; echo " removed charon.pid on `hostname`"; fi'
done
done
@ -736,10 +746,20 @@ cecho ""
HTDOCS="/var/www/localhost/htdocs"
cecho-n "Copying test results to winnetou.."
ssh root@${ipv4_winnetou} mkdir -p $HTDOCS/testresults > /dev/null 2>&1
scp -r $TODAYDIR root@${ipv4_winnetou}:$HTDOCS/testresults > /dev/null 2>&1
ssh root@${ipv4_winnetou} ln -s $HTDOCS/images $HTDOCS/testresults/$TESTDATE/images > /dev/null 2>&1
ssh $SSHCONF root@${ipv4_winnetou} mkdir -p $HTDOCS/testresults > /dev/null 2>&1
scp $SSHCONF -r $TODAYDIR root@${ipv4_winnetou}:$HTDOCS/testresults > /dev/null 2>&1
ssh $SSHCONF root@${ipv4_winnetou} ln -s $HTDOCS/images $HTDOCS/testresults/$TESTDATE/images > /dev/null 2>&1
cgecho "done"
cecho ""
cecho "The results are available in $TODAYDIR"
cecho "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
##########################################################################
# close ssh sessions
#
for host in $STRONGSWANHOSTS
do
kill `eval echo \\\$ssh_pid_$host`
done

View File

@ -45,7 +45,7 @@ then
for host in `ls $TESTSDIR/$testname/hosts`
do
eval HOSTLOGIN="root@`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
scp -r $TESTSDIR/$testname/hosts/$host/etc $HOSTLOGIN:/ > /dev/null 2>&1
scp $SSHCONF -r $TESTSDIR/$testname/hosts/$host/etc $HOSTLOGIN:/ > /dev/null 2>&1
done
fi
@ -57,7 +57,7 @@ fi
for host in $IPSECHOSTS
do
eval HOSTLOGIN="root@`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
ssh $HOSTLOGIN 'rm -f /var/log/auth.log /var/log/daemon.log; \
ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/auth.log /var/log/daemon.log; \
kill -SIGHUP `cat /var/run/syslogd.pid`' > /dev/null 2>&1
done
@ -69,6 +69,6 @@ done
for host in $RADIUSHOSTS
do
eval HOSTLOGIN="root@`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
ssh $HOSTLOGIN 'rm -f /var/log/radius/radius.log; \
ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/radius/radius.log; \
kill -SIGHUP `cat /var/run/syslogd.pid`' > /dev/null 2>&1
done

View File

@ -46,6 +46,6 @@ then
for host in `ls $TESTSDIR/${testname}/hosts`
do
eval HOSTLOGIN="root@`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
scp -r $HOSTCONFIGDIR/${host}/etc $HOSTLOGIN:/ > /dev/null 2>&1
scp $SSHCONF -r $HOSTCONFIGDIR/${host}/etc $HOSTLOGIN:/ > /dev/null 2>&1
done
fi

10
testing/ssh_config Normal file
View File

@ -0,0 +1,10 @@
Host *
# debian default
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
# faster encryption
Ciphers arcfour
# share multiple sessions
ControlMaster auto
ControlPath /tmp/ssh-uml-%r@%h:%p

View File

@ -87,6 +87,9 @@ UMLKERNEL=$BUILDDIR/linux-uml-$KERNELVERSION
# Directory where test results will be stored
TESTRESULTSDIR=$UMLTESTDIR/testresults
# SSH configuration (speedup SSH)
SSHCONF="-F $UMLTESTDIR/testing/ssh_config"
# Path to a full strongswan tree on the host system, which is
# mounted into /root/strongswan-shared. This gives us an easy
# way to apply and test changes instantly.