blob: f52105bac9f070e4519378cbc92a79143076a156 [file] [log] [blame]
#!/usr/bin/env bash
source ../multi-host.conf
source include.sh
workdir=$(pwd)
mkdir -p $workdir/logs
testLog=$workdir/logs/nfdc_test.log
echo "TEST START" > $testLog
start_nfd
# 1: Check for the existence of mcast address udp4://224.0.23.170
udp4Mcast=$(nfdc face list | grep "udp4://224.0.23.170")
udp6Mcast=$(nfdc face list | grep -iF "udp6://[ff00")
ethv4=$(nfdc face list | grep -iF "ether://[01:00:5E:")
ethv6=$(nfdc face list | grep -iF "ether://[33:33:")
if [[ -z "$udp4Mcast" ]] && [[ -z "$udp6Mcast" ]] && [[ -z "$ethv4" ]] && [[ -z "$ethv6" ]]; then
echo "nfdc: Failed to find udp4/udp6/ether multicast faces" >> $testLog
echo "'nfdc face list' output is:" >> $testLog
nfdc face list >> $testLog
clean_up
exit 2
fi
# 2 and 3: Create face tcp4://$IP4_B1 and check for its existence
faceIdTcp4=$(nfdc face create tcp4://$IP4_B1 | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
sleep 2
face=$(check_nfdc_face_existence $faceIdTcp4 tcp4://$IP4_B1)
if [ "-1" == $face ]; then
echo "Could not create face tcp4://$IP4_B1"
clean_up
exit 2
fi
#compress IPv6
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")
# 4 and 5: Create face tcp6://[$IP6_B1] and check for its existence
faceIdTcp6=$(nfdc face create tcp6://[$IP6_B1] | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
sleep 2
face=$(check_nfdc_face_existence_show $faceIdTcp6 tcp6://[$IP6_B1])
if [ "-1" == $face ]; then
echo "Could not create face tcp6://[$IP6_B1]"
clean_up
exit 2
fi
# 6 and 7: Create face udp4://$IP4_B1 and check for its existence
faceIdUdp4=$(nfdc face create udp4://$IP4_B1 | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
sleep 2
face=$(check_nfdc_face_existence_remote_uri $faceIdUdp4 udp4://$IP4_B1)
if [ "-1" == $face ]; then
echo "Could not create face udp4://$IP4_B1"
clean_up
exit 2
fi
# 8 and 9: Create face udp6://[$IP4_B1] and check for its existence
faceIdUdp6=$(nfdc face create udp6://[$IP6_B1] | grep -Po 'id=[0-9]+' | sed 's/id=//' | sed 's/ //')
sleep 2
face=$(check_nfdc_face_existence $faceIdUdp6 udp6://[$IP6_B1])
if [ "-1" == $face ]; then
echo "Could not create face udp6://[$IP6_B1]"
clean_up
exit 2
fi
# 10, 11, 12, and 13: Add routes for /test-nfdc
nfdc route add /test-nfdc tcp4://$IP4_B1 cost 24
nfdc route add /test-nfdc tcp6://[$IP6_B1] cost 26
nfdc route add /test-nfdc udp4://$IP4_B1 cost 14
nfdc route add /test-nfdc udp6://[$IP6_B1] cost 16
# 14: Check for the existence of the created routes
check_nfdc_route_existence "/test-nfdc" $faceIdTcp4 24
check_nfdc_route_existence "/test-nfdc" $faceIdTcp6 26
check_nfdc_route_existence_show "/test-nfdc" $faceIdUdp4 14
check_nfdc_route_existence_show "/test-nfdc" $faceIdUdp6 16
# 15: Check whether the `/test-nfdc` FIB entry contains all routes with the correct nexthops, in the correct order
check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp4 24
check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp6 26
check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp4 14
check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16
# Check if nexthops in correct order
nexthopInfo=$(nfdc fib list | grep "/test-nfdc" | \
grep "nexthops={faceid=$faceIdUdp4 (cost=14), faceid=$faceIdUdp6 (cost=16), faceid=$faceIdTcp4 (cost=24), faceid=$faceIdTcp6 (cost=26)}")
if [[ -z "$nexthopInfo" ]]; then
echo "nfdc: Nexthops to /test-nfdc not in correct order (by cost)" >> $testLog
echo "'nfdc fib list' is:" >> $testLog
nfdc fib list >> $testLog
clean_up
exit 2
fi
# 16: Use MulticastStrategy for the /test-nfdc prefix
nfdc strategy set /test-nfdc /localhost/nfd/strategy/multicast
# 17: Verify that /test-nfdc prefix uses MulticastStrategy
strategyInfo=$(nfdc strategy show /test-nfdc | grep "^strategy=/localhost/nfd/strategy/multicast/%FD%[0-9][0-9]$")
if [[ -z "$strategyInfo" ]]; then
echo "nfdc: prefix /test-nfdc does not use MulticastStrategy" >> $testLog
echo "'nfdc strategy show /test-nfdc' is:" >> $testLog
nfdc strategy show /test-nfdc >> $testLog
clean_up
exit 2
fi
# 18: Send 100 Interests to /test-nfdc w/ 50ms interval
ndnping -c $NUM_OF_PINGS -i 50 /test-nfdc
# 19: Verify that each face we created has had at least 100 outgoing Interests
check_nfdc_face_counters $faceIdTcp4 tcp4://$IP4_B1 out $NUM_OF_PINGS
check_nfdc_face_counters $faceIdTcp6 tcp6://[$IP6_B1] out $NUM_OF_PINGS
check_nfdc_face_counters $faceIdUdp4 udp4://$IP4_B1 out $NUM_OF_PINGS
check_nfdc_face_counters $faceIdUdp6 udp6://[$IP6_B1] out $NUM_OF_PINGS
# 20: Verify that corresponding faces on host B have had at least 100 incoming Interests
ssh $CTRL_B "$workdir/test-B.sh $workdir"
if [[ $? -ne 0 ]]; then
echo "Failed to verify correctness on node B" >> $testLog
clean_up
exit 3
fi
# 21: Destroy faces tcp4://$IP4_B1 and tcp6://[$IP6_B1]
nfdc face destroy $faceIdTcp4
echo "after nfdc face destroy $faceIdTcp4" >> $testLog
face=$(check_nfdc_face_existence $faceIdTcp4 tcp4://$IP4_B1)
if [ "-1" != $face ]; then
echo "face $faceIdTcp4 still exists after nfdc face destroy" >> $testLog
clean_up
exit 2
fi
nfdc face destroy $faceIdTcp6
echo "after nfdc face destroy $faceIdTcp6" >> $testLog
face=$(check_nfdc_face_existence $faceIdTcp6 tcp6://[$IP6_B1])
if [ "-1" != $face ]; then
clean_up
exit 2
fi
# 22: Unset MulticastStrategy for prefix /test-nfdc
nfdc strategy unset /test-nfdc
# 23: Verify that /test-nfdc prefix no longer uses MulticastStrategy
strategyInfo=$(nfdc strategy show /test-nfdc | grep "^strategy=/localhost/nfd/strategy/multicast/%FD%[0-9][0-9]$")
if [[ -n "$strategyInfo" ]]; then
echo "nfdc: prefix /test-nfdc still uses MulticastStrategy after 'nfdc strategy unset /test-nfdc''" >> $testLog
echo "'nfdc strategy show /test-nfdc' is:" >> $testLog
nfdc strategy show /test-nfdc >> $testLog
clean_up
exit 2
fi
# 24: Remove route to /test-nfdc via nexthop udp4://$IP4_B1
nfdc route remove /test-nfdc udp4://$IP4_B1
# 25: Ensure that route to /test-nfdc w/ nexthop udp4://$IP4_B1 has been removed
check_nfdc_route_existence "/test-nfdc" $faceIdTcp4 24 noexist
check_nfdc_route_existence "/test-nfdc" $faceIdTcp6 26 noexist
check_nfdc_route_existence "/test-nfdc" $faceIdUdp4 14 noexist
check_nfdc_route_existence "/test-nfdc" $faceIdUdp6 16
# 26: Ensure that /test-nfdc FIB entry no longer contains nexthop to udp4://$IP4_B1
check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp4 24 noexist
check_nfdc_nexthop_existence "/test-nfdc" $faceIdTcp6 26 noexist
check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp4 14 noexist
check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16
# 27: Remove route to /test-nfdc via nexthop udp6://[$IP6_B1]
nfdc route remove /test-nfdc udp6://[$IP6_B1]
sleep 1
# 28: Ensure that FIB entry for /test-nfdc has been removed, given that all routes to it have been removed
check_nfdc_nexthop_existence "/test-nfdc" $faceIdUdp6 16 noexist
nexthopInfo=$(nfdc fib list | grep "/test-nfdc")
if [[ -n $nexthopInfo ]]; then
echo "nfdc: FIB entry for /test-nfdc should not exist" >> $testLog
echo "'nfdc fib list' is:" >> $testLog
nfdc fib list >> $testLog
clean_up
exit 2
fi
clean_up
exit 0