integration-tests: test udp permanent face
refs: #2994
Change-Id: I7fcde62b12f9d9c83dfe2e9a072c1b0158ebe39d
diff --git a/test_permanent_face/README.md b/test_permanent_face/README.md
new file mode 100644
index 0000000..83ba5b1
--- /dev/null
+++ b/test_permanent_face/README.md
@@ -0,0 +1,24 @@
+Test Case - UDP permanent face test scenario
+=====================
+
+## Topology
+A--B
+
+test UDP permanent face minimal feature set
+
+## Procedure:
+
+1. start NFD on A and B
+2. on B, start ndnpingserver for prefix /B
+3. on A, create a UDP permanent face toward B
+4. on A, register prefix ndn:/B on the face created in step 3
+5. on A, execute ndnping for prefix ndn:/B with client specifier "a" for 10 probes; fail the scenario if loss rate is more than 15%
+6. stop NFD on B
+7. on A, execute ndnping for prefix ndn:/B with client specifier "b" for 10 probes; fail the scenario if loss rate is less than 100%
+8. start NFD on B
+9. on B, start ndnpingserver for prefix /B
+10. on A, execute ndnping for prefix ndn:/B with client specifier "c" for 10 probes; fail the scenario if loss rate is more than 15%
+
+## Return value
+PASS of all tests finished successfully.
+
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
diff --git a/test_permanent_face/test_permanent_face.py b/test_permanent_face/test_permanent_face.py
new file mode 100644
index 0000000..430c985
--- /dev/null
+++ b/test_permanent_face/test_permanent_face.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python2
+
+import os
+import unittest
+import subprocess
+
+class test_permanent_face(unittest.TestCase):
+ """Test case for testing udp permanent face"""
+
+ def setUp(self):
+ print "\nTesting UDP permanent face"
+ print "*****************************"
+ os.chdir("test_permanent_face")
+ os.system("mkdir -p logs")
+
+ def tearDown(self):
+ print "********************************"
+ os.chdir("..")
+
+ def test_permanent_face(self):
+ print ">>> test permanent face <<<"
+
+ ret = subprocess.call(['./permanent-face-test.sh'], shell=True)
+
+ if (ret != 0):
+ self.fail(" >> TEST PERMANENT FACE FAILED")
+ else:
+ print ">> TEST PERMANENT FACE PROCEDURE PASSED SUCCESSFULLY"