99c74bf3db89907e1cf3bcf986ef58f3c95636d5
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / src_dst.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/3_node_star.sh
4
5 ODL_CONFIG_FILE1="map1.json"
6 ODL_CONFIG_FILE2="map2.json"
7
8 if [ "$1" == "clean" ] ; then
9   3_node_star_topo_clean
10   exit 0
11 fi
12
13 if [[ $(id -u) != 0 ]]; then
14   echo "Error: run this as a root."
15   exit 1
16 fi
17
18 function send_ping_from_ns
19 {
20   ip netns exec "${1}" "${2}" -w 20 -c 1 "${3}"
21   assert_rc_ok $? 3_node_star_topo_clean "No ICMP Response!"
22 }
23
24 function send_ping_from_ns_no_verify
25 {
26   ip netns exec "${1}" "${2}" -c 1 "${3}"
27 }
28
29 function test_src_dst
30 {
31   3_node_star_topo_setup
32   post_curl "add-mapping" "map3.json"
33   post_curl "add-mapping" "map4.json"
34
35   maybe_pause
36
37   test_result=1
38
39   # send ping for first EID
40   send_ping_from_ns vpp-ns1 ${1} ${2}
41
42   # TODO assert counters
43
44   maybe_pause
45
46   # send ping for second EID
47   send_ping_from_ns vpp-ns3 ${1} ${2}
48
49   maybe_pause
50
51   # verify first tunnel still works
52   send_ping_from_ns vpp-ns1 ${1} ${2}
53
54   maybe_pause
55
56   # verify second tunnel still works
57   send_ping_from_ns vpp-ns3 ${1} ${2}
58   rc=$?
59
60   maybe_pause
61   3_node_star_topo_clean
62   print_status $rc "No ICM response!"
63   exit $test_result
64 }
65
66 function test_src_dst_l2
67 {
68   3_node_star_topo_setup
69   post_curl "add-mapping" "map3.json"
70   post_curl "add-mapping" "map4.json"
71
72   maybe_pause
73
74   test_result=1
75
76   # send ping for first EID
77   send_ping_from_ns vpp-ns5 ${1} ${2}
78
79   # TODO assert counters
80
81   maybe_pause
82
83   # send ping for second EID
84   send_ping_from_ns vpp-ns8 ${1} ${2}
85
86   maybe_pause
87
88   # verify first tunnel still works
89   send_ping_from_ns vpp-ns5 ${1} ${2}
90
91   maybe_pause
92
93   # verify second tunnel still works
94   send_ping_from_ns vpp-ns8 ${1} ${2}
95   rc=$?
96
97   maybe_pause
98   3_node_star_topo_clean
99   print_status $rc "No ICM response!"
100   exit $test_result
101 }
102
103 function mapping_exists
104 {
105   python scripts/vat/mapping_exists.py ${VPP_API_TEST} "$1" "$2" ${VAT_TEMPLATES}
106 }
107
108 function test_mapping_timers
109 {
110   3_node_star_topo_setup
111   post_curl "add-mapping" "map3.json"
112   post_curl "add-mapping" "map4.json"
113
114   maybe_pause
115
116   test_result=1
117
118   send_ping_from_ns vpp-ns1 ${1} ${2}
119   send_ping_from_ns vpp-ns3 ${1} ${2}
120
121   # wait for map-requests to resolve
122   sleep 2
123
124   mapping_exists "vpp1" "6.0.1.0/24|6.0.2.0/24"
125   assert_rc_ok $? 3_node_star_topo_clean "mapping not in map-cache!"
126   mapping_exists "vpp2" "6.0.1.0/24"
127   assert_rc_ok $? 3_node_star_topo_clean "mapping not in map-cache!"
128
129   # sleep enough so the mapping expires
130   sleep 65
131
132   mapping_exists "vpp1" "6.0.1.0/24|6.0.2.0/24"
133   assert_rc_not_ok $? 3_node_star_topo_clean "mapping still present in map-cache!"
134   mapping_exists "vpp2" "6.0.1.0/24"
135   assert_rc_not_ok $? 3_node_star_topo_clean "mapping still present in map-cache!"
136
137   maybe_pause
138   3_node_star_topo_clean
139   echo "Test passed."
140   exit 0
141 }