testing: Use tar instead of recursive scp

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.
This commit is contained in:
Tobias Brunner 2025-04-04 11:07:21 +02:00
parent d7eb3ed92e
commit 353d5c130b
3 changed files with 19 additions and 4 deletions

View File

@ -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/*
##########################################################################

View File

@ -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

View File

@ -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