Add source/dest tests
[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   remove_sd_mapping "6.0.1.0/24" "6.0.2.0/24"
64
65   # wait for SMR being resolved
66   sleep 2
67
68   maybe_pause
69
70   # now ping should fail
71   send_ping_from_ns_expect_failure vppns1 ${1} ${2}
72
73   maybe_pause
74
75   # Replace ODL mapping with positive one
76   post_curl "add-mapping" "replace2.json"
77   remove_sd_mapping "6.0.0.0/16" "6.0.2.0/24"
78
79   # wait for SMR being resolved
80   sleep 2
81
82   maybe_pause
83
84   # expect ping reply again
85   send_ping_from_ns vppns1 ${1} ${2}
86   rc=$?
87
88   maybe_pause
89   2_node_topo_clean
90   print_status $rc "No ICM response!"
91   exit $test_result
92 }