diff --git a/.travis.yml b/.travis.yml index 13285fc..c19fbc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ script: - testing/run_integration_case.sh connect_with_ssh_key - testing/run_integration_case.sh do_client_teardown - testing/run_integration_case.sh do_server_teardown + - testing/run_integration_case.sh run_with_dns_propagation branches: only: diff --git a/testing/integration/cases/do_client_teardown.sh b/testing/integration/cases/do_client_teardown.sh index 3ee8204..63c4686 100644 --- a/testing/integration/cases/do_client_teardown.sh +++ b/testing/integration/cases/do_client_teardown.sh @@ -11,11 +11,7 @@ ${XIRI_EXE} -X -R ${SSH_USER}@${REMOTE_IP} & XIRI_PID=${!}; sleep ${INIT_DELAY} NEW_LINKS=$(get_client_links) -kill ${XIRI_PID}; sleep ${DOWN_DELAY} -if [[ $(ps -p ${XIRI_PID} | wc -l) -eq 2 ]]; then - kill -9 ${XIRI_PID} &>/dev/null - sleep ${DOWN_DELAY} -fi +kill_reliably ${XIRI_PID} ${DOWN_DELAY} FINAL_LINKS=$(get_client_links) if [[ "${ORIG_LINKS}" == "${NEW_LINKS}" ]]; then diff --git a/testing/integration/cases/do_server_teardown.sh b/testing/integration/cases/do_server_teardown.sh index 8349cad..ca6ba3d 100644 --- a/testing/integration/cases/do_server_teardown.sh +++ b/testing/integration/cases/do_server_teardown.sh @@ -12,11 +12,7 @@ ${XIRI_EXE} -f 1 -X -R ${SSH_USER}@${REMOTE_IP} & XIRI_PID=${!}; sleep ${INIT_DELAY} NEW_LINKS=$(get_server_links) -kill ${XIRI_PID}; sleep ${DOWN_DELAY} -if [[ $(ps -p ${XIRI_PID} | wc -l) -eq 2 ]]; then - kill -9 ${XIRI_PID} &>/dev/null - sleep ${DOWN_DELAY} -fi +kill_reliably ${XIRI_PID} ${DOWN_DELAY} FINAL_LINKS=$(get_server_links) diff --git a/testing/integration/cases/run_with_dns_propagation.sh b/testing/integration/cases/run_with_dns_propagation.sh index e69de29..36ae54d 100644 --- a/testing/integration/cases/run_with_dns_propagation.sh +++ b/testing/integration/cases/run_with_dns_propagation.sh @@ -0,0 +1,18 @@ +INIT_DELAY=20 +DOWN_DELAY=20 + +ORIG_RESOLV_CONF=$(cat /etc/resolv.conf) +warn "${ORIG_RESOLV_CONF}" + +${XIRI_EXE} -f 1 -X -R ${SSH_USER}@${REMOTE_IP} 10.245.245.245/32 & +XIRI_PID=${!}; sleep ${INIT_DELAY} + +NEW_RESOLV_CONF=$(cat /etc/resolv.conf) +warn "${NEW_RESOLV_CONF}" + +if [[ "${ORIG_RESOLV_CONF}" == "${NEW_RESOLV_CONF}" ]]; then + complain "Should update /etc/resolv.conf" + exit 1 +fi + +kill_reliably ${XIRI_PID} ${DOWN_DELAY} diff --git a/testing/run_integration_case.sh b/testing/run_integration_case.sh index eec26cf..7b94044 100755 --- a/testing/run_integration_case.sh +++ b/testing/run_integration_case.sh @@ -17,6 +17,22 @@ function setup(){ done } +function kill_reliably(){ + local TARGET_PID=${1} + local CHECK_DELAY=${2} + + kill ${TARGET_PID} + sleep ${CHECK_DELAY} + if [[ $(ps -p ${TARGET_PID} | wc -l) -eq 2 ]]; then + kill -9 ${TARGET_PID} &>/dev/null + sleep ${CHECK_DELAY} + fi +} + +function warn(){ + echo -e "\033[1;33m${@}\033[0m" +} + function complain(){ echo -e "\033[1;31m>>> ${@}\033[0m" }