Case: client teardown

This commit is contained in:
Ivan Ilves 2017-05-19 10:09:41 +02:00
parent 118b9f4567
commit a703c344d3
6 changed files with 46 additions and 6 deletions

View File

@ -19,6 +19,7 @@ script:
- testing/integration.sh basic_connectivity_with_ssh
- testing/integration.sh connect_with_ssh_agent
- testing/integration.sh connect_with_ssh_key
- testing/integration.sh do_client_teardown
branches:
only:

View File

@ -17,12 +17,18 @@ function setup(){
done
}
function complain(){
echo -e "\033[1;31m>>> ${@}\033[0m"
}
function run_case(){
declare -r CASE=${1}
declare -r XIRI_EXE=../../xiringuito
declare -r SSH_USER=root
eval `ssh-agent -s`; ssh-add ssh-keys/id_rsa
for DIST in ${DISTS}; do
echo
echo "[ RUN: ${1} / ${DIST} ]"
@ -34,9 +40,11 @@ function run_case(){
export LANG=C
export LC_ALL=C
[[ ${DEBUG} ]] && set -x
set -e
source cases/${1}.sh
set +e
[[ ${DEBUG} ]] && set +x
done
}
@ -49,10 +57,13 @@ function teardown(){
make docker-rm DIST=${DIST}
done
kill ${SSH_AGENT_PID}
if [[ "${SUCCESS}" == "true" ]]; then
echo
echo -e "\033[0;32m[ OK ]\033[0m"
echo
sleep 1
exit 0
fi
@ -65,6 +76,8 @@ function teardown(){
if [[ ${#} != 1 ]]; then
echo "Usage: $(basename ${0}) CASE"
echo
echo "HINT: Set 'DEBUG' environment variable to see case execution trace."
echo
echo "Available integration testing cases:"
echo "${CASES}"
exit 1

View File

@ -1,9 +1,3 @@
export EXIT_AFTER_CONNECT=1
eval `ssh-agent -s`
ssh-add ssh-keys/id_rsa
${XIRI_EXE} -X ${SSH_USER}@${REMOTE_IP}
kill ${SSH_AGENT_PID}

View File

@ -1,3 +1,5 @@
unset SSH_AUTH_SOCK
export SSH_EXTRA_OPTS="${SSH_EXTRA_OPTS} -i ${PWD}/ssh-keys/id_rsa"
export EXIT_AFTER_CONNECT=1

View File

@ -0,0 +1,30 @@
function get_client_links(){
ip link | egrep "tun[0-9]{1,2}" | cut -f2 -d' ' | tr '\n' ' '
}
ORIG_LINKS=$(get_client_links)
${XIRI_EXE} -X -R ${SSH_USER}@${REMOTE_IP} &
XIRI_PID=${!}; sleep 2
NEW_LINKS=$(get_client_links)
kill ${XIRI_PID}; sleep 2
if [[ $(ps -p ${XIRI_PID} | wc -l) -eq 2 ]]; then
kill -9 ${XIRI_PID} &>/dev/null
sleep 2
fi
FINAL_LINKS=$(get_client_links)
if [[ "${ORIG_LINKS}" == "${NEW_LINKS}" ]]; then
complain "TUNx link state should change after xiringuito started and connected!"
complain "* Original : ${ORIG_LINKS}"
complain "* New : ${NEW_LINKS}"
exit 1
fi
if [[ "${ORIG_LINKS}" != "${FINAL_LINKS}" ]]; then
complain "TUNx link state should be restored after xiringuito stop!"
complain "* Original : ${ORIG_LINKS}"
complain "* Final : ${FINAL_LINKS}"
exit 1
fi