blob: f52105bac9f070e4519378cbc92a79143076a156 [file] [log] [blame]
Hila Ben Abraham47583d12014-05-22 04:39:31 -05001#!/usr/bin/env bash
2source ../multi-host.conf
3source include.sh
4workdir=$(pwd)
Eric Newberrybef49472017-05-08 22:49:05 -07005mkdir -p $workdir/logs
6testLog=$workdir/logs/nfdc_test.log
Hila Ben Abraham47583d12014-05-22 04:39:31 -05007
8echo "TEST START" > $testLog
9
Eric Newberrybef49472017-05-08 22:49:05 -070010start_nfd
Hila Ben Abraham47583d12014-05-22 04:39:31 -050011
Eric Newberrybef49472017-05-08 22:49:05 -070012# 1: Check for the existence of mcast address udp4://224.0.23.170
13udp4Mcast=$(nfdc face list | grep "udp4://224.0.23.170")
14udp6Mcast=$(nfdc face list | grep -iF "udp6://[ff00")
15ethv4=$(nfdc face list | grep -iF "ether://[01:00:5E:")
16ethv6=$(nfdc face list | grep -iF "ether://[33:33:")
Hila Ben Abraham47583d12014-05-22 04:39:31 -050017
Eric Newberrybef49472017-05-08 22:49:05 -070018if [[ -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 Abraham47583d12014-05-22 04:39:31 -050022 clean_up
Eric Newberrybef49472017-05-08 22:49:05 -070023 exit 2
24fi
Hila Ben Abraham47583d12014-05-22 04:39:31 -050025
Eric Newberrybef49472017-05-08 22:49:05 -070026# 2 and 3: Create face tcp4://$IP4_B1 and check for its existence
27faceIdTcp4=$(nfdc face create tcp4://$IP4_B1 | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
28sleep 2
29face=$(check_nfdc_face_existence $faceIdTcp4 tcp4://$IP4_B1)
30if [ "-1" == $face ]; then
31 echo "Could not create face tcp4://$IP4_B1"
Hila Ben Abraham47583d12014-05-22 04:39:31 -050032 clean_up
Eric Newberrybef49472017-05-08 22:49:05 -070033 exit 2
34fi
Hila Ben Abraham47583d12014-05-22 04:39:31 -050035
Eric Newberrybef49472017-05-08 22:49:05 -070036#compress IPv6
37IP6_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 Abraham47583d12014-05-22 04:39:31 -050038
Eric Newberrybef49472017-05-08 22:49:05 -070039# 4 and 5: Create face tcp6://[$IP6_B1] and check for its existence
40faceIdTcp6=$(nfdc face create tcp6://[$IP6_B1] | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
41sleep 2
42face=$(check_nfdc_face_existence_show $faceIdTcp6 tcp6://[$IP6_B1])
43if [ "-1" == $face ]; then
44 echo "Could not create face tcp6://[$IP6_B1]"
Hila Ben Abraham47583d12014-05-22 04:39:31 -050045 clean_up
Eric Newberrybef49472017-05-08 22:49:05 -070046 exit 2
47fi
48
49# 6 and 7: Create face udp4://$IP4_B1 and check for its existence
50faceIdUdp4=$(nfdc face create udp4://$IP4_B1 | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
51sleep 2
52face=$(check_nfdc_face_existence_remote_uri $faceIdUdp4 udp4://$IP4_B1)
53if [ "-1" == $face ]; then
54 echo "Could not create face udp4://$IP4_B1"
55 clean_up
56 exit 2
57fi
58
59
60# 8 and 9: Create face udp6://[$IP4_B1] and check for its existence
61faceIdUdp6=$(nfdc face create udp6://[$IP6_B1] | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
62sleep 2
63face=$(check_nfdc_face_existence $faceIdUdp6 udp6://[$IP6_B1])
64if [ "-1" == $face ]; then
65 echo "Could not create face udp6://[$IP6_B1]"
66 clean_up
67 exit 2
68fi
69
70# 10, 11, 12, and 13: Add routes for /test-nfdc
71nfdc route add /test-nfdc tcp4://$IP4_B1 cost 24
72nfdc route add /test-nfdc tcp6://[$IP6_B1] cost 26
73nfdc route add /test-nfdc udp4://$IP4_B1 cost 14
74nfdc route add /test-nfdc udp6://[$IP6_B1] cost 16
75
76# 14: Check for the existence of the created routes
77check_nfdc_route_existence "/test-nfdc" $faceIdTcp4 24
78check_nfdc_route_existence "/test-nfdc" $faceIdTcp6 26
79check_nfdc_route_existence_show "/test-nfdc" $faceIdUdp4 14
80check_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
83check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp4 24
84check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp6 26
85check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp4 14
86check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16
87
88# Check if nexthops in correct order
89nexthopInfo=$(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
92if [[ -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
98fi
99
100# 16: Use MulticastStrategy for the /test-nfdc prefix
101nfdc strategy set /test-nfdc /localhost/nfd/strategy/multicast
102
103# 17: Verify that /test-nfdc prefix uses MulticastStrategy
104strategyInfo=$(nfdc strategy show /test-nfdc | grep "^strategy=/localhost/nfd/strategy/multicast/%FD%[0-9][0-9]$")
105
106if [[ -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
112fi
113
114# 18: Send 100 Interests to /test-nfdc w/ 50ms interval
115ndnping -c $NUM_OF_PINGS -i 50 /test-nfdc
116
117# 19: Verify that each face we created has had at least 100 outgoing Interests
118check_nfdc_face_counters $faceIdTcp4 tcp4://$IP4_B1 out $NUM_OF_PINGS
119check_nfdc_face_counters $faceIdTcp6 tcp6://[$IP6_B1] out $NUM_OF_PINGS
120check_nfdc_face_counters $faceIdUdp4 udp4://$IP4_B1 out $NUM_OF_PINGS
121check_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
124ssh $CTRL_B "$workdir/test-B.sh $workdir"
125if [[ $? -ne 0 ]]; then
126 echo "Failed to verify correctness on node B" >> $testLog
127 clean_up
128 exit 3
129fi
130
131# 21: Destroy faces tcp4://$IP4_B1 and tcp6://[$IP6_B1]
132nfdc face destroy $faceIdTcp4
133echo "after nfdc face destroy $faceIdTcp4" >> $testLog
134face=$(check_nfdc_face_existence $faceIdTcp4 tcp4://$IP4_B1)
135if [ "-1" != $face ]; then
136 echo "face $faceIdTcp4 still exists after nfdc face destroy" >> $testLog
137 clean_up
138 exit 2
139fi
140
141nfdc face destroy $faceIdTcp6
142echo "after nfdc face destroy $faceIdTcp6" >> $testLog
143face=$(check_nfdc_face_existence $faceIdTcp6 tcp6://[$IP6_B1])
144if [ "-1" != $face ]; then
145 clean_up
146 exit 2
147fi
148
149# 22: Unset MulticastStrategy for prefix /test-nfdc
150nfdc strategy unset /test-nfdc
151
152# 23: Verify that /test-nfdc prefix no longer uses MulticastStrategy
153strategyInfo=$(nfdc strategy show /test-nfdc | grep "^strategy=/localhost/nfd/strategy/multicast/%FD%[0-9][0-9]$")
154
155if [[ -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
161fi
162
163# 24: Remove route to /test-nfdc via nexthop udp4://$IP4_B1
164nfdc route remove /test-nfdc udp4://$IP4_B1
165
166# 25: Ensure that route to /test-nfdc w/ nexthop udp4://$IP4_B1 has been removed
167check_nfdc_route_existence "/test-nfdc" $faceIdTcp4 24 noexist
168check_nfdc_route_existence "/test-nfdc" $faceIdTcp6 26 noexist
169check_nfdc_route_existence "/test-nfdc" $faceIdUdp4 14 noexist
170check_nfdc_route_existence "/test-nfdc" $faceIdUdp6 16
171
172# 26: Ensure that /test-nfdc FIB entry no longer contains nexthop to udp4://$IP4_B1
173check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp4 24 noexist
174check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp6 26 noexist
175check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp4 14 noexist
176check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16
177
178# 27: Remove route to /test-nfdc via nexthop udp6://[$IP6_B1]
179nfdc route remove /test-nfdc udp6://[$IP6_B1]
180
181sleep 1
182
183# 28: Ensure that FIB entry for /test-nfdc has been removed, given that all routes to it have been removed
184check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16 noexist
185
186nexthopInfo=$(nfdc fib list | grep "/test-nfdc")
187if [[ -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 Abraham47583d12014-05-22 04:39:31 -0500193fi
194
195clean_up
196exit 0