integration-tests: route inheritance flags

refs: #1687

Change-Id: If334f39ab119d608bc66dafce022397dab3dd17c
diff --git a/test_route_inheritance/route-inheritance-test.sh b/test_route_inheritance/route-inheritance-test.sh
new file mode 100755
index 0000000..2d2f0b7
--- /dev/null
+++ b/test_route_inheritance/route-inheritance-test.sh
@@ -0,0 +1,208 @@
+#!/usr/bin/env bash
+source ../multi-host.conf
+workDir=$(pwd)
+logDir=$workDir/logs
+testLogA=$logDir/route-inheritanceA.log
+testLogB=$logDir/route-inheritanceB.log
+testLogC=$logDir/route-inheritanceC.log
+testLogD=$logDir/route-inheritanceD.log
+mkdir -p $workDir/logs
+
+echo "Starting nfd on host A" > $testLogA
+# start nfd on localhost (A)
+sudo nfd &> $logDir/nfdA.log &
+
+# start nfd on hostB
+ssh $CTRL_B "mkdir -p $logDir ; sudo nfd &> $logDir/nfdB.log &\
+  echo 'Starting nfd on host B' > $testLogB ; sleep 2"
+
+# start nfd on hostC
+ssh $CTRL_C "mkdir -p $logDir ; sudo nfd &> $logDir/nfdC.log &\
+  echo 'Starting nfd on host C' > $testLogC ; sleep 2"
+
+# start nfd on hostD
+ssh $CTRL_D "mkdir -p $logDir ; sudo nfd &> $logDir/nfdD.log &\
+  echo 'Starting nfd on host D' > $testLogD ; sleep 2"
+
+# set multicast strategy for root namespace on A
+nfdc set-strategy / /localhost/nfd/strategy/multicast
+
+# run traffic generator on B,C,D
+ssh $CTRL_B "echo 'starting ndn-traffic-server on B' > $testLogB &\
+  ndn-traffic-server $workDir/NDNTrafficServer.conf &> $logDir/serverB.log &"
+ssh $CTRL_C "echo 'starting ndn-traffic-server on C' > $testLogC &\
+  ndn-traffic-server $workDir/NDNTrafficServer.conf &> $logDir/serverC.log &"
+ssh $CTRL_D "echo 'starting ndn-traffic-server on D' > $testLogD &\
+  ndn-traffic-server $workDir/NDNTrafficServer.conf &> $logDir/serverD.log &"
+
+echo "setting up routes..."
+
+# on A, add ndn:/ , nexthop=hostB, CHILD_INHERIT=yes, CAPTURE=no
+nfdc register ndn:/ udp4://$IP4_B1:6363 >> $testLogA
+
+# on A, add ndn:/ , nexthop=hostC, CHILD_INHERIT=no, CAPTURE=no
+nfdc register -I ndn:/ udp4://$IP4_C1:6363 >> $testLogA
+
+# on A, add ndn:/A , nexthop=hostB, CHILD_INHERIT=yes, CAPTURE=no
+nfdc register ndn:/A udp4://$IP4_B1:6363 >> $testLogA
+
+# on A, add ndn:/A/B/C , nexthop=hostD, CHILD_INHERIT=yes, CAPTURE=no
+nfdc register ndn:/A/B/C udp4://$IP4_D1:6363 >> $testLogA
+
+# on A, add ndn:/D , nexthop=hostC, CHILD_INHERIT=yes, CAPTURE=yes
+nfdc register -C ndn:/D udp4://$IP4_C1:6363 >> $testLogA
+
+# on A, add ndn:/D , nexthop=hostD, CHILD_INHERIT=yes, CAPTURE=no
+nfdc register ndn:/D udp4://$IP4_D1:6363 >> $testLogA
+
+sleep 2
+
+
+# run traffic generator clients on A
+echo "running traffic generator client1..."
+ndn-traffic -c 20 -i 200 $workDir/NDNTrafficClient1.conf > $logDir/client1.log 2>&1
+
+echo "running traffic generator client2..."
+ndn-traffic -c 20 -i 200 $workDir/NDNTrafficClient2.conf > $logDir/client2.log 2>&1
+
+echo "running traffic generator client3..."
+ndn-traffic -c 20 -i 200 $workDir/NDNTrafficClient3.conf > $logDir/client3.log 2>&1
+
+echo "running traffic generator client4..."
+ndn-traffic -c 20 -i 200 $workDir/NDNTrafficClient4.conf > $logDir/client4.log 2>&1
+
+
+# stop traffic generator server on B,C,D and kill local nfd
+echo "killing ndn-traffic-server on B, C and D..."
+ssh $CTRL_B "sudo killall ndn-traffic-server; sudo killall nfd >> $testLogB 2>&1"
+ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd >> $testLogC 2>&1"
+ssh $CTRL_D "sudo killall ndn-traffic-server; sudo killall nfd >> $testLogD 2>&1"
+sudo killall nfd 2>&1
+
+sleep 2
+
+# collect data from servers
+scp $CTRL_B:$logDir/serverB.log $logDir/serverB.log
+scp $CTRL_C:$logDir/serverC.log $logDir/serverC.log
+scp $CTRL_D:$logDir/serverD.log $logDir/serverD.log
+
+#### verify server numbers of server B ####
+echo "analyzing result of server B"
+received=$(grep -A 1 "Name=ndn:/A/P," $logDir/serverB.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: B received $received interests of ndn:/A/P out of the 20 sent by A. &\
+      At least 18 were supposed to arrive at B due to CHILD_INHERIT flag of /A towards B."
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/A/B/C/Q," $logDir/serverB.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: B received $received interests of ndn:/A/B/C/Q out of the 20 sent by A. &\
+      At least 18 were supposed to arrive at B due to CHILD_INHERIT flag of /A towards B."
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/D/R," $logDir/serverB.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -ne 0 ]]
+then
+echo "FAIL: B received $received interests of ndn:/D/R out of 20 sent by A. &\
+      There is no available route for ndn:/D/R at A towards B so 0 interests were supposed to arrive at B."
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/S," $logDir/serverB.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: B received $received interests of ndn:/S out of the 20 sent by A. &\
+      At least 18 were supposed to arrive at B due to CHILD_INHERIT flag of / towards B."
+exit 1
+fi
+
+#### verify server numbers of server C ####
+echo "analyzing result of server C"
+received=$(grep -A 1 "Name=ndn:/A/P," $logDir/serverC.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -ne 0 ]]
+then
+echo "FAIL: C received $received interests of ndn:/A/P out of 20 sent by A. &\
+      There is no available route for ndn:/A/P at A towards C so 0 interests were supposed to arrive at C."
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/A/B/C/Q," $logDir/serverC.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -ne 0 ]]
+then
+echo "FAIL: C received $received interests of ndn:/A/B/C/Q out of 20 sent by A. &\
+      There is no available route for ndn:/A/B/C/Q at A towards C so 0 interests were supposed to arrive at C."
+
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/D/R," $logDir/serverC.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: C received $received interests of ndn:/D/R out of the 20 sent by A. &\
+            At least 18 were supposed to arrive at C due to CHILD_INHERIT flag of /D towards C."
+
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/S," $logDir/serverC.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: C received $received interests of ndn:/S out of the 20 sent by A. &\
+      Longest-prefix match of ndn:/S in A is ndn:/ and therefore at least 18 were supposed to arrive at C."
+
+exit 1
+fi
+
+#### verify server numbers of server D ####
+echo "analyzing result of server D"
+received=$(grep -A 1 "Name=ndn:/A/P," $logDir/serverD.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -ne 0 ]]
+then
+echo "FAIL: D received $received interests of ndn:/A/P out of 20 sent by A. &\
+      There is no available route for ndn:/A/P at A towards D so 0 interests were supposed to arrive at D."
+
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/A/B/C/Q," $logDir/serverD.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: D received $received interests of ndn:/A/B/C/Q out of the 20 sent by A. &\
+      At least 18 were supposed to arrive at D due to CHILD_INHERIT flag of /A/B/C towards D."
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/D/R," $logDir/serverD.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -lt 18 ]]
+then
+echo "FAIL: D received $received interests of ndn:/D/R out of the 20 sent by A. &\
+      At least 18 were supposed to arrive at D due to CHILD_INHERIT flag of /D towards D."
+exit 1
+fi
+
+received=$(grep -A 1 "Name=ndn:/S," $logDir/serverD.log | grep "Total Interests Received" |
+           cut -d= -f2 | cut -d' ' -f2)
+if [[ $received -ne 0 ]]
+then
+echo "FAIL: D received $received interests of ndn:/S out of 20 sent by A. &\
+      There is no available route for ndn:/S at A towards D so 0 interests were supposed to arrive at D."
+exit 1
+fi
+
+echo "Test passed successfully"
+exit 0