integration-tests: test udp permanent face
refs: #2994
Change-Id: I7fcde62b12f9d9c83dfe2e9a072c1b0158ebe39d
diff --git a/test_permanent_face/permanent-face-test.sh b/test_permanent_face/permanent-face-test.sh
new file mode 100755
index 0000000..66542ae
--- /dev/null
+++ b/test_permanent_face/permanent-face-test.sh
@@ -0,0 +1,85 @@
+#!/usr/bin/env bash
+source ../multi-host.conf
+workDir=$(pwd)
+logDir=$workDir/logs
+testLogA=$logDir/permanent-faceA.log
+testLogB=$logDir/permanent-faceB.log
+
+mkdir -p $workDir/logs
+
+echo "About to start 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 'About to start nfd on host B' > $testLogB ; sleep 2"
+
+# on B, start ndnpingserver for prefix /B
+ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &"
+
+# on A, create a UDP permanent face toward B
+nfdc create -P udp://$IP4_B1 >> $testLogA
+
+# on A, register prefix ndn:/B on the face created in step 3
+nfdc register ndn:/B udp4://$IP4_B1:6363 >> $testLogA
+
+# on A, execute ndnping for prefix ndn:/B with client specifier "a" for 10 probes
+pingOutput=$(ndnping ndn:/B -p a -c 10)
+echo $pingOutput >> $testLogA
+
+# fail the scenario if loss rate is more than 15%
+loss=$(echo $pingOutput | grep -i 'packet loss' | grep -Po '\d*%' | sed 's/%//')
+echo "LOSS rate of first ping is: $loss" >> $testLogA
+if [[ $loss -gt 15 ]]; then
+ echo "LOSS rate is greater than 15. FAILED!" >> $testLogA
+ sudo killall nfd 2>&1
+ ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
+ exit 1
+fi
+
+
+# stop NFD on B
+ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1 "
+
+# on A, execute ndnping for prefix ndn:/B with client specifier "b" for 10 probes
+pingOutput=$(ndnping ndn:/B -p b -c 10)
+echo $pingOutput >> $testLogA
+
+# fail the scenario if loss rate is less than 100%
+loss=$(echo $pingOutput | grep -i 'packet loss' | grep -Po '\d*%' | sed 's/%//')
+echo "LOSS rate of second ping is: $loss" >> $testLogA
+if [[ $loss -lt 100 ]]; then
+ echo "LOSS rate is less than 100. FAILED!" >> $testLogA
+ ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
+ exit 1
+fi
+
+
+# start nfd on hostB
+ssh $CTRL_B "mkdir -p $workDir/logs/ ; sudo nfd &> $workDir/logs/nfdB.log &\
+ sleep 2"
+sleep 2
+
+# on B, start ndnpingserver for prefix /B
+ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &"
+
+# on A, execute ndnping for prefix ndn:/B with client specifier "c" for 10 probes
+pingOutput=$(ndnping ndn:/B -p c -c 10)
+echo $pingOutput >> $testLogA
+
+# fail the scenario if loss rate is more than 15%
+loss=$(echo $pingOutput | grep -i 'packet loss' | grep -Po '\d*%' | sed 's/%//')
+echo "LOSS rate of third ping is: $loss" >> $testLogA
+if [[ $loss -gt 15 ]]; then
+ echo "LOSS rate is greater than 15. FAILED!" >> $testLogA
+ sudo killall nfd 2>&1
+ ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
+ exit 1
+fi
+
+# cleanup
+sudo killall nfd 2>&1
+ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
+
+exit 0