Merge branch 'tmp-tests-stability' into 'master'

tests: improve stability of certain tests

See merge request openconnect/ocserv!191
This commit is contained in:
Nikos Mavrogiannopoulos
2020-06-30 11:47:01 +00:00
4 changed files with 58 additions and 18 deletions

View File

@@ -140,7 +140,7 @@ RPM/epel7:
- CURDIR=$(pwd)
- TARFILE=$(find ./ -name '*.tar.xz')
- RPMVERSION=$(cat /usr/local/rpms/ocserv/*.spec|grep ^Version|awk '{print $2}')
- sed -i '/^%{_sbindir}\/ocserv$/ a %{_sbindir}/ocserv-worker' /usr/local/rpms/ocserv/ocserv.spec
- sed -i 's/XFAIL_TESTS=test-sighup-key-change//' /usr/local/rpms/ocserv/ocserv.spec
- NEWVERSION=$(echo $TARFILE|sed -e 's/ocserv-//' -e 's/\.tar\.xz//' -e 's|./||')
- echo "tarfile $TARFILE" && echo "rpm $RPMVERSION" && echo "new $NEWVERSION"
- cp $TARFILE /usr/local/rpms/ocserv
@@ -177,7 +177,7 @@ RPM/epel8:
- CURDIR=$(pwd)
- TARFILE=$(find ./ -name '*.tar.xz')
- RPMVERSION=$(cat /usr/local/rpms/ocserv/*.spec|grep ^Version|awk '{print $2}')
- sed -i '/^%{_sbindir}\/ocserv$/ a %{_sbindir}/ocserv-worker' /usr/local/rpms/ocserv/ocserv.spec
- sed -i 's/XFAIL_TESTS=test-sighup-key-change//' /usr/local/rpms/ocserv/ocserv.spec
- NEWVERSION=$(echo $TARFILE|sed -e 's/ocserv-//' -e 's/\.tar\.xz//' -e 's|./||')
- echo "tarfile $TARFILE" && echo "rpm $RPMVERSION" && echo "new $NEWVERSION"
- cp $TARFILE /usr/local/rpms/ocserv

View File

@@ -110,12 +110,6 @@ auth-timeout = 40
# a failed authentication attempt.
#min-reauth-time = 2
# Cookie validity time (in seconds)
# Once a client is authenticated he's provided a cookie with
# which he can reconnect. This option sets the maximum lifetime
# of that cookie.
cookie-validity = 172800
# Script to call when a client connects and obtains an IP
# Parameters are passed on the environment.
# REASON, USERNAME, GROUPNAME, HOSTNAME (the hostname selected by client),

View File

@@ -68,6 +68,28 @@ function finish {
}
trap finish EXIT
function wait_file_contents {
local file=$1
local contents=$2
local max_time=$3
local time=0
while [ ${time} -lt ${max_time} ]
do
sleep 5
grep -E "${contents}" "${file}" >/dev/null
if test $? = 0;then
echo "Found ${contents} (waited ${time})"
return 0
fi
let time+=5
done
#timeout
echo "Could not find ${contents} in ${file} after ${time} secs"
exit 1
}
# server address
ADDRESS=10.102.246.1
CLI_ADDRESS=10.102.247.1
@@ -85,6 +107,7 @@ OCCTL_SOCKET=./occtl-radius-$$.socket
${CMDNS2} ${IP} link set dev lo up
# Run servers
rm -f ${RADIUSLOG}
${CMDNS2} ${RADIUSD} -d ${srcdir}/data/raddb/ -s -x -l ${RADIUSLOG} &
RADIUSPID=$!
@@ -138,9 +161,9 @@ fi
echo "Waiting for accounting report"
sleep 28
wait_file_contents ${RADIUSLOG} "Acct-Input-Octets = [1-9]+" 35
OCTETS=$(cat ${RADIUSLOG}|grep Acct-Input-Octets|tail -1|sed 's/Acct-Input-Octets = //g')
OCTETS=$(cat ${RADIUSLOG}|grep Acct-Input-Octets|tail -1|sed 's/.*Acct-Input-Octets = //g')
if test -z "$OCTETS" || test "$OCTETS" = 0;then
cat ${RADIUSLOG}|grep Acct-Input-Octets
echo "Interim update showed no data!"
@@ -149,7 +172,7 @@ fi
echo "Transferred ${OCTETS} bytes"
echo "Waiting for disconnection report"
sleep 60
wait_file_contents ${RADIUSLOG} "Acct-Terminate-Cause" 70
DISC=$(cat ${RADIUSLOG}|grep "Acct-Status-Type = Start"|tail -1)
if test -z "$DISC";then

View File

@@ -57,11 +57,31 @@ function finish {
rm "${OUTFILE}" "${CONFIG_UDP_LISTEN_LOCAL}"
# first openconnect cli will exit after ocserv is killed/restarted
kill "$(cat "${CLIPID2}")"
rm "${CLIPID2}"
test -f "${CLIPID2}" && kill "$(cat "${CLIPID2}")"
test -f "${CLIPID}" && kill "$(cat "${CLIPID}")"
rm -f "${CLIPID2}" "${CLIPID}"
}
trap finish EXIT
function wait_file {
local file=$1
local max_time=$2
local time=0
while [ ${time} -lt ${max_time} ]
do
sleep 5
if test -e ${file};then
echo "Found file (waited ${time})"
return 0
fi
let time+=5
done
#timeout
echo "Could not find ${file} after ${time} secs"
}
# server address
ADDRESS=10.201.2.1
CLI_ADDRESS=10.201.1.1
@@ -91,9 +111,9 @@ sleep 3
echo " * Connecting to haproxy and using dtls ... "
echo "test" | ${CMDNS1} ${OPENCONNECT} ${ADDRESS}:${HAPORT} --user test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true --verbose --pid-file "${CLIPID}" --background
${OCCTL} -s ${OCCTL_SOCKET} show user ${USERNAME} >${OUTFILE}
wait_file "${CLIPID}" 11
sleep 3
${OCCTL} -s ${OCCTL_SOCKET} show user ${USERNAME} >${OUTFILE}
grep "DTLS cipher:" ${OUTFILE}
if test $? != 0;then
@@ -101,17 +121,20 @@ if test $? != 0;then
exit 1
fi
test -n "${PID}" && kill "${PID}" >/dev/null 2>&1
test -n "${PID}" && kill "${PID}" >/dev/null
sed -e "s/^udp-listen-host = ${ADDRESS}/udp-listen-host = 127.0.0.1/" "${CONFIG}" >${CONFIG_UDP_LISTEN_LOCAL}
kill -9 "${PID}" >/dev/null
wait ${PID}
kill "$(cat "${CLIPID}")"
sleep 1
echo "restart ocsev with udp-listen-host set to 127.0.0.1"
${CMDNS2} ${SERV} -p ${PIDFILE} -f -c ${CONFIG_UDP_LISTEN_LOCAL} ${DEBUG} & PID=$!
echo " * Connecting to haproxy and using dtls again ... "
echo "test" | ${CMDNS1} ${OPENCONNECT} ${ADDRESS}:${HAPORT} --user test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true --verbose --pid-file "${CLIPID2}" --background
sleep 3
wait_file "${CLIPID2}" 11
${OCCTL} -s ${OCCTL_SOCKET} show user ${USERNAME} >${OUTFILE}