blob: fcaecc00b1145e4884feb409b47818c6e4ac41c2 [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 Newberry6fc88222015-06-19 10:43:24 -07005mkdir -p $workdir/logs/$1
Hila Ben Abraham47583d12014-05-22 04:39:31 -05006testCase=$1
Eric Newberry6fc88222015-06-19 10:43:24 -07007testLog=$workdir/logs/$testCase/nfdc_test.log
Hila Ben Abraham47583d12014-05-22 04:39:31 -05008
9echo "TEST START" > $testLog
10
Eric Newberry6fc88222015-06-19 10:43:24 -070011start_nfd $testCase
Hila Ben Abraham47583d12014-05-22 04:39:31 -050012
13# run test case A: test nfdc create / add-nexthop / destroy test case
14if [[ $testCase == 'A' ]]; then
15
16 # Check for the existence of mcast address udp4://224.0.23.170
17 udp4Mcast=$(nfd-status | grep udp4://224.0.23.170)
18 udp6Mcast=$(nfd-status | grep -iF udp6://[ff00)
19 ethv4=$(nfd-status | grep -iF ether://[01:00:5E:)
20 ethv6=$(nfd-status | grep -iF ether://[33:33:)
21
22 if [[ -z "$udp4Mcast" ]] && [[ -z "$udp6Mcast" ]] && [[ -z "$ethv4" ]] && [[ -z "$ethv6" ]]; then
23 echo "nfd-status: Failed to find udp4/udp6/ether multicast faces" >> $testLog
24 echo "nfd-status is:" >> $testLog
25 nfd-status >> $testLog
26 clean_up
27 exit 2
28 fi
29
30 # Invoke nfdc create tcp://$IP4_B1.
31 faceIdTcp4=$(nfdc create tcp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
32 sleep 2
33 face=$(check_nfd_status_face_existence $faceIdTcp4 tcp4://$IP4_B1)
34 if [ "-1" = $face ]; then
35 clean_up
36 exit 2
37 fi
38
39 #compress IPv6
40 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")
41
42 # Invoke nfdc create tcp://$IP6_B1.
43 faceIdTcp6=$(nfdc create tcp6://[$IP6_B1] | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
44 sleep 2
45 face=$(check_nfd_status_face_existence $faceIdTcp6 tcp6://[$IP6_B1])
46 if [ "-1" = $face ]; then
47 clean_up
48 exit 2
49 fi
50
51 # Invoke nfdc create udp://$IP4_B1.
52 faceIdUdp4=$(nfdc create udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
53 sleep 2
54
55 face=$(check_nfd_status_face_existence $faceIdUdp4 udp4://$IP4_B1)
56 if [ "-1" = $face ]; then
57 clean_up
58 exit 2
59 fi
60
61
62 # Invoke nfdc create udp://$IP6_B1.
63 faceIdUdp6=$(nfdc create udp6://[$IP6_B1] | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
64 sleep 2
65 face=$(check_nfd_status_face_existence $faceIdUdp6 udp6://[$IP6_B1])
66 if [ "-1" = $face ]; then
67 clean_up
68 exit 2
69 fi
70
71 # Invoke nfdc to add next hops
72 nfdc add-nexthop -c 24 ndn:/test-nfdc $faceIdTcp4
73 nfdc add-nexthop -c 26 ndn:/test-nfdc $faceIdTcp6
74 nfdc add-nexthop -c 14 ndn:/test-nfdc $faceIdUdp4
75 nfdc add-nexthop -c 16 ndn:/test-nfdc $faceIdUdp6
76
77 # check correctness of add-nexthop -c 24 ndn:/test-nfdc $faceIdTcp4
78 check_nfd_status_correctness $faceIdTcp4 tcp4://$IP4_B1 /test-nfdc 24
79
80 # check correctness of add-nexthop -c 26 ndn:/test-nfdc $faceIdTcp6
81 check_nfd_status_correctness $faceIdTcp6 tcp6://[$IP6_B1] /test-nfdc 26
82
83 # check correctness of add-nexthop -c 14 ndn:/test-nfdc $faceIdUdp4
84 check_nfd_status_correctness $faceIdUdp4 udp4://$IP4_B1 /test-nfdc 14
85
86 # check correctness of add-nexthop -c 16 ndn:/test-nfdc $faceIdUdp6
87 check_nfd_status_correctness $faceIdUdp6 udp6://[$IP6_B1] /test-nfdc 16
88
Junxiao Shif9ecac22015-08-28 10:02:51 -070089 # Invoke nfdc to choose MulticastStrategy for ndn:/ namespace.
90 nfdc set-strategy ndn:/ ndn:/localhost/nfd/strategy/multicast
Hila Ben Abraham47583d12014-05-22 04:39:31 -050091
Eric Newberry86b00b92015-06-07 15:23:51 -070092 ndnping -c $NUM_OF_PINGS ndn:/test-nfdc
Hila Ben Abraham47583d12014-05-22 04:39:31 -050093
94 check_nfd_status_counters $faceIdTcp4 tcp4://$IP4_B1 out $NUM_OF_PINGS
95 check_nfd_status_counters $faceIdTcp6 tcp6://[$IP6_B1] out $NUM_OF_PINGS
96 check_nfd_status_counters $faceIdUdp4 udp4://$IP4_B1 out $NUM_OF_PINGS
97 check_nfd_status_counters $faceIdUdp6 udp6://[$IP6_B1] out $NUM_OF_PINGS
98
99 ssh $CTRL_B "$workdir/test-B.sh $workdir"
100 if [[ $? -ne 0 ]]; then
101 echo "Failed to verify correctness on node B" >> $testLog
102 clean_up
103 exit 3
104 fi
105
106 nfdc destroy $faceIdTcp4
107 echo "after nfdc destroy $faceIdTcp4" >> $testLog
108 face=$(check_nfd_status_face_existence $faceIdTcp4 tcp4://$IP4_B1)
109 if [ "-1" != $face ]; then
110 echo "face $faceIdTcp4 still exists after nfdc destory" >> $testLog
111 clean_up
112 exit 2
113 fi
114
115 nfdc destroy $faceIdTcp6
116 echo "after nfdc destroy $faceIdTcp6" >> $testLog
117 face=$(check_nfd_status_face_existence $faceIdTcp6 tcp6://[$IP6_B1])
118 if [ "-1" != $face ]; then
119 clean_up
120 exit 2
121 fi
122
123 clean_up
124
125# run test case B: nfdc add-nexthop / remove-nexthop test case
126elif [[ $testCase == 'B' ]]; then
127
128 # Invoke nfdc to add next hop
129 faceId=$(nfdc add-nexthop -c 44 ndn:/test-nfdc udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
130 if [[ "ERROR" == $faceId* ]]
131 then
132 echo "nfdc: Failed to add nexthop for $IP4_B1" >> $testLog
133 clean_up
134 exit 1
135 fi
136
137 check_nfd_status_correctness $faceId udp4://$IP4_B1 /test-nfdc 44
138
139 # invoke nfdc to remove the nexthop for created FaceId
140 removeNextHop=$(nfdc remove-nexthop ndn:/test-nfdc $faceId)
141
Hila Ben Abraham799f78f2015-03-01 22:06:33 -0600142 #wait for the refreshed output of nfd-status
143 sleep 2
144
Hila Ben Abraham47583d12014-05-22 04:39:31 -0500145 # check the existence of ndn:/test-nfdc FIB entry
146 fibEntry=$(nfd-status | grep /test-nfdc)
147 if [ ! -z "$fibEntry" ]; then
148 echo "nfd-status: Failed to delete ndn:/test-nfdc FIB entry" >> $testLog
149 clean_up
150 exit 2
151 fi
152 clean_up
153
154# run test case C: test nfdc register / unregister test case
155elif [[ $testCase == 'C' ]]; then
156
Hila Ben Abraham47583d12014-05-22 04:39:31 -0500157 # Invoke nfdc register a new prefix
158 faceId=$(nfdc register -c 55 ndn:/test-nfdc udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
159 if [[ "ERROR" == $faceId* ]]; then
160 echo "nfdc: Failed to register ndn:/test-nfdc for $IP4_B1" >> $testLog
161 clean_up
162 exit 1
163 fi
164 check_nfd_status_correctness $faceId udp4://$IP4_B1 /test-nfdc 55
165
166 # Invoke nfdc to unregister the prefix
167 unregisterPrefix=$(nfdc unregister ndn:/test-nfdc $faceId)
Hila Ben Abraham799f78f2015-03-01 22:06:33 -0600168 sleep 2
Hila Ben Abraham47583d12014-05-22 04:39:31 -0500169 # check the existence of ndn:/test-nfdc FIB entry
170 fibEntry=$(nfd-status | grep /test-nfdc)
171 if [ ! -z "$fibEntry" ]; then
172 echo "nfd-status: Failed to unregister prefix" >> $testLog
173 clean_up
174 exit 2
175 fi
176 clean_up
177fi
178
179clean_up
180exit 0
181