Tests for SMR + RTR with disjoint locators
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / smr_rtr_disjoint.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/smr_rtr_disjoint.sh
4
5 # set odl config json file names; they are common among all rtr tests
6 ODL_CONFIG_FILE1="vpp1.json"
7 ODL_CONFIG_FILE2="vpp2.json"
8 ODL_CONFIG_FILE3="elp1.json"
9 ODL_CONFIG_FILE4="elp2.json"
10
11 if [ "$1" == "clean" ] ; then
12   smr_rtr_disjoint_clean
13   exit 0
14 fi
15
16 if [[ $(id -u) != 0 ]]; then
17   echo "Error: run this as a root."
18   exit 1
19 fi
20
21 function test_ns_ping {
22   if [ "$1" != "${1#*[0-9].[0-9]}" ]; then
23     ip netns exec $2 ping -w 15 -c 1 "${1}"
24     rc=$?
25   elif [ "$1" != "${1#*:[0-9a-fA-F]}" ]; then
26     ip netns exec $2 ping6 -w 15 -c 1 "${1}"
27     rc=$?
28   else
29     echo "Unrecognized IP format '$1'"
30   fi
31   return $rc
32 }
33
34 function test_smr_rtr_disjoint {
35   # CONFIGURE
36   smr_rtr_disjoint_setup
37
38   if [ "$2" == "wait" ] ; then
39     read -p  "press any key to continue .." -n1
40   fi
41
42   test_result=1
43   rc=0
44
45   # TEST IP6 over IP4
46   test_ns_ping $1 vpp1-ns
47
48   rc=$?
49
50   if [ $rc -ne 0 ] ; then
51     echo "Simple test failed: No ICMP response received within specified timeout limit!"
52   else
53     echo "Simple test passed."
54     test_result=0
55   fi
56
57   if [ "$2" == "wait" ] ; then
58     read -p  "press any key to continue .." -n1
59   fi
60
61   # RECONFIGURE
62   smr_rtr_disjoint_reconfigure
63
64   if [ "$2" == "wait" ] ; then
65     read -p  "Topology reconfigured press any key to continue .." -n1
66   fi
67
68   # TEST IP6 over disjoing IP4 and IP6 underlay
69   test_ns_ping $1 vpp1-ns
70
71   rc=$?
72
73   if [ $rc -ne 0 ] ; then
74     echo "SMR+RTR test failed: No ICMP response received within specified timeout limit!"
75   else
76     echo "SMR+RTR test passed."
77     test_result=0
78   fi
79
80   if [ "$2" == "wait" ] ; then
81     read -p  "press any key to continue .." -n1
82   fi
83
84   # CLEANUP
85   smr_rtr_disjoint_clean
86
87   exit $test_result
88 }