Redesign nfdc test case to use new nfdc syntax
refs #4058
Change-Id: If48027509c3c8865334b776a30f420c5fafa02ec
diff --git a/test_nfdc/README.md b/test_nfdc/README.md
index 1c8ea51..ebb25ed 100644
--- a/test_nfdc/README.md
+++ b/test_nfdc/README.md
@@ -1,4 +1,4 @@
-Test Case - nfdc and nfd-status
+Test Case - nfdc
=====================
## Topology ##
@@ -9,57 +9,55 @@
## Description ##
-The script runs 3 test cases:
-A: Test nfdc create / add-nexthop / destroy test case
-B: Test nfdc add-nexthop / remove-nexthop test case
-C: Test nfdc register / unregister test case
+The script tests the following nfdc commands:
+* `nfdc face create`
+* `nfdc face destroy`
+* `nfdc face list`
+* `nfdc face show`
+* `nfdc fib list`
+* `nfdc route add`
+* `nfdc route list`
+* `nfdc route remove`
+* `nfdc route show`
+* `nfdc strategy set`
+* `nfdc strategy show`
+* `nfdc strategy unset`
In case of a failure, the detailed log can be found under:
A: test_nfdc/log/nfdc_test_A.log
B: test_nfdc/log/nfdc_test_B.log
-C: test_nfdc/log/nfdc_test_C.log
-## Test case A: Test nfdc create / add-nexthop / destroy test case ##
-Start NFD on host A and B.
-On host A, run the following steps:
+## Steps ##
+Start NFD on hosts A and B.
+On host A, do the following:
-1. Execute nfd-status. Check the existence of udp4/udp6/ether multicast faces.
-2. Invoke nfdc create tcp://$IP4_B1. Pause 2 seconds for connection establishment.
-3. Execute nfd-status. Check the existence of new tcp4 face.
-4. Invoke nfdc create tcp://[$IP6_B1]. Pause 2 seconds for connection establishment.
-5. Execute nfd-status. Check the existence of new tcp6 face.
-6. Invoke nfdc create udp://$IP4_B1. Pause 2 seconds for connection establishment.
-7. Execute nfd-status. Check the existence of new udp4 face.
-8. Invoke nfdc create udp://[$IP6_B1]. Pause 2 seconds for connection establishment.
-9. Execute nfd-status. Check the existence of new udp6 face.
-10. Invoke nfdc to add a nexthop for ndn:/test-nfdc with cost 24 toward FaceId created in step 3.
-11. Invoke nfdc to add a nexthop for ndn:/test-nfdc with cost 26 toward FaceId created in step 5.
-12. Invoke nfdc to add a nexthop for ndn:/test-nfdc with cost 14 toward FaceId created in step 7.
-13. Invoke nfdc to add a nexthop for ndn:/test-nfdc with cost 16 toward FaceId created in step 9.
-14. Execute nfd-status. Check the existence of ndn:/test-nfdc FIB entry, and the correctness of cost on nexthop records.
-15. Invoke nfdc to choose MulticastStrategy for ndn:/ namespace.
-16. Invoke ndnping to send 100 Interests under ndn:/test-nfdc prefix.
-17. Pause 50ms before sending each Interest.
-18. Execute nfd-status. Verify NOutInterests counters of faces created in step 3,5,7,9 are greater than 60.
-19. On host B, execute nfd-status. Check the existence of tcp4, tcp6, udp4, udp6 faces with host A's address. Verify NInInterests counters for those faces are greater than 60.
-20. Invoke nfdc to destroy FaceIds created in step 3,5.
-21. Execute nfd-status. Check the non-existence of tcp4 and tcp6 faces.
-
-## Test case B: Test nfdc add-nexthop / remove-nexthop test case ##
-Start NFD on host A and B.
-On host A, run the following steps:
-
-1. Invoke nfdc add-nexthop -c 44 ndn:/test-nfdc udp4://$IP4_B1. Pause 2 seconds for connection establishment.
-2. Execute nfd-status. Check the existence of new udp4 face. Check the existence of ndn:/test-nfdc FIB entry, and the correctness of cost on nexthop records.
-3. Invoke nfdc to remove the nexthop for FaceId seen in step 3.
-4. Execute nfd-status. Check the non-existence of ndn:/test-nfdc FIB entry.
-
-## Test case C: Test nfdc register / unregister test case ##
-Start NFD on host A and B.
-On host A, run the following steps:
-1. Invoke nfdc register -c 55 ndn:/test-nfdc udp4://$IP4_B1. Pause 2 seconds for connection establishment.
-2. Execute nfd-status. Check the existence of new udp4 face. Check the existence of ndn:/test-nfdc FIB entry, and the correctness of cost on nexthop records.
-3. Invoke nfdc to unregister the prefix ndn:/test-nfdc for FaceId seen in step 3.
-4. Execute nfd-status. Check the non-existence of ndn:/test-nfdc FIB entry.
-
-
+1. Execute `nfdc face list` to check for the existence of udp4/udp6/ether multicast faces.
+2. Execute `nfdc face create tcp4://$IP4_B1`. Pause 2 seconds to allow for connection establishment.
+3. Execute `nfdc face list` to check for the existence of the new tcp4 face.
+4. Execute `nfdc face create tcp6://[$IP6_B1]`. Pause 2 seconds to allow for connection establishment.
+5. Execute `nfdc face show id [faceId from step 4]` to check for the existence of the new tcp6 face.
+6. Execute `nfdc face create udp4://$IP4_B1`. Pause 2 seconds to allow for connection establishment.
+7. Execute `nfdc face list remote udp4://$IP4_B1` to check for the existence of the new udp4 face.
+8. Execute `nfdc face create udp6://[$IP6_B1]`. Pause 2 seconds to allow for connection establishment.
+9. Execute `nfdc face list` to check for the existence of the new udp6 face.
+10. Execute `nfdc route add /test-nfdc nexthop tcp4://$IP4_B1 cost 24`
+11. Execute `nfdc route add /test-nfdc nexthop tcp6://[$IP6_B1] cost 26`
+12. Execute `nfdc route add /test-nfdc nexthop udp4://$IP4_B1 cost 14`
+13. Execute `nfdc route add /test-nfdc nexthop udp6://[$IP6_B1] cost 16`
+14. Execute `nfdc route list` and `nfdc route show` to check for the existence of the four created routes.
+15. Execute `nfdc fib list` to check for the existence of the `/test-nfdc` FIB entry with the correct nexthops and costs
+16. Execute `nfdc strategy set /test-nfdc /localhost/nfd/strategy/multicast` to use MulticastStrategy for prefix `/test-nfdc`.
+17. Execute `nfdc strategy show /test-nfdc` to verify the strategy set in step 16.
+18. Use `ndnping` to send 100 Interests to the `/test-nfdc` prefix, with a 50ms interval between sending each Interest.
+19. Execute `nfdc face list` to verify that NOutInterests for faces created in steps 2, 4, 6, and 8 are greater than 100.
+20. On host B, execute `nfdc face list` to verify that tcp4, tcp6, udp4, and udp6 faces exist for host A's address.
+ Verify that NInInterests for those faces is greater than 100.
+21. Execute `nfdc face destroy` to destroy faces tcp4://$IP_B1 and tcp6://[$IP6_B1] and use
+ `nfdc face list` to verify that removed faces no longer exist.
+22. Execute `nfdc strategy unset /test-nfdc` to unset the MulticastStrategy set in step 16.
+23. Execute `nfdc strategy show /test-nfdc` to ensure that `/` no longer uses MulticastStrategy.
+24. Execute `nfdc route remove /test-nfdc nexthop udp4://$IP4_B1`.
+25. Execute `nfdc route list` to ensure route has been removed.
+26. Execute `nfdc fib list` to ensure that the nexthop has been updated to use the new best route.
+27. Execute `nfdc route remove /test-nfdc nexthop udp6://[$IP6_B1]`.
+28. Execute `nfdc fib list` to ensure that nexthop has been removed, since the last route to prefix `/test-nfdc` has been removed.
diff --git a/test_nfdc/include.sh b/test_nfdc/include.sh
index 4319e9f..fcfceac 100755
--- a/test_nfdc/include.sh
+++ b/test_nfdc/include.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-NUM_OF_PINGS=10
+NUM_OF_PINGS=100
# clean up - kill nfd
clean_up() {
@@ -9,110 +9,216 @@
start_nfd() {
# start nfd on localhost
- sudo nfd &> $workdir/logs/$1/nfd.log &
+ sudo nfd &> $workdir/logs/nfd.log &
# start nfd on hostB
- ssh $CTRL_B "mkdir -p $workdir/logs/$1 ; sudo nfd &> $workdir/logs/$1/nfd.log &\
- sleep 2"
+ ssh $CTRL_B "mkdir -p $workdir/logs ; sudo nfd &> $workdir/logs/nfd.log & sleep 2"
sleep 2
}
-
-check_nfd_status_counters() {
- faceId=$1
- faceUri=$2
- counterType=$3
- threshold=$4
+# check whether a given face with the specified FaceId and URI has had at least a given number of
+# incoming/outgoing Interests
+# param list: $1 - face ID
+# $2 - face URI
+# $3 - counter type (in/out)
+# $4 - minimum successful value of the counter
+check_nfdc_face_counters() {
+ local faceId=$1
+ local faceUri=$2
+ local counterType=$3
+ local threshold=$4
# wait for the refreshed output of nfd-status
sleep 2
- outCounter=$(nfd-status | grep -iF 'faceid='$faceId' remote='$faceUri | grep -Po $counterType={[0-9]+ | sed 's/'$counterType'={//')
+ local counter=$(nfdc face list | grep -iF "faceid=$faceId remote=$faceUri" | sed -E "s/.*${counterType}=\{([0-9]+)i.*/\1/")
-
- if [[ $outCounter -lt $threshold ]]; then
- if [[ "out" = $counterType ]]; then
- echo "nfd-status: out counter of face=$faceId is less than $threshold " >> $testLog
- echo "nfd-status is:" >> $testLog
- nfd-status >> $testLog
- clean_up
- fi
+ if [[ $counter -lt $threshold ]]; then
+ echo "nfdc: $counterType counter of face=$faceId is less than $threshold " >> $testLog
+ echo "'nfdc face list' is:" >> $testLog
+ nfdc face list >> $testLog
+ clean_up
exit 2
-
fi
-
}
-# check for the existence of the face
-# param list: $1 - face Id
-# $2 - face Uri
-check_nfd_status_face_existence() {
- faceId=$1
- faceUri=$2
+# check for the existence of a face with the specified FaceId and URI
+# param list: $1 - face ID
+# $2 - face URI
+check_nfdc_face_existence() {
+ local faceId=$1
+ local faceUri=$2
- # wait for the refreshed output of nfd-status
+ # wait for the refreshed output of nfdc
sleep 2
- # check for the existence of the face
+ # check for the existence of the specified face
# First, get the face line
# Second, extract the face id attached to the fetched line
- face=$(nfd-status | grep -iF remote=$faceUri | grep -Po faceid=\[0-9\]+ | sed 's/faceid=//')
+ local face=$(nfdc face list | grep -iF "remote=$faceUri" | sed -E "s/.*faceid=([0-9]+).*/\1/")
- if [[ "none" != $faceId ]]; then
- if [[ $face != $faceId ]]; then
- echo "nfd-status: Failed to find face $faceId of $faceUri" >> $testLog
- echo "nfd-status is:" >> $testLog
- nfd-status >> $testLog
- echo "-1"
- else
- echo $face
- fi
+ if [[ $faceId != "none" && $face != $faceId ]]; then
+ echo "nfdc: Failed to find face $faceId to $faceUri" >> $testLog
+ echo "'nfdc face list' is:" >> $testLog
+ nfdc face list >> $testLog
+ echo "-1"
else
echo $face
fi
-
}
+# check for the existence of a face with the specified FaceId and URI using `nfdc face show`
+# param list: $1 - face ID
+# $2 - face URI
+check_nfdc_face_existence_show() {
+ local faceId=$1
+ local faceUri=$2
-# This function checks for the existence of a face and a fib entry
-# including nexthop records
-# param list: $1 - face Id
-# $2 - face Uri
-# $3 - prefix
-# $4 - cost
-check_nfd_status_correctness() {
- faceId=$1
- faceUri=$2
- prefix=$3
- cost=$4
-
- face=$(check_nfd_status_face_existence $faceId $faceUri)
- if [[ "-1" = $face ]]; then
- clean_up
- exit 2
- fi
-
- # wait for the refreshed output of nfd-status
+ # wait for the refreshed output of nfdc
sleep 2
- # check the existence of prefix FIB entry
- fibEntry=$(nfd-status | grep $prefix)
- if [[ -z "$fibEntry" ]]; then
- echo "nfd-status: Failed to find $prefix in FIB table" >> $testLog
- echo "nfd-status is:" >> $testLog
- nfd-status >> $testLog
- clean_up
- exit 2
+ # check for the existence of the specified face
+ # Extract the remote URI
+ local actualUri=$(nfdc face show id $faceId | grep -iFo "remote=$faceUri" | sed 's/remote=//')
+
+ if [[ "$actualUri" != "$faceUri" ]]; then
+ echo "nfdc: Failed to find face $faceId to $faceUri" >> $testLog
+ echo "'nfdc face show id $faceId' is:" >> $testLog
+ nfdc face show id $faceId >> $testLog
+ echo "-1"
+ else
+ echo $face
+ fi
+}
+
+# check for the existence of a face with the specified FaceId and URI using `nfdc face list`, filtered
+# for remote URI
+# param list: $1 - face ID
+# $2 - face URI
+check_nfdc_face_existence_remote_uri() {
+ local faceId=$1
+ local faceUri=$2
+
+ # wait for the refreshed output of nfdc
+ sleep 2
+
+ # check for the existence of the specified face
+ # First, get the face line
+ # Second, extract the face id attached to the fetched line
+ local face=$(nfdc face list remote $faceUri | grep -iF "remote=$faceUri" | grep -Po "faceid=[0-9]+" | sed 's/faceid=//')
+
+ if [[ "none" != $faceId && $face != $faceId ]]; then
+ echo "nfdc: Failed to find face $faceId to $faceUri" >> $testLog
+ echo "'nfdc face list remote $faceUri' is:" >> $testLog
+ nfdc face list >> $testLog
+ echo "-1"
+ else
+ echo $face
+ fi
+}
+
+# check for the existence of a route for a given prefix with nexthop face ID and cost
+# param list: $1 - route prefix
+# $2 - nexthop face ID
+# $3 - route cost
+# $4 - if set, check if route does not exist (optional)
+check_nfdc_route_existence() {
+ local prefix=$1
+ local nexthop=$2
+ local cost=$3
+ local noexist=false
+ if [[ $# -gt 3 ]]; then
+ noexist=true
fi
- # check the correctness of cost on nexthop records
- fibEntryCost=$(echo $fibEntry | grep -Po 'faceid='$faceId'.\(cost=[0-9]+\)' | sed 's/faceid='$faceId' //' | sed 's/(cost=//' | sed 's/)//')
+ local routeInfo=$(nfdc route list | grep "^prefix=$prefix nexthop=$nexthop origin=[a-zA-Z0-9]* cost=$cost flags=")
- if [[ $cost != $fibEntryCost ]]; then
- echo "nfd-status: nexthop records are incorrect, expected cost is $cost, cost in records $fibEntryCost" >> $testLog
- echo "nfd-status is:" >> $testLog
- nfd-status >> $testLog
- clean_up
- exit 2
+ if [[ $noexist == false ]]; then
+ if [[ -z $routeInfo ]]; then
+ echo "nfdc: Failed to find route to $prefix with nexthop $nexthop and cost $cost" >> $testLog
+ echo "'nfdc route list' is:" >> $testLog
+ nfdc route list >> $testLog
+ clean_up
+ exit 2
+ fi
+ else
+ if [[ -n $routeInfo ]]; then
+ echo "nfdc: Failed to remove route to $prefix with nexthop" >> $testLog
+ echo "'nfdc route list' is:" >> $testLog
+ nfdc route list >> $testLog
+ clean_up
+ exit 2
+ fi
+ fi
+}
+
+# check for the existence of a route for a given prefix with nexthop face ID and cost using
+# `nfdc route show`
+# param list: $1 - route prefix
+# $2 - nexthop face ID
+# $3 - route cost
+# $4 - if set, check if route does not exist (optional)
+check_nfdc_route_existence_show() {
+ local prefix=$1
+ local nexthop=$2
+ local cost=$3
+ local noexist=false
+ if [[ $# -gt 3 ]]; then
+ noexist=true
+ fi
+
+ local routeInfo=$(nfdc route show $prefix | grep "^prefix=$prefix nexthop=$nexthop origin=[a-zA-Z0-9]* cost=$cost flags=")
+
+ if [[ $noexist == false ]]; then
+ if [[ -z $routeInfo ]]; then
+ echo "nfdc: Failed to find route to $prefix with nexthop $nexthop and cost $cost" >> $testLog
+ echo "'nfdc route list' is:" >> $testLog
+ nfdc route list >> $testLog
+ clean_up
+ exit 2
+ fi
+ else
+ if [[ -n $routeInfo ]]; then
+ echo "nfdc: Failed to remove route to $prefix with nexthop" >> $testLog
+ echo "'nfdc route list' is:" >> $testLog
+ nfdc route list >> $testLog
+ clean_up
+ exit 2
+ fi
+ fi
+}
+
+# check for the existence of a given route for a given nexthop
+# param list: $1 - route prefix
+# $2 - nexthop face ID
+# $3 - route cost
+# $4 - if set, check if route does not exist (optional)
+check_nfdc_nexthop_existence() {
+ local prefix=$1
+ local faceId=$2
+ local cost=$3
+ local noexist=false
+ if [[ $# -gt 3 ]]; then
+ noexist=true
+ fi
+
+ local nexthopInfo=$(nfdc fib list | grep "^ $prefix" | grep "faceid=$faceId (cost=$cost)")
+
+ if [[ $noexist == false ]]; then
+ if [[ -z $nexthopInfo ]]; then
+ echo "nfdc: Failed to find route to $prefix via $faceId with cost $cost in FIB" >> $testLog
+ echo "'nfdc fib list' is:" >> $testLog
+ nfdc fib list >> $testLog
+ clean_up
+ exit 2
+ fi
+ else
+ if [[ -n $nexthopInfo ]]; then
+ echo "nfdc: Failed to remove route to $prefix via $faceId with from FIB" >> $testLog
+ echo "'nfdc fib list' is:" >> $testLog
+ nfdc fib list >> $testLog
+ clean_up
+ exit 2
+ fi
fi
}
diff --git a/test_nfdc/nfdc-test.sh b/test_nfdc/nfdc-test.sh
index fcaecc0..f52105b 100755
--- a/test_nfdc/nfdc-test.sh
+++ b/test_nfdc/nfdc-test.sh
@@ -2,180 +2,195 @@
source ../multi-host.conf
source include.sh
workdir=$(pwd)
-mkdir -p $workdir/logs/$1
-testCase=$1
-testLog=$workdir/logs/$testCase/nfdc_test.log
+mkdir -p $workdir/logs
+testLog=$workdir/logs/nfdc_test.log
echo "TEST START" > $testLog
-start_nfd $testCase
+start_nfd
-# run test case A: test nfdc create / add-nexthop / destroy test case
-if [[ $testCase == 'A' ]]; then
+# 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:")
- # 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 MulticastStrategy for ndn:/ namespace.
- nfdc set-strategy ndn:/ ndn:/localhost/nfd/strategy/multicast
-
- ndnping -c $NUM_OF_PINGS ndn:/test-nfdc
-
- 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
-
+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
-# 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
+# 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
-# run test case C: test nfdc register / unregister test case
-elif [[ $testCase == 'C' ]]; then
+#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 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
+# 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
-
diff --git a/test_nfdc/test-B.sh b/test_nfdc/test-B.sh
index fad09d0..3e33002 100755
--- a/test_nfdc/test-B.sh
+++ b/test_nfdc/test-B.sh
@@ -1,50 +1,50 @@
#!/usr/bin/env bash
workDir=$1
+testLog=$workDir/logs/nfdc_test.log
source $workDir/../multi-host.conf
source $workDir/include.sh
#compress IPv6
IP6_A1=$(python -c "import sys; import socket; result = socket.getaddrinfo('$IP6_A1', None); family, socktype, proto, canonname,(address, port, flow_info, scope_id) = result[0]; print address")
-remoteFaceIdUdp4=$(check_nfd_status_face_existence none udp4://$IP4_A1)
+remoteFaceIdUdp4=$(check_nfdc_face_existence none udp4://$IP4_A1)
if [[ -z "$remoteFaceIdUdp4" ]]; then
exit 3
fi
-remoteFaceIdTcp4=$(check_nfd_status_face_existence none tcp4://$IP4_A1)
+remoteFaceIdTcp4=$(check_nfdc_face_existence none tcp4://$IP4_A1)
if [[ -z "$remoteFaceIdTcp4" ]]; then
exit 3
fi
-remoteFaceIdUdp6=$(check_nfd_status_face_existence none udp6://[$IP6_A1])
+remoteFaceIdUdp6=$(check_nfdc_face_existence none udp6://[$IP6_A1])
if [[ -z "$remoteFaceIdUdp6" ]]; then
exit 3
fi
-remoteFaceIdTcp6=$(check_nfd_status_face_existence none tcp6://[$IP6_A1])
+remoteFaceIdTcp6=$(check_nfdc_face_existence none tcp6://[$IP6_A1])
if [[ -z "$remoteFaceIdTcp6" ]]; then
exit 3
fi
-check_nfd_status_counters $remoteFaceIdUdp4 udp4://$IP4_A1 'in' $NUM_OF_PINGS
+check_nfdc_face_counters $remoteFaceIdUdp4 udp4://$IP4_A1 'in' $NUM_OF_PINGS
if [[ $? -ne 0 ]]; then
exit 3
fi
-check_nfd_status_counters $remoteFaceIdTcp4 tcp4://$IP4_A1 'in' $NUM_OF_PINGS
+check_nfdc_face_counters $remoteFaceIdTcp4 tcp4://$IP4_A1 'in' $NUM_OF_PINGS
if [[ $? -ne 0 ]]; then
exit 3
fi
-check_nfd_status_counters $remoteFaceIdUdp6 udp6://[$IP6_A1] 'in' $NUM_OF_PINGS
+check_nfdc_face_counters $remoteFaceIdUdp6 udp6://[$IP6_A1] 'in' $NUM_OF_PINGS
if [[ $? -ne 0 ]]; then
exit 3
fi
-check_nfd_status_counters $remoteFaceIdTcp6 tcp6://[$IP6_A1] 'in' $NUM_OF_PINGS
+check_nfdc_face_counters $remoteFaceIdTcp6 tcp6://[$IP6_A1] 'in' $NUM_OF_PINGS
if [[ $? -ne 0 ]]; then
exit 3
fi
-
exit 0
diff --git a/test_nfdc/test_nfdc.py b/test_nfdc/test_nfdc.py
index 79afcc4..5538b79 100644
--- a/test_nfdc/test_nfdc.py
+++ b/test_nfdc/test_nfdc.py
@@ -2,6 +2,7 @@
# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
# Copyright (C) 2014 Washington University in St. Louis
+# Copyright (C) 2017 Arizona Board of Regents.
# Author: Hila Ben Abraham <hila@wustl.edu>
# See COPYING for copyright and distribution information.
#
@@ -11,10 +12,10 @@
import subprocess
class test_nfdc(unittest.TestCase):
- """Test case for testing nfdc and nfd-status applications"""
+ """Test case for testing nfdc"""
def setUp(self):
- print "\nTesting nfdc and nfd-status"
+ print "\nTesting nfdc"
print "*****************************"
os.chdir("test_nfdc")
os.system("mkdir -p logs")
@@ -23,26 +24,9 @@
print "********************************"
os.chdir("..")
- def test_nfdc_A(self):
- print ">>> TEST CASE A: test nfdc create / add-nexthop / destroy test case <<<"
- ret = subprocess.call(["./nfdc-test.sh A"], shell=True)
+ def test_nfdc(self):
+ ret = subprocess.call(["./nfdc-test.sh"], shell=True)
if ret != 0:
- self.fail(" >> TEST CASE A FAILED")
+ self.fail(" >> TEST FAILED")
else:
- print ">> TEST CASE A PASSED SUCCESSFULLY"
-
- def test_nfdc_B(self):
- print ">>> TEST CASE B: test nfdc add-nexthop / remove-nexthop test case <<<"
- ret = subprocess.call(["./nfdc-test.sh B"], shell=True)
- if ret != 0:
- self.fail(" >> TEST CASE B FAILED")
- else:
- print ">> TEST CASE B PASSED SUCCESSFULLY"
-
- def test_nfdc_C(self):
- print ">>> TEST CASE C: test nfdc register / unregister test case <<<"
- ret = subprocess.call(["./nfdc-test.sh C"], shell=True)
- if ret != 0:
- self.fail(" >> TEST CASE C FAILED")
- else:
- print ">> TEST CASE C PASSED SUCCESSFULLY"
\ No newline at end of file
+ print ">> TEST PASSED SUCCESSFULLY"