testing: Use an on-guest script to cleanup/initialize and run them in parallel

This is a bit quicker than doing this with separate SSH calls for each
host sequentially (up to half a second per test).
This commit is contained in:
Tobias Brunner
2024-12-03 08:43:45 +01:00
parent c8cfeeff54
commit b3a72c7994
2 changed files with 59 additions and 47 deletions
+38
View File
@@ -0,0 +1,38 @@
#! /bin/bash
while getopts "i:d:" opt
do
case "$opt" in
i)
INTERFACE=${OPTARG}
;;
d)
DB=${OPTARG}
esac
done
shift $((OPTIND-1))
# start tcpdump in the background
if [ -n "$INTERFACE" ]
then
tcpdump -l --immediate-mode -i $INTERFACE not port ssh and not port domain >/tmp/tcpdump.log 2>/tmp/tcpdump.err.log &
fi
# setup ramdisk for databases
if [ -n "$DB" ]
then
mkdir -p $DB
mount -t ramfs -o size=5m ramfs $DB
chgrp www-data $DB
chmod g+w $DB
fi
# flush conntrack table
conntrack -F >/dev/null 2>&1
# flush IPsec state
ip xfrm state flush
ip xfrm policy flush
# remove leak detective log
rm -f $LEAK_DETECTIVE_LOG