blob: 9c491986cf04f0fcb5439e74448e9750c86484ac [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)
5mkdir -p $workdir/logs
6testCase=$1
7testLog=$workdir/logs/nfdc_test_$testCase.log
8
9echo "TEST START" > $testLog
10
11start_nfd
12
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
89 # Invoke nfdc to choose BroadcastStrategy for ndn:/ namespace.
90 nfdc set-strategy ndn:/ ndn:/localhost/nfd/strategy/broadcast
91
92 ndnping ndn:/test-nfdc -c $NUM_OF_PINGS
93
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
157 # run nrd
158 start_nrd
159
160 # Invoke nfdc register a new prefix
161 faceId=$(nfdc register -c 55 ndn:/test-nfdc udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
162 if [[ "ERROR" == $faceId* ]]; then
163 echo "nfdc: Failed to register ndn:/test-nfdc for $IP4_B1" >> $testLog
164 clean_up
165 exit 1
166 fi
167 check_nfd_status_correctness $faceId udp4://$IP4_B1 /test-nfdc 55
168
169 # Invoke nfdc to unregister the prefix
170 unregisterPrefix=$(nfdc unregister ndn:/test-nfdc $faceId)
Hila Ben Abraham799f78f2015-03-01 22:06:33 -0600171 sleep 2
Hila Ben Abraham47583d12014-05-22 04:39:31 -0500172 # check the existence of ndn:/test-nfdc FIB entry
173 fibEntry=$(nfd-status | grep /test-nfdc)
174 if [ ! -z "$fibEntry" ]; then
175 echo "nfd-status: Failed to unregister prefix" >> $testLog
176 clean_up
177 exit 2
178 fi
179 clean_up
180fi
181
182clean_up
183exit 0
184