Refactor basic LISP tests
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / basic.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/basic_topo.sh
4
5 ODL_CONFIG_FILE1="vpp1.json"
6 ODL_CONFIG_FILE2="vpp2.json"
7 ODL_CONFIG_FILE3="update_vpp2.json"
8
9 if [ "$1" == "clean" ] ; then
10   basic_topo_clean
11   exit 0
12 fi
13
14 if [[ $(id -u) != 0 ]]; then
15   echo "Error: run this as a root."
16   exit 1
17 fi
18
19 function test_basic
20 {
21   if [ "$3" != "no_setup" ] ; then
22     basic_topo_setup
23   fi
24
25   test_result=1
26
27   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
28   rc=$?
29   if [ $rc -ne 0 ] ; then
30     echo "No response received!"
31     basic_topo_clean
32     exit $test_result
33   fi
34
35   # change IP addresses of destination RLOC
36   echo "set int ip address del host-intervpp2 6.0.3.2/24" | nc 0 5003
37   echo "set int ip address host-intervpp2 6.0.3.20/24" | nc 0 5003
38   echo "set int ip address del host-intervpp2 6:0:3::2/24" | nc 0 5003
39   echo "set int ip address host-intervpp2 6:0:3::20/24" | nc 0 5003
40   post_curl "update-mapping" ${ODL_CONFIG_FILE3}
41
42   ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
43   rc=$?
44
45   # test done
46
47   basic_topo_clean
48   if [ $rc -ne 0 ] ; then
49     echo "Test failed: No ICMP response received within specified timeout limit!"
50   else
51     echo "Test passed."
52     test_result=0
53   fi
54
55   exit $test_result
56 }