From 4543d2821b1ab69579a525d83497ff84e9084bed Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 16 Aug 2016 23:37:40 +0200 Subject: Small improvements - update function to check if odl is up - add global function (and option) to clean test sate - fix test driver script Change-Id: I80e4908d3a266ce064e5823f310f7a2302c10577 Signed-off-by: Florin Coras Signed-off-by: Filip Tehlar --- tests/data_plane/vpp_lite_topo/config.sh | 63 ++++++++++++++++++++++ tests/data_plane/vpp_lite_topo/odl_utils.sh | 7 +++ tests/data_plane/vpp_lite_topo/run.sh | 18 +++---- .../test_driver/basic_multi_traffic.sh | 8 ++- 4 files changed, 85 insertions(+), 11 deletions(-) diff --git a/tests/data_plane/vpp_lite_topo/config.sh b/tests/data_plane/vpp_lite_topo/config.sh index f7afa3c..1fa060a 100644 --- a/tests/data_plane/vpp_lite_topo/config.sh +++ b/tests/data_plane/vpp_lite_topo/config.sh @@ -17,3 +17,66 @@ if [ ! -f "${VPP_LITE_BIN}" ] ; then echo "VPP_LITE_BIN=${VPP_LITE_BIN}" exit 1 fi + +function clean_all +{ + echo "Clearing all VPP instances.." + pkill vpp --signal 9 + rm /dev/shm/* &> /dev/null + + echo "Cleaning topology.." + ip netns exec intervppns ifconfig vppbr down &> /dev/null + ip netns exec intervppns brctl delbr vppbr &> /dev/null + ip netns exec intervppns1 ifconfig vppbr down &> /dev/null + ip netns exec intervppns1 brctl delbr vppbr &> /dev/null + ip netns exec intervppns2 ifconfig vppbr down &> /dev/null + ip netns exec intervppns2 brctl delbr vppbr &> /dev/null + ip netns exec intervpp-ns ifconfig vppbr1 down &> /dev/null + ip netns exec intervpp-ns brctl delbr vppbr1 &> /dev/null + ip netns exec xtr-rtr-ns ifconfig vppbr1 down &> /dev/null + ip netns exec xtr-rtr-ns brctl delbr vppbr1 &> /dev/null + + ip link del dev veth_vpp1 &> /dev/null + ip link del dev veth_vpp2 &> /dev/null + ip link del dev vpp1_cus1 &> /dev/null + ip link del dev vpp2_cus1 &> /dev/null + ip link del dev vpp1_cus2 &> /dev/null + ip link del dev vpp2_cus2 &> /dev/null + ip link del dev vpp1 &> /dev/null + ip link del dev vpp2 &> /dev/null + + ip link del dev veth_intervpp1 &> /dev/null + ip link del dev veth_intervpp2 &> /dev/null + ip link del dev veth_intervpp11 &> /dev/null + ip link del dev veth_intervpp12 &> /dev/null + ip link del dev veth_intervpp21 &> /dev/null + ip link del dev veth_intervpp22 &> /dev/null + ip link del dev intervpp1 &> /dev/null + ip link del dev intervpp2 &> /dev/null + ip link del dev xtr_rtr1 &> /dev/null + ip link del dev xtr_rtr2 &> /dev/null + ip link del dev xtr_rtr3 &> /dev/null + + ip link del dev veth_odl &> /dev/null + ip link del dev odl &> /dev/null + + ip netns del vppns1 &> /dev/null + ip netns del vppns2 &> /dev/null + ip netns del intervppns &> /dev/null + ip netns del intervppns1 &> /dev/null + ip netns del intervppns2 &> /dev/null + ip netns del vpp1-cus1-ns &> /dev/null + ip netns del vpp1-cus2-ns &> /dev/null + ip netns del vpp2-cus1-ns &> /dev/null + ip netns del vpp2-cus2-ns &> /dev/null + ip netns del intervpp-ns &> /dev/null + ip netns del vpp-ns1 &> /dev/null + ip netns del vpp-ns2 &> /dev/null + ip netns del xtr-rtr-ns &> /dev/null + + if [ "$1" != "no_odl" ] ; then + odl_clear_all + fi + + +} diff --git a/tests/data_plane/vpp_lite_topo/odl_utils.sh b/tests/data_plane/vpp_lite_topo/odl_utils.sh index 8a2b8bc..44064c0 100644 --- a/tests/data_plane/vpp_lite_topo/odl_utils.sh +++ b/tests/data_plane/vpp_lite_topo/odl_utils.sh @@ -14,3 +14,10 @@ function odl_clear_all { curl -X DELETE "http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database" \ -u ${ODL_USER}:${ODL_PASSWD} } + +function check_odl_running { + if [ -z "`netstat -tunlp | grep 8181`" ] ; then + echo "ODL is not running!" + exit 1 + fi +} diff --git a/tests/data_plane/vpp_lite_topo/run.sh b/tests/data_plane/vpp_lite_topo/run.sh index aa0a298..d51b552 100755 --- a/tests/data_plane/vpp_lite_topo/run.sh +++ b/tests/data_plane/vpp_lite_topo/run.sh @@ -11,9 +11,10 @@ function help echo echo This must be run with superuser privileges. echo "Usage:" - echo " ./run.sh [vh]" + echo " ./run.sh [vhc]" echo echo " -v : verbose output" + echo " -c : clean" echo " -h : show help" } @@ -28,6 +29,9 @@ while [ $# -gt 0 ] ; do elif [ $arg == "-h" ] ; then help exit 0 + elif [ $arg == "-c" ] ; then + clean_all + exit 0 fi done @@ -40,20 +44,16 @@ passed_num=0 start_time=`date +%s` -# check whether ODL is running -if [ "`curl -X DELETE \ - "http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database" \ - -u ${ODL_USER}:${ODL_PASSWD} -s -o /dev/null -w "%{http_code}"`" != 200 ] ; then - echo "ODL is not running!" - exit 1 -fi - # sudo? if [[ $(id -u) != 0 ]]; then echo "Superuser privileges needed!" exit 1 fi +# check whether ODL is running +check_odl_running + + # count tests test_num=`ls -l "$TESTS_DIR"/test_* | wc -l` diff --git a/tests/data_plane/vpp_lite_topo/test_driver/basic_multi_traffic.sh b/tests/data_plane/vpp_lite_topo/test_driver/basic_multi_traffic.sh index 1dc8ae0..81fd0ff 100644 --- a/tests/data_plane/vpp_lite_topo/test_driver/basic_multi_traffic.sh +++ b/tests/data_plane/vpp_lite_topo/test_driver/basic_multi_traffic.sh @@ -27,7 +27,7 @@ function test_basic_multi_traffic test_result=1 - if [ "$3" == "wait" ] ; then + if [ "$5" == "wait" ] ; then read -p "press any key to continue .." -n1 fi @@ -56,6 +56,10 @@ function test_basic_multi_traffic ODL_CONFIG_DIR=`pwd`/../configs/odl/basic/4o4 post_curl "update-mapping" ${ODL_CONFIG_FILE3} + if [ "$5" == "wait" ] ; then + read -p "press any key to continue .." -n1 + fi + ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}" if [ $? -ne 0 ] ; then echo "No response received!" @@ -66,7 +70,7 @@ function test_basic_multi_traffic ip netns exec vppns1 "${3}" -w 15 -c 1 "${4}" rc=$? - if [ "$3" == "wait" ] ; then + if [ "$5" == "wait" ] ; then read -p "press any key to continue .." -n1 fi -- cgit 1.2.3-korg