src_dst.sh revision f3ac1dd5
1source config.sh
2source odl_utils.sh
3source topologies/3_node_star.sh
4
5ODL_CONFIG_FILE1="map1.json"
6ODL_CONFIG_FILE2="map2.json"
7
8if [ "$1" == "clean" ] ; then
9  3_node_star_topo_clean
10  exit 0
11fi
12
13if [[ $(id -u) != 0 ]]; then
14  echo "Error: run this as a root."
15  exit 1
16fi
17
18function 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
24function send_ping_from_ns_no_verify
25{
26  ip netns exec "${1}" "${2}" -c 1 "${3}"
27}
28
29function 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 ICMP response!"
63  exit $test_result
64}
65
66function 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 ICMP response!"
100  exit $test_result
101}
102
103function mapping_exists
104{
105  python scripts/vat/mapping_exists.py ${VPP_API_TEST} "$1" "$2" ${VAT_TEMPLATES}
106}
107
108function 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 "vpp1" "6.0.5.0/24|6.0.2.0/24"
127  assert_rc_ok $? 3_node_star_topo_clean "mapping not in map-cache!"
128  mapping_exists "vpp2" "6.0.1.0/24"
129  assert_rc_ok $? 3_node_star_topo_clean "mapping not in map-cache!"
130
131  # sleep enough so the mapping expires
132  sleep 65
133
134  maybe_pause
135
136  mapping_exists "vpp1" "6.0.1.0/24|6.0.2.0/24"
137  assert_rc_not_ok $? 3_node_star_topo_clean "mapping still present in map-cache!"
138  mapping_exists "vpp1" "6.0.5.0/24|6.0.2.0/24"
139  assert_rc_not_ok $? 3_node_star_topo_clean "mapping still present in map-cache!"
140  mapping_exists "vpp2" "6.0.1.0/24"
141  assert_rc_not_ok $? 3_node_star_topo_clean "mapping still present in map-cache!"
142
143  maybe_pause
144  3_node_star_topo_clean
145  echo "Test passed."
146  exit 0
147}
148