| #!/usr/bin/env bash |
| source ../multi-host.conf |
| source include.sh |
| workdir=$(pwd) |
| mkdir -p $workdir/logs |
| testCase=$1 |
| testLog=$workdir/logs/nfdc_test_$testCase.log |
| |
| echo "TEST START" > $testLog |
| |
| start_nfd |
| |
| # run test case A: test nfdc create / add-nexthop / destroy test case |
| if [[ $testCase == 'A' ]]; then |
| |
| # Check for the existence of mcast address udp4://224.0.23.170 |
| udp4Mcast=$(nfd-status | grep udp4://224.0.23.170) |
| udp6Mcast=$(nfd-status | grep -iF udp6://[ff00) |
| ethv4=$(nfd-status | grep -iF ether://[01:00:5E:) |
| ethv6=$(nfd-status | grep -iF ether://[33:33:) |
| |
| if [[ -z "$udp4Mcast" ]] && [[ -z "$udp6Mcast" ]] && [[ -z "$ethv4" ]] && [[ -z "$ethv6" ]]; then |
| echo "nfd-status: Failed to find udp4/udp6/ether multicast faces" >> $testLog |
| echo "nfd-status is:" >> $testLog |
| nfd-status >> $testLog |
| clean_up |
| exit 2 |
| fi |
| |
| # Invoke nfdc create tcp://$IP4_B1. |
| faceIdTcp4=$(nfdc create tcp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| sleep 2 |
| face=$(check_nfd_status_face_existence $faceIdTcp4 tcp4://$IP4_B1) |
| if [ "-1" = $face ]; then |
| 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") |
| |
| # Invoke nfdc create tcp://$IP6_B1. |
| faceIdTcp6=$(nfdc create tcp6://[$IP6_B1] | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| sleep 2 |
| face=$(check_nfd_status_face_existence $faceIdTcp6 tcp6://[$IP6_B1]) |
| if [ "-1" = $face ]; then |
| clean_up |
| exit 2 |
| fi |
| |
| # Invoke nfdc create udp://$IP4_B1. |
| faceIdUdp4=$(nfdc create udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| sleep 2 |
| |
| face=$(check_nfd_status_face_existence $faceIdUdp4 udp4://$IP4_B1) |
| if [ "-1" = $face ]; then |
| clean_up |
| exit 2 |
| fi |
| |
| |
| # Invoke nfdc create udp://$IP6_B1. |
| faceIdUdp6=$(nfdc create udp6://[$IP6_B1] | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| sleep 2 |
| face=$(check_nfd_status_face_existence $faceIdUdp6 udp6://[$IP6_B1]) |
| if [ "-1" = $face ]; then |
| clean_up |
| exit 2 |
| fi |
| |
| # Invoke nfdc to add next hops |
| nfdc add-nexthop -c 24 ndn:/test-nfdc $faceIdTcp4 |
| nfdc add-nexthop -c 26 ndn:/test-nfdc $faceIdTcp6 |
| nfdc add-nexthop -c 14 ndn:/test-nfdc $faceIdUdp4 |
| nfdc add-nexthop -c 16 ndn:/test-nfdc $faceIdUdp6 |
| |
| # check correctness of add-nexthop -c 24 ndn:/test-nfdc $faceIdTcp4 |
| check_nfd_status_correctness $faceIdTcp4 tcp4://$IP4_B1 /test-nfdc 24 |
| |
| # check correctness of add-nexthop -c 26 ndn:/test-nfdc $faceIdTcp6 |
| check_nfd_status_correctness $faceIdTcp6 tcp6://[$IP6_B1] /test-nfdc 26 |
| |
| # check correctness of add-nexthop -c 14 ndn:/test-nfdc $faceIdUdp4 |
| check_nfd_status_correctness $faceIdUdp4 udp4://$IP4_B1 /test-nfdc 14 |
| |
| # check correctness of add-nexthop -c 16 ndn:/test-nfdc $faceIdUdp6 |
| check_nfd_status_correctness $faceIdUdp6 udp6://[$IP6_B1] /test-nfdc 16 |
| |
| # Invoke nfdc to choose BroadcastStrategy for ndn:/ namespace. |
| nfdc set-strategy ndn:/ ndn:/localhost/nfd/strategy/broadcast |
| |
| ndnping ndn:/test-nfdc -c $NUM_OF_PINGS |
| |
| check_nfd_status_counters $faceIdTcp4 tcp4://$IP4_B1 out $NUM_OF_PINGS |
| check_nfd_status_counters $faceIdTcp6 tcp6://[$IP6_B1] out $NUM_OF_PINGS |
| check_nfd_status_counters $faceIdUdp4 udp4://$IP4_B1 out $NUM_OF_PINGS |
| check_nfd_status_counters $faceIdUdp6 udp6://[$IP6_B1] out $NUM_OF_PINGS |
| |
| 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 |
| |
| nfdc destroy $faceIdTcp4 |
| echo "after nfdc destroy $faceIdTcp4" >> $testLog |
| face=$(check_nfd_status_face_existence $faceIdTcp4 tcp4://$IP4_B1) |
| if [ "-1" != $face ]; then |
| echo "face $faceIdTcp4 still exists after nfdc destory" >> $testLog |
| clean_up |
| exit 2 |
| fi |
| |
| nfdc destroy $faceIdTcp6 |
| echo "after nfdc destroy $faceIdTcp6" >> $testLog |
| face=$(check_nfd_status_face_existence $faceIdTcp6 tcp6://[$IP6_B1]) |
| if [ "-1" != $face ]; then |
| clean_up |
| exit 2 |
| fi |
| |
| clean_up |
| |
| # run test case B: nfdc add-nexthop / remove-nexthop test case |
| elif [[ $testCase == 'B' ]]; then |
| |
| # Invoke nfdc to add next hop |
| faceId=$(nfdc add-nexthop -c 44 ndn:/test-nfdc udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| if [[ "ERROR" == $faceId* ]] |
| then |
| echo "nfdc: Failed to add nexthop for $IP4_B1" >> $testLog |
| clean_up |
| exit 1 |
| fi |
| |
| check_nfd_status_correctness $faceId udp4://$IP4_B1 /test-nfdc 44 |
| |
| # invoke nfdc to remove the nexthop for created FaceId |
| removeNextHop=$(nfdc remove-nexthop ndn:/test-nfdc $faceId) |
| |
| #wait for the refreshed output of nfd-status |
| sleep 2 |
| |
| # check the existence of ndn:/test-nfdc FIB entry |
| fibEntry=$(nfd-status | grep /test-nfdc) |
| if [ ! -z "$fibEntry" ]; then |
| echo "nfd-status: Failed to delete ndn:/test-nfdc FIB entry" >> $testLog |
| clean_up |
| exit 2 |
| fi |
| clean_up |
| |
| # run test case C: test nfdc register / unregister test case |
| elif [[ $testCase == 'C' ]]; then |
| |
| # run nrd |
| start_nrd |
| |
| # Invoke nfdc register a new prefix |
| faceId=$(nfdc register -c 55 ndn:/test-nfdc udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| if [[ "ERROR" == $faceId* ]]; then |
| echo "nfdc: Failed to register ndn:/test-nfdc for $IP4_B1" >> $testLog |
| clean_up |
| exit 1 |
| fi |
| check_nfd_status_correctness $faceId udp4://$IP4_B1 /test-nfdc 55 |
| |
| # Invoke nfdc to unregister the prefix |
| unregisterPrefix=$(nfdc unregister ndn:/test-nfdc $faceId) |
| sleep 2 |
| # check the existence of ndn:/test-nfdc FIB entry |
| fibEntry=$(nfd-status | grep /test-nfdc) |
| if [ ! -z "$fibEntry" ]; then |
| echo "nfd-status: Failed to unregister prefix" >> $testLog |
| clean_up |
| exit 2 |
| fi |
| clean_up |
| fi |
| |
| clean_up |
| exit 0 |
| |