Add INFO.yaml file
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / src_dst_overwrite.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/2_node_topo.sh
4
5 ODL_CONFIG_FILE1="map1.json"
6 ODL_CONFIG_FILE2="map2.json"
7
8 if [ "$1" == "clean" ] ; then
9   2_node_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 $? 2_node_topo_clean "No ICMP Response!"
22 }
23
24 function send_ping_from_ns_expect_failure
25 {
26   ip netns exec "${1}" "${2}" -w 10 -c 1 "${3}"
27   assert_rc_not_ok $? 2_node_topo_clean "Reply received, but failure expected!"
28 }
29
30 function remove_sd_mapping {
31   curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 1e4f00f4-74eb-20d7-97da-89963f37713b" -d '{
32     "input": {
33         "eid": {
34             "address-type": "ietf-lisp-address-types:source-dest-key-lcaf",
35             "source-dest-key": {
36                 "source": "'$1'",
37                 "dest": "'$2'"
38             }
39         }
40     }
41 }' "http://${ODL_IP}:8181/restconf/operations/odl-mappingservice:remove-mapping"
42 }
43
44 function remove_mapping1 {
45 curl -X DELETE -H "Content-Type: application/json" -H "Cache-Control: no-cache" "http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database/virtual-network-identifier/0/mapping/${1}/northbound/"
46 }
47
48 function test_src_dst_overwrite
49 {
50   2_node_topo_setup
51
52   maybe_pause
53
54   test_result=1
55
56   # send ping request
57   send_ping_from_ns vppns1 ${1} ${2}
58
59   maybe_pause
60
61   # Replace ODL mapping with negative one
62   post_curl "add-mapping" "replace1.json"
63
64   # wait for SMR being resolved
65   sleep 2
66
67   maybe_pause
68
69   # now ping should fail
70   send_ping_from_ns_expect_failure vppns1 ${1} ${2}
71
72   maybe_pause
73
74   # Replace ODL mapping with positive one
75   post_curl "add-mapping" "replace2.json"
76
77   # wait for SMR being resolved
78   sleep 2
79
80   maybe_pause
81
82   # expect ping reply again
83   send_ping_from_ns vppns1 ${1} ${2}
84   rc=$?
85
86   maybe_pause
87   2_node_topo_clean
88   print_status $rc "No ICMP response!"
89   exit $test_result
90 }
91
92 function test_src_dst_overwrite_superset
93 {
94   2_node_topo_setup
95
96   maybe_pause
97
98   test_result=1
99
100   # send ping request
101   send_ping_from_ns vppns1 ${1} ${2}
102
103   maybe_pause
104
105   # Replace ODL mapping with negative one
106   post_curl "add-mapping" "replace1.json"
107   remove_sd_mapping "6.0.1.0/24" "6.0.2.0/24"
108
109   # wait for SMR being resolved
110   sleep 2
111
112   maybe_pause
113
114   # now ping should fail
115   send_ping_from_ns_expect_failure vppns1 ${1} ${2}
116
117   maybe_pause
118
119   # Replace ODL mapping with positive one
120   post_curl "add-mapping" "replace2.json"
121   remove_sd_mapping "6.0.0.0/16" "6.0.2.0/24"
122
123   # wait for SMR being resolved
124   sleep 2
125
126   maybe_pause
127
128   # expect ping reply again
129   send_ping_from_ns vppns1 ${1} ${2}
130   rc=$?
131
132   maybe_pause
133   2_node_topo_clean
134   print_status $rc "No ICMP response!"
135   exit $test_result
136 }