Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | source include.sh |
| 4 | workdir=$(pwd) |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 5 | mkdir -p $workdir/logs |
| 6 | testLog=$workdir/logs/nfdc_test.log |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 7 | |
| 8 | echo "TEST START" > $testLog |
| 9 | |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 10 | start_nfd |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 11 | |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 12 | # 1: Check for the existence of mcast address udp4://224.0.23.170 |
| 13 | udp4Mcast=$(nfdc face list | grep "udp4://224.0.23.170") |
| 14 | udp6Mcast=$(nfdc face list | grep -iF "udp6://[ff00") |
| 15 | ethv4=$(nfdc face list | grep -iF "ether://[01:00:5E:") |
| 16 | ethv6=$(nfdc face list | grep -iF "ether://[33:33:") |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 17 | |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 18 | if [[ -z "$udp4Mcast" ]] && [[ -z "$udp6Mcast" ]] && [[ -z "$ethv4" ]] && [[ -z "$ethv6" ]]; then |
| 19 | echo "nfdc: Failed to find udp4/udp6/ether multicast faces" >> $testLog |
| 20 | echo "'nfdc face list' output is:" >> $testLog |
| 21 | nfdc face list >> $testLog |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 22 | clean_up |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 23 | exit 2 |
| 24 | fi |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 25 | |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 26 | # 2 and 3: Create face tcp4://$IP4_B1 and check for its existence |
| 27 | faceIdTcp4=$(nfdc face create tcp4://$IP4_B1 | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //') |
| 28 | sleep 2 |
| 29 | face=$(check_nfdc_face_existence $faceIdTcp4 tcp4://$IP4_B1) |
| 30 | if [ "-1" == $face ]; then |
| 31 | echo "Could not create face tcp4://$IP4_B1" |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 32 | clean_up |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 33 | exit 2 |
| 34 | fi |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 35 | |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 36 | #compress IPv6 |
| 37 | IP6_B1=$(python -c "import sys; import socket; result = socket.getaddrinfo('$IP6_B1', None); family, socktype, proto, canonname,(address, port, flow_info, scope_id) = result[0]; print address") |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 38 | |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 39 | # 4 and 5: Create face tcp6://[$IP6_B1] and check for its existence |
| 40 | faceIdTcp6=$(nfdc face create tcp6://[$IP6_B1] | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //') |
| 41 | sleep 2 |
| 42 | face=$(check_nfdc_face_existence_show $faceIdTcp6 tcp6://[$IP6_B1]) |
| 43 | if [ "-1" == $face ]; then |
| 44 | echo "Could not create face tcp6://[$IP6_B1]" |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 45 | clean_up |
Eric Newberry | bef4947 | 2017-05-08 22:49:05 -0700 | [diff] [blame] | 46 | exit 2 |
| 47 | fi |
| 48 | |
| 49 | # 6 and 7: Create face udp4://$IP4_B1 and check for its existence |
| 50 | faceIdUdp4=$(nfdc face create udp4://$IP4_B1 | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //') |
| 51 | sleep 2 |
| 52 | face=$(check_nfdc_face_existence_remote_uri $faceIdUdp4 udp4://$IP4_B1) |
| 53 | if [ "-1" == $face ]; then |
| 54 | echo "Could not create face udp4://$IP4_B1" |
| 55 | clean_up |
| 56 | exit 2 |
| 57 | fi |
| 58 | |
| 59 | |
| 60 | # 8 and 9: Create face udp6://[$IP4_B1] and check for its existence |
| 61 | faceIdUdp6=$(nfdc face create udp6://[$IP6_B1] | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //') |
| 62 | sleep 2 |
| 63 | face=$(check_nfdc_face_existence $faceIdUdp6 udp6://[$IP6_B1]) |
| 64 | if [ "-1" == $face ]; then |
| 65 | echo "Could not create face udp6://[$IP6_B1]" |
| 66 | clean_up |
| 67 | exit 2 |
| 68 | fi |
| 69 | |
| 70 | # 10, 11, 12, and 13: Add routes for /test-nfdc |
| 71 | nfdc route add /test-nfdc tcp4://$IP4_B1 cost 24 |
| 72 | nfdc route add /test-nfdc tcp6://[$IP6_B1] cost 26 |
| 73 | nfdc route add /test-nfdc udp4://$IP4_B1 cost 14 |
| 74 | nfdc route add /test-nfdc udp6://[$IP6_B1] cost 16 |
| 75 | |
| 76 | # 14: Check for the existence of the created routes |
| 77 | check_nfdc_route_existence "/test-nfdc" $faceIdTcp4 24 |
| 78 | check_nfdc_route_existence "/test-nfdc" $faceIdTcp6 26 |
| 79 | check_nfdc_route_existence_show "/test-nfdc" $faceIdUdp4 14 |
| 80 | check_nfdc_route_existence_show "/test-nfdc" $faceIdUdp6 16 |
| 81 | |
| 82 | # 15: Check whether the `/test-nfdc` FIB entry contains all routes with the correct nexthops, in the correct order |
| 83 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp4 24 |
| 84 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp6 26 |
| 85 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp4 14 |
| 86 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16 |
| 87 | |
| 88 | # Check if nexthops in correct order |
| 89 | nexthopInfo=$(nfdc fib list | grep "/test-nfdc" | \ |
| 90 | grep "nexthops={faceid=$faceIdUdp4 (cost=14), faceid=$faceIdUdp6 (cost=16), faceid=$faceIdTcp4 (cost=24), faceid=$faceIdTcp6 (cost=26)}") |
| 91 | |
| 92 | if [[ -z "$nexthopInfo" ]]; then |
| 93 | echo "nfdc: Nexthops to /test-nfdc not in correct order (by cost)" >> $testLog |
| 94 | echo "'nfdc fib list' is:" >> $testLog |
| 95 | nfdc fib list >> $testLog |
| 96 | clean_up |
| 97 | exit 2 |
| 98 | fi |
| 99 | |
| 100 | # 16: Use MulticastStrategy for the /test-nfdc prefix |
| 101 | nfdc strategy set /test-nfdc /localhost/nfd/strategy/multicast |
| 102 | |
| 103 | # 17: Verify that /test-nfdc prefix uses MulticastStrategy |
| 104 | strategyInfo=$(nfdc strategy show /test-nfdc | grep "^strategy=/localhost/nfd/strategy/multicast/%FD%[0-9][0-9]$") |
| 105 | |
| 106 | if [[ -z "$strategyInfo" ]]; then |
| 107 | echo "nfdc: prefix /test-nfdc does not use MulticastStrategy" >> $testLog |
| 108 | echo "'nfdc strategy show /test-nfdc' is:" >> $testLog |
| 109 | nfdc strategy show /test-nfdc >> $testLog |
| 110 | clean_up |
| 111 | exit 2 |
| 112 | fi |
| 113 | |
| 114 | # 18: Send 100 Interests to /test-nfdc w/ 50ms interval |
| 115 | ndnping -c $NUM_OF_PINGS -i 50 /test-nfdc |
| 116 | |
| 117 | # 19: Verify that each face we created has had at least 100 outgoing Interests |
| 118 | check_nfdc_face_counters $faceIdTcp4 tcp4://$IP4_B1 out $NUM_OF_PINGS |
| 119 | check_nfdc_face_counters $faceIdTcp6 tcp6://[$IP6_B1] out $NUM_OF_PINGS |
| 120 | check_nfdc_face_counters $faceIdUdp4 udp4://$IP4_B1 out $NUM_OF_PINGS |
| 121 | check_nfdc_face_counters $faceIdUdp6 udp6://[$IP6_B1] out $NUM_OF_PINGS |
| 122 | |
| 123 | # 20: Verify that corresponding faces on host B have had at least 100 incoming Interests |
| 124 | ssh $CTRL_B "$workdir/test-B.sh $workdir" |
| 125 | if [[ $? -ne 0 ]]; then |
| 126 | echo "Failed to verify correctness on node B" >> $testLog |
| 127 | clean_up |
| 128 | exit 3 |
| 129 | fi |
| 130 | |
| 131 | # 21: Destroy faces tcp4://$IP4_B1 and tcp6://[$IP6_B1] |
| 132 | nfdc face destroy $faceIdTcp4 |
| 133 | echo "after nfdc face destroy $faceIdTcp4" >> $testLog |
| 134 | face=$(check_nfdc_face_existence $faceIdTcp4 tcp4://$IP4_B1) |
| 135 | if [ "-1" != $face ]; then |
| 136 | echo "face $faceIdTcp4 still exists after nfdc face destroy" >> $testLog |
| 137 | clean_up |
| 138 | exit 2 |
| 139 | fi |
| 140 | |
| 141 | nfdc face destroy $faceIdTcp6 |
| 142 | echo "after nfdc face destroy $faceIdTcp6" >> $testLog |
| 143 | face=$(check_nfdc_face_existence $faceIdTcp6 tcp6://[$IP6_B1]) |
| 144 | if [ "-1" != $face ]; then |
| 145 | clean_up |
| 146 | exit 2 |
| 147 | fi |
| 148 | |
| 149 | # 22: Unset MulticastStrategy for prefix /test-nfdc |
| 150 | nfdc strategy unset /test-nfdc |
| 151 | |
| 152 | # 23: Verify that /test-nfdc prefix no longer uses MulticastStrategy |
| 153 | strategyInfo=$(nfdc strategy show /test-nfdc | grep "^strategy=/localhost/nfd/strategy/multicast/%FD%[0-9][0-9]$") |
| 154 | |
| 155 | if [[ -n "$strategyInfo" ]]; then |
| 156 | echo "nfdc: prefix /test-nfdc still uses MulticastStrategy after 'nfdc strategy unset /test-nfdc''" >> $testLog |
| 157 | echo "'nfdc strategy show /test-nfdc' is:" >> $testLog |
| 158 | nfdc strategy show /test-nfdc >> $testLog |
| 159 | clean_up |
| 160 | exit 2 |
| 161 | fi |
| 162 | |
| 163 | # 24: Remove route to /test-nfdc via nexthop udp4://$IP4_B1 |
| 164 | nfdc route remove /test-nfdc udp4://$IP4_B1 |
| 165 | |
| 166 | # 25: Ensure that route to /test-nfdc w/ nexthop udp4://$IP4_B1 has been removed |
| 167 | check_nfdc_route_existence "/test-nfdc" $faceIdTcp4 24 noexist |
| 168 | check_nfdc_route_existence "/test-nfdc" $faceIdTcp6 26 noexist |
| 169 | check_nfdc_route_existence "/test-nfdc" $faceIdUdp4 14 noexist |
| 170 | check_nfdc_route_existence "/test-nfdc" $faceIdUdp6 16 |
| 171 | |
| 172 | # 26: Ensure that /test-nfdc FIB entry no longer contains nexthop to udp4://$IP4_B1 |
| 173 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp4 24 noexist |
| 174 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp6 26 noexist |
| 175 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp4 14 noexist |
| 176 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16 |
| 177 | |
| 178 | # 27: Remove route to /test-nfdc via nexthop udp6://[$IP6_B1] |
| 179 | nfdc route remove /test-nfdc udp6://[$IP6_B1] |
| 180 | |
| 181 | sleep 1 |
| 182 | |
| 183 | # 28: Ensure that FIB entry for /test-nfdc has been removed, given that all routes to it have been removed |
| 184 | check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16 noexist |
| 185 | |
| 186 | nexthopInfo=$(nfdc fib list | grep "/test-nfdc") |
| 187 | if [[ -n $nexthopInfo ]]; then |
| 188 | echo "nfdc: FIB entry for /test-nfdc should not exist" >> $testLog |
| 189 | echo "'nfdc fib list' is:" >> $testLog |
| 190 | nfdc fib list >> $testLog |
| 191 | clean_up |
| 192 | exit 2 |
Hila Ben Abraham | 47583d1 | 2014-05-22 04:39:31 -0500 | [diff] [blame] | 193 | fi |
| 194 | |
| 195 | clean_up |
| 196 | exit 0 |