]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
testing: Use tar instead of recursive scp
authorTobias Brunner <tobias@strongswan.org>
Fri, 4 Apr 2025 09:07:21 +0000 (11:07 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 7 Apr 2025 12:54:48 +0000 (14:54 +0200)
It seems that scp is sometimes very slow (unclear what causes it as it's
not always the same).  Packing up the files with tar performs a lot
better in these situations.  And copying the files to multiple hosts
in parallel additionally helps to reduce the time required for these
steps.

Using --overwrite and -h preserves existing symlinks (e.g. for the users
file in /etc/freeradius/3.0) and overwrites the target file instead.
The -m option ignores timestamps when extracting the files as some target
files will be newer than the source.  Using -h when packing up files in
load-testconfig allows using symlinks in the test config dirs to files
on the host running the tests.

testing/do-tests
testing/scripts/load-testconfig
testing/scripts/restore-defaults

index e2a60aa63015d6fbbb60664495ce0fac06fa87f6..28337c022f35aa76968d6e8daadd6aaf0f4750eb 100755 (executable)
@@ -580,11 +580,17 @@ else
 
        test ${#WAIT_FOR[@]} -gt 0 && wait ${WAIT_FOR[@]}
 
+       WAIT_FOR=()
+
        for host in ${!COLLECT_OPTIONS[@]}
        do
                eval HOSTLOGIN=root@\$ipv4_${host}
-               scp $SSHCONF -q $HOSTLOGIN:${GUEST_OUTPUT_DIR}/* $TESTRESULTDIR/
+               ssh $SSHCONF $HOSTLOGIN "tar -cf - -C ${GUEST_OUTPUT_DIR} ." | tar -xf - -C $TESTRESULTDIR/ &
+               WAIT_FOR+=($!)
        done
+
+       test ${#WAIT_FOR[@]} -gt 0 && wait ${WAIT_FOR[@]}
+
        chmod a+r $TESTRESULTDIR/*
 
        ##########################################################################
index 3101467d6e96892330ced0d90330fd7497355006..49fb2fbcad559b68bdc1ceaca35ed6740e57b56b 100755 (executable)
@@ -135,16 +135,20 @@ done
 source $TESTDIR/test.conf
 
 ##########################################################################
-# copy test specific configurations to uml hosts
+# copy test specific configurations to hosts
 #
 
+WAIT_FOR=()
+
 if [ -d $TESTDIR/hosts ]
 then
        for host in `ls $TESTDIR/hosts`
        do
                eval HOSTLOGIN=root@\$ipv4_${host}
-               scp $SSHCONF -r $TESTDIR/hosts/$host/etc $HOSTLOGIN:/ > /dev/null 2>&1
+               tar -chf - -C $TESTDIR/hosts/$host etc | ssh $SSHCONF $HOSTLOGIN 'tar --overwrite -xhmf - -C /' &
+               WAIT_FOR+=($!)
        done
+       wait ${WAIT_FOR[@]}
 fi
 
 
index a88f3eb8915f72bbb31a7e4e74f2df0356c710b2..29ec1905e06b8ec2c008835cc20b7fc9fa000dab 100755 (executable)
@@ -30,11 +30,16 @@ TESTSDIR=$BUILDDIR/tests
 
 . $TESTSDIR/$testname/test.conf
 
+# load files in parallel
+WAIT_FOR=()
+
 if [ -d $TESTSDIR/${testname}/hosts ]
 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 $SSHCONF -r $HOSTCONFIGDIR/default/etc $HOSTCONFIGDIR/${host}/etc $HOSTLOGIN:/ >/dev/null 2>&1
+               tar -cf - -C $HOSTCONFIGDIR/default etc -C ../${host} etc | ssh $SSHCONF $HOSTLOGIN 'tar --overwrite -xhmf - -C /' &
+               WAIT_FOR+=($!)
        done
+       wait ${WAIT_FOR[@]}
 fi