Add Nack handling to CS freshness test and localhop test
Bring implementation of localhop test in line with design
refs #3692
Change-Id: I40c49b68b03aa1996e5546465daaccc18e29853e
diff --git a/test_localhop/localhop-test.sh b/test_localhop/localhop-test.sh
index 796fb95..549b8d1 100755
--- a/test_localhop/localhop-test.sh
+++ b/test_localhop/localhop-test.sh
@@ -7,68 +7,57 @@
clean_up() {
r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
+ r=$(ssh $CTRL_C "sudo killall nfd-traffic-server" 2>&1)
r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
r=$(sudo killall nfd 2>&1)
}
mkdir -p logs
-# start nfd and ndn-traffic-server on host C
+# Start NFD on A, B, and C
workdir=$(pwd)
-echo "starting nfd and ndn-traffic-server on host C..."
-ssh $CTRL_C "mkdir -p $workdir/logs;\
- sudo nfd > $workdir/logs/nfd.log 2>&1 &\
- sleep 3;\
- ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
+echo "starting nfd on host A..."
+sudo nfd > $workdir/logs/nfd.log 2>&1 &
+sleep 1
-# start nfd and add nexthop of ndn:/localhop to C on host B
-echo "starting nfd and adding nexthop of ndn:/localhop to C on host B..."
+echo "starting nfd on host B..."
ssh $CTRL_B "mkdir -p $workdir/logs;\
- $workdir/hostB.sh $workdir $c_ipaddr"
+ sudo nfd &> $workdir/logs/nfd.log &"
+sleep 1
-# start nfd and add nexthop of ndn:/localhop to B on host A
-echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..."
-sudo nfd > logs/nfd.log 2>&1 &
-sleep 3
+echo "starting nfd on host C..."
+ssh $CTRL_C "mkdir -p $workdir/logs;\
+ sudo nfd &> $workdir/logs/nfd.log &"
+sleep 1
+
+# On A, add nexthop of `ndn:/localhop` to B
nfdc add-nexthop ndn:/localhop udp4://$b_ipaddr
if [[ $? -ne 0 ]]
then
- echo "Fail to add nexthop of ndn:/localhop"
+ echo "Failed to add nexthop of ndn:/localhop"
clean_up
exit 2
fi
-# From A, send interest ndn:/localhop/test-localhop/A/1
-echo "From A, sending interest ndn:/localhop/test-localhop/A/1..."
-output=$(ndnpeek -p ndn:/localhop/test-localhop/A/1)
-if [[ ! -z $output ]]
+# On B, add nexthop of `ndn:/localhop` to C
+ssh $CTRL_B "nfdc add-nexthop ndn:/localhop udp4://$c_ipaddr"
+
+# On C, start ndn-traffic-server
+echo "starting ndn-traffic-server on host C..."
+ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
+
+# From A, send interest ndn:/localhop/test-localhop/1
+echo "From A, sending interest ndn:/localhop/test-localhop/1..."
+output=$(ndnpeek -p ndn:/localhop/test-localhop/1)
+if [[ $? == "0" ]]
then
- echo "ndn:/localhop/test-localhop/A/1 is answered."
+ echo "Interest ndn:/localhop/test-localhop/1 answered with a Data."
clean_up
exit 4
fi
-# From B, send interest ndn:/localhop/test-localhop/B/1
-echo "From B, sending interest ndn:/localhop/test-localhop/B/1..."
-output=$(ssh $CTRL_B "ndnpeek -p ndn:/localhop/test-localhop/B/1")
-if [[ $output != BBBBBBBB ]]
-then
- echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output"
- clean_up
- exit 5
-fi
-
-# stop ndn-traffic-server and nfd on host C
-echo "stopping ndn-traffic-server and nfd on host C..."
-ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
-
-# stop nfd on host B
-echo "stopping nfd on host B..."
-ssh $CTRL_B "sudo killall nfd"
-
-# stop nfd on host A
-echo "stopping nfd on host A..."
-sudo killall nfd
+echo "stopping nfd and ndn-traffic-server instances..."
+clean_up
# copy back the server log
echo "copying back ndn-traffic-server log..."
@@ -77,10 +66,11 @@
# analyze server log
echo "analyzing server log..."
output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2)
-if [[ $output != 0?(.+(0)) ]]
+# output can be empty due to a receive error (End of file)
+if [[ -n $output ]] && [[ $output != 0?(.+(0)) ]]
then
- echo "Expected no interests with name ndn:/localhop/test-localhop/A/1 received on host C. Actual: $output"
- echo "For more information, please examine the log at \"$(pwd)/logs\""
+ echo "Expected no interests with name ndn:/localhop/test-localhop/1 to be received on host C. Actual: '$output'"
+ echo "For more information, please examine the logs at \"$(pwd)/logs\""
clean_up
exit 3
fi