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/NDNTrafficServer.conf b/test_localhop/NDNTrafficServer.conf
index 4d046f7..d55f649 100644
--- a/test_localhop/NDNTrafficServer.conf
+++ b/test_localhop/NDNTrafficServer.conf
@@ -1,7 +1,4 @@
##########
-Name=ndn:/localhop/test-localhop/A
+Name=ndn:/localhop/test-localhop
Content=AAAAAAAA
##########
-Name=ndn:/localhop/test-localhop/B
-Content=BBBBBBBB
-##########
diff --git a/test_localhop/hostB.sh b/test_localhop/hostB.sh
deleted file mode 100755
index 4402d67..0000000
--- a/test_localhop/hostB.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-workdir=$1
-c_ipaddr=$2
-sudo nfd &> $workdir/logs/nfd.log &
-sleep 3
-nfdc add-nexthop ndn:/localhop udp4://$c_ipaddr
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
diff --git a/test_localhop/test_localhop.py b/test_localhop/test_localhop.py
index 28c3ced..a2789c8 100644
--- a/test_localhop/test_localhop.py
+++ b/test_localhop/test_localhop.py
@@ -27,10 +27,9 @@
print "Test script return value:", ret
errormsg = {
1 : "Invalid command line arguments",
- 2 : "Fail to add nexthop of ndn:/localhop",
- 3 : "Interest with name ndn:/localhop/test-localhop/A/1 was received on host C",
- 4 : "ndn:/localhop/test-localhop/A/1 is answered.",
- 5 : "ndn:/localhop/test-localhop/B/1 is not correctly answered.",
+ 2 : "Failed to add nexthop of ndn:/localhop",
+ 3 : "Interest with name ndn:/localhop/test-localhop/1 was received on host C",
+ 4 : "Interest ndn:/localhop/test-localhop/1 answered with a Data.",
}
if (ret != 0):
self.fail(errormsg[ret])