mirror of
https://github.com/ivanilves/xiringuito.git
synced 2025-05-31 06:20:22 -07:00
Case: client teardown
This commit is contained in:
parent
118b9f4567
commit
a703c344d3
@ -19,6 +19,7 @@ script:
|
|||||||
- testing/integration.sh basic_connectivity_with_ssh
|
- testing/integration.sh basic_connectivity_with_ssh
|
||||||
- testing/integration.sh connect_with_ssh_agent
|
- testing/integration.sh connect_with_ssh_agent
|
||||||
- testing/integration.sh connect_with_ssh_key
|
- testing/integration.sh connect_with_ssh_key
|
||||||
|
- testing/integration.sh do_client_teardown
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
|
@ -17,12 +17,18 @@ function setup(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function complain(){
|
||||||
|
echo -e "\033[1;31m>>> ${@}\033[0m"
|
||||||
|
}
|
||||||
|
|
||||||
function run_case(){
|
function run_case(){
|
||||||
declare -r CASE=${1}
|
declare -r CASE=${1}
|
||||||
|
|
||||||
declare -r XIRI_EXE=../../xiringuito
|
declare -r XIRI_EXE=../../xiringuito
|
||||||
declare -r SSH_USER=root
|
declare -r SSH_USER=root
|
||||||
|
|
||||||
|
eval `ssh-agent -s`; ssh-add ssh-keys/id_rsa
|
||||||
|
|
||||||
for DIST in ${DISTS}; do
|
for DIST in ${DISTS}; do
|
||||||
echo
|
echo
|
||||||
echo "[ RUN: ${1} / ${DIST} ]"
|
echo "[ RUN: ${1} / ${DIST} ]"
|
||||||
@ -34,9 +40,11 @@ function run_case(){
|
|||||||
export LANG=C
|
export LANG=C
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
|
||||||
|
[[ ${DEBUG} ]] && set -x
|
||||||
set -e
|
set -e
|
||||||
source cases/${1}.sh
|
source cases/${1}.sh
|
||||||
set +e
|
set +e
|
||||||
|
[[ ${DEBUG} ]] && set +x
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,10 +57,13 @@ function teardown(){
|
|||||||
make docker-rm DIST=${DIST}
|
make docker-rm DIST=${DIST}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
kill ${SSH_AGENT_PID}
|
||||||
|
|
||||||
if [[ "${SUCCESS}" == "true" ]]; then
|
if [[ "${SUCCESS}" == "true" ]]; then
|
||||||
echo
|
echo
|
||||||
echo -e "\033[0;32m[ OK ]\033[0m"
|
echo -e "\033[0;32m[ OK ]\033[0m"
|
||||||
echo
|
echo
|
||||||
|
sleep 1
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -65,6 +76,8 @@ function teardown(){
|
|||||||
if [[ ${#} != 1 ]]; then
|
if [[ ${#} != 1 ]]; then
|
||||||
echo "Usage: $(basename ${0}) CASE"
|
echo "Usage: $(basename ${0}) CASE"
|
||||||
echo
|
echo
|
||||||
|
echo "HINT: Set 'DEBUG' environment variable to see case execution trace."
|
||||||
|
echo
|
||||||
echo "Available integration testing cases:"
|
echo "Available integration testing cases:"
|
||||||
echo "${CASES}"
|
echo "${CASES}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
export EXIT_AFTER_CONNECT=1
|
export EXIT_AFTER_CONNECT=1
|
||||||
|
|
||||||
eval `ssh-agent -s`
|
|
||||||
|
|
||||||
ssh-add ssh-keys/id_rsa
|
|
||||||
|
|
||||||
${XIRI_EXE} -X ${SSH_USER}@${REMOTE_IP}
|
${XIRI_EXE} -X ${SSH_USER}@${REMOTE_IP}
|
||||||
|
|
||||||
kill ${SSH_AGENT_PID}
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
unset SSH_AUTH_SOCK
|
||||||
|
|
||||||
export SSH_EXTRA_OPTS="${SSH_EXTRA_OPTS} -i ${PWD}/ssh-keys/id_rsa"
|
export SSH_EXTRA_OPTS="${SSH_EXTRA_OPTS} -i ${PWD}/ssh-keys/id_rsa"
|
||||||
export EXIT_AFTER_CONNECT=1
|
export EXIT_AFTER_CONNECT=1
|
||||||
|
|
||||||
|
30
testing/integration/cases/do_client_teardown.sh
Normal file
30
testing/integration/cases/do_client_teardown.sh
Normal 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
|
Loading…
x
Reference in New Issue
Block a user