test-fib-matching: FIB matching test scenario
Change-Id: Ib309cad378cdfb89e7ddfc0e35d45a98c92ddfd3
refs: #1385
diff --git a/test_fib_matching/README.md b/test_fib_matching/README.md
new file mode 100644
index 0000000..58842a3
--- /dev/null
+++ b/test_fib_matching/README.md
@@ -0,0 +1,35 @@
+Test Case - fib-matching
+========================
+
+## Objective ##
+
+To test NFD's fib matching on a single host.
+
+## Description ##
+
+This test case will run the NFD, ndn-traffic and ndn-traffic-server to test NFD's fib matching. The following steps will be followed:
+
+1. Start NFD.
+2. Start ndn-traffic-server to serve ndn:/ with Content "Z", FreshnessPeriod=10ms. Do prefix registration using NFD FibMgmt.
+3. Start ndn-traffic-server to serve ndn:/A with Content "A", FreshnessPeriod=10ms. Do prefix registration using NFD FibMgmt.
+4. Start ndn-traffic-server to serve ndn:/A/B/C with Content "C", FreshnessPeriod=10ms. Do prefix registration using NFD FibMgmt.
+5. Start ndn-traffic-server to serve ndn:/D/E with Content "E", FreshnessPeriod=10ms. Do prefix registration using NFD FibMgmt.
+6. Invoke ndn-traffic to request ndn:/ MustBeFresh=yes. Fail if unanswered. Fail if Content is not "Z".
+7. Wait 100ms.
+8. Invoke ndn-traffic to request ndn:/F MustBeFresh=yes. Fail if unanswered. Fail if Content is not "Z".
+9. Wait 100ms.
+10. Invoke ndn-traffic to request ndn:/A MustBeFresh=yes. Fail if unanswered. Fail if Content is not "A".
+11. Wait 100ms.
+12. Invoke ndn-traffic to request ndn:/a MustBeFresh=yes. Fail if unanswered. Fail if Content is not "Z".
+13. Wait 100ms.
+14. Invoke ndn-traffic to request ndn:/A/B MustBeFresh=yes. Fail if unanswered. Fail if Content is not "A".
+15. Wait 100ms.
+16. Invoke ndn-traffic to request ndn:/A/B/G MustBeFresh=yes. Fail if unanswered. Fail if Content is not "A".
+17. Wait 100ms.
+18. Invoke ndn-traffic to request ndn:/A/B/C MustBeFresh=yes. Fail if unanswered. Fail if Content is not "C".
+19. Wait 100ms.
+20. Invoke ndn-traffic to request ndn:/A/B/C/P/Q/R/S/T/U/V/W/X/Y/Z MustBeFresh=yes. Fail if unanswered. Fail if Content is not "C".
+21. Wait 100ms.
+22. Invoke ndn-traffic to request ndn:/D MustBeFresh=yes Exclude=[,D]. Fail if unanswered. Fail if Content is not "Z".
+23. Wait 100ms.
+24. Invoke ndn-traffic to request ndn:/D MustBeFresh=yes Exclude=[,E]. Fail if unanswered. Fail if Content is not "Z".
diff --git a/test_fib_matching/__init__.py b/test_fib_matching/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test_fib_matching/__init__.py
diff --git a/test_fib_matching/test-traffic-client-1.conf b/test_fib_matching/test-traffic-client-1.conf
new file mode 100644
index 0000000..ef1884f
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-1.conf
@@ -0,0 +1,5 @@
+TrafficPercentage=100
+Name=ndn:/
+MustBeFresh=1
+MaxSuffixComponents=2
+ExpectedContent=Z
diff --git a/test_fib_matching/test-traffic-client-10.conf b/test_fib_matching/test-traffic-client-10.conf
new file mode 100644
index 0000000..3cc199f
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-10.conf
@@ -0,0 +1,5 @@
+TrafficPercentage=100
+Name=ndn:/D
+MustBeFresh=1
+ExcludeBefore=E
+ExpectedContent=Z
diff --git a/test_fib_matching/test-traffic-client-2.conf b/test_fib_matching/test-traffic-client-2.conf
new file mode 100644
index 0000000..7c4f22c
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-2.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/F
+MustBeFresh=1
+ExpectedContent=Z
diff --git a/test_fib_matching/test-traffic-client-3.conf b/test_fib_matching/test-traffic-client-3.conf
new file mode 100644
index 0000000..ebab4a5
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-3.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/A
+MustBeFresh=1
+ExpectedContent=A
diff --git a/test_fib_matching/test-traffic-client-4.conf b/test_fib_matching/test-traffic-client-4.conf
new file mode 100644
index 0000000..6329655
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-4.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/a
+MustBeFresh=1
+ExpectedContent=Z
diff --git a/test_fib_matching/test-traffic-client-5.conf b/test_fib_matching/test-traffic-client-5.conf
new file mode 100644
index 0000000..9ea75b2
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-5.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/A/B
+MustBeFresh=1
+ExpectedContent=A
diff --git a/test_fib_matching/test-traffic-client-6.conf b/test_fib_matching/test-traffic-client-6.conf
new file mode 100644
index 0000000..302ce02
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-6.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/A/B/G
+MustBeFresh=1
+ExpectedContent=A
diff --git a/test_fib_matching/test-traffic-client-7.conf b/test_fib_matching/test-traffic-client-7.conf
new file mode 100644
index 0000000..e3b3d84
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-7.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/A/B/C
+MustBeFresh=1
+ExpectedContent=C
diff --git a/test_fib_matching/test-traffic-client-8.conf b/test_fib_matching/test-traffic-client-8.conf
new file mode 100644
index 0000000..c37c7aa
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-8.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=ndn:/A/B/C/P/Q/R/S/T/U/V/W/X/Y/Z
+MustBeFresh=1
+ExpectedContent=C
diff --git a/test_fib_matching/test-traffic-client-9.conf b/test_fib_matching/test-traffic-client-9.conf
new file mode 100644
index 0000000..57fc450
--- /dev/null
+++ b/test_fib_matching/test-traffic-client-9.conf
@@ -0,0 +1,5 @@
+TrafficPercentage=100
+Name=ndn:/D
+MustBeFresh=1
+ExcludeBefore=D
+ExpectedContent=Z
diff --git a/test_fib_matching/test-traffic-server-1.conf b/test_fib_matching/test-traffic-server-1.conf
new file mode 100644
index 0000000..24b38d9
--- /dev/null
+++ b/test_fib_matching/test-traffic-server-1.conf
@@ -0,0 +1,3 @@
+Name=ndn:/
+FreshnessPeriod=10
+Content=Z
diff --git a/test_fib_matching/test-traffic-server-2.conf b/test_fib_matching/test-traffic-server-2.conf
new file mode 100644
index 0000000..6f31945
--- /dev/null
+++ b/test_fib_matching/test-traffic-server-2.conf
@@ -0,0 +1,3 @@
+Name=ndn:/A
+FreshnessPeriod=10
+Content=A
diff --git a/test_fib_matching/test-traffic-server-3.conf b/test_fib_matching/test-traffic-server-3.conf
new file mode 100644
index 0000000..59453ae
--- /dev/null
+++ b/test_fib_matching/test-traffic-server-3.conf
@@ -0,0 +1,3 @@
+Name=ndn:/A/B/C
+FreshnessPeriod=10
+Content=C
diff --git a/test_fib_matching/test-traffic-server-4.conf b/test_fib_matching/test-traffic-server-4.conf
new file mode 100644
index 0000000..ae2c299
--- /dev/null
+++ b/test_fib_matching/test-traffic-server-4.conf
@@ -0,0 +1,3 @@
+Name=ndn:/D/E
+FreshnessPeriod=10
+Content=E
diff --git a/test_fib_matching/test_fib_matching.py b/test_fib_matching/test_fib_matching.py
new file mode 100644
index 0000000..0570f64
--- /dev/null
+++ b/test_fib_matching/test_fib_matching.py
@@ -0,0 +1,240 @@
+#!/usr/bin/python2
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2014 University of Arizona
+# Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
+# See COPYING for copyright and distribution information.
+#
+
+import os
+import time
+import unittest
+import process_manager
+
+class test_fib_matching(unittest.TestCase, process_manager.ProcessManager):
+ """Test case for testing fib matching"""
+
+ def setUp(self):
+ print "\nTesting FIB Matching"
+ print "********************"
+
+ def tearDown(self):
+ self.killNfd()
+ try:
+ self.killProcess("ndn-traffic-server-1")
+ self.killProcess("ndn-traffic-server-2")
+ self.killProcess("ndn-traffic-server-3")
+ self.killProcess("ndn-traffic-server-4")
+ self.killProcess("ndn-traffic-client-1")
+ self.killProcess("ndn-traffic-client-2")
+ self.killProcess("ndn-traffic-client-3")
+ self.killProcess("ndn-traffic-client-4")
+ self.killProcess("ndn-traffic-client-5")
+ self.killProcess("ndn-traffic-client-6")
+ self.killProcess("ndn-traffic-client-7")
+ self.killProcess("ndn-traffic-client-8")
+ self.killProcess("ndn-traffic-client-9")
+ self.killProcess("ndn-traffic-client-10")
+ self.cleanupProcesses()
+ except IOError as e:
+ self.cleanupProcesses()
+ pass
+
+ def checkAndReportFailure(self, processKey, processName):
+ if self.hasProcessCompleted(processKey):
+ if self.getProcessReturnCode(processKey) != 0:
+ print self.getProcessOutput(processKey)
+ print self.getProcessError(processKey)
+ self.fail(">> TEST FAILED - received non-zero return code from " + processName)
+ else:
+ self.fail(">> TEST FAILED - " + processName + " failed to complete")
+
+ def test_matching(self):
+
+ #Start NFD
+ self.startNfd()
+ time.sleep(1)
+
+ #Start ndn-traffic-server to serve ndn:/ with Content "Z", FreshnessPeriod=10ms
+ #Prefix registration using NFD FibMgmt
+ serverConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-server-1.conf")
+ self.startProcess("ndn-traffic-server-1",
+ ["ndn-traffic-server", serverConfigurationFile],
+ "-> Starting Traffic Server 1 (Prefix=ndn:/, FreshnessPeriod=10ms, Data=Z)")
+ time.sleep(0.1)
+
+ #Start ndn-traffic-server to serve ndn:/A with Content "A", FreshnessPeriod=10ms
+ #Prefix registration using NFD FibMgmt
+ serverConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-server-2.conf")
+ self.startProcess("ndn-traffic-server-2",
+ ["ndn-traffic-server", serverConfigurationFile],
+ "-> Starting Traffic Server 2 (Prefix=ndn:/A, FreshnessPeriod=10ms, Data=A)")
+ time.sleep(0.1)
+
+ #Start ndn-traffic-server to serve ndn:/A/B/C with Content "C", FreshnessPeriod=10ms
+ #Prefix registration using NFD FibMgmt
+ serverConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-server-3.conf")
+ self.startProcess("ndn-traffic-server-3",
+ ["ndn-traffic-server", serverConfigurationFile],
+ "-> Starting Traffic Server 3 (Prefix=ndn:/A/B/C, FreshnessPeriod=10ms, Data=C)")
+ time.sleep(0.1)
+
+ #Start ndn-traffic-server to serve ndn:/D/E with Content "E", FreshnessPeriod=10ms
+ #Prefix registration using NFD FibMgmt
+ serverConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-server-4.conf")
+ self.startProcess("ndn-traffic-server-4",
+ ["ndn-traffic-server", serverConfigurationFile],
+ "-> Starting Traffic Server 4 (Prefix=ndn:/D/E, FreshnessPeriod=10ms, Data=E)")
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/ MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "Z".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-1.conf")
+ self.startProcess("ndn-traffic-client-1",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ ("-> Starting Traffic Client 1 (Prefix=ndn:/, MustBeFresh=Yes,"
+ " ExpectedContent=Z, MaxSuffixComponents=2)"))
+ self.waitForProcessCompletion("ndn-traffic-client-1", 10)
+ self.checkAndReportFailure("ndn-traffic-client-1", "Traffic Client 1")
+ print "-> Traffic Client 1 received data with Content=Z"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/F MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "Z".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-2.conf")
+ self.startProcess("ndn-traffic-client-2",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client 2 (Prefix=ndn:/F, MustBeFresh=Yes, ExpectedContent=Z)")
+ self.waitForProcessCompletion("ndn-traffic-client-2", 10)
+ self.checkAndReportFailure("ndn-traffic-client-2", "Traffic Client 2")
+ print "-> Traffic Client 2 received data with Content=Z"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/A MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "A".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-3.conf")
+ self.startProcess("ndn-traffic-client-3",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client 3 (Prefix=ndn:/A, MustBeFresh=Yes, ExpectedContent=A)")
+ self.waitForProcessCompletion("ndn-traffic-client-3", 10)
+ self.checkAndReportFailure("ndn-traffic-client-3", "Traffic Client 3")
+ print "-> Traffic Client 3 received data with Content=A"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/a MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "Z".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-4.conf")
+ self.startProcess("ndn-traffic-client-4",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client 4 (Prefix=ndn:/a, MustBeFresh=Yes, ExpectedContent=Z)")
+ self.waitForProcessCompletion("ndn-traffic-client-4", 10)
+ self.checkAndReportFailure("ndn-traffic-client-4", "Traffic Client 4")
+ print "-> Traffic Client 4 received data with Content=Z"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/A/B MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "A".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-5.conf")
+ self.startProcess("ndn-traffic-client-5",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client 5 (Prefix=ndn:/A/B, MustBeFresh=Yes, ExpectedContent=A)")
+ self.waitForProcessCompletion("ndn-traffic-client-5", 10)
+ self.checkAndReportFailure("ndn-traffic-client-5", "Traffic Client 5")
+ print "-> Traffic Client 5 received data with Content=A"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/A/B/G MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "A".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-6.conf")
+ self.startProcess("ndn-traffic-client-6",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client 6 (Prefix=ndn:/A/B/G, MustBeFresh=Yes, ExpectedContent=A)")
+ self.waitForProcessCompletion("ndn-traffic-client-6", 10)
+ self.checkAndReportFailure("ndn-traffic-client-6", "Traffic Client 6")
+ print "-> Traffic Client 6 received data with Content=A"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/A/B/C MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "C".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-7.conf")
+ self.startProcess("ndn-traffic-client-7",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client 7 (Prefix=ndn:/A/B/C, MustBeFresh=Yes, ExpectedContent=C)")
+ self.waitForProcessCompletion("ndn-traffic-client-7", 10)
+ self.checkAndReportFailure("ndn-traffic-client-7", "Traffic Client 7")
+ print "-> Traffic Client 7 received data with Content=C"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/A/B/C/P/Q/R/S/T/U/V/W/X/Y/Z MustBeFresh=yes
+ #Fail if unanswered. Fail if Content is not "C".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-8.conf")
+ self.startProcess("ndn-traffic-client-8",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ ("-> Starting Traffic Client 8 (Prefix=ndn:/A/B/C/P/Q/R/S/T/U/V/W/X/Y/Z,"
+ " MustBeFresh=Yes, ExpectedContent=C)"))
+ self.waitForProcessCompletion("ndn-traffic-client-8", 10)
+ self.checkAndReportFailure("ndn-traffic-client-8", "Traffic Client 8")
+ print "-> Traffic Client 8 received data with Content=C"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/D MustBeFresh=yes Exclude=[,D]
+ #Fail if unanswered. Fail if Content is not "Z".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-9.conf")
+ self.startProcess("ndn-traffic-client-9",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ ("-> Starting Traffic Client 9 (Prefix=ndn:/D, MustBeFresh=Yes,"
+ " ExcludeBefore=D, ExpectedContent=Z)"))
+ self.waitForProcessCompletion("ndn-traffic-client-9", 10)
+ self.checkAndReportFailure("ndn-traffic-client-9", "Traffic Client 9")
+ print "-> Traffic Client 9 received data with Content=Z"
+
+ #Wait 100ms
+ time.sleep(0.1)
+
+ #Invoke ndn-traffic to request ndn:/D MustBeFresh=yes Exclude=[,E].
+ #Fail if unanswered. Fail if Content is not "Z".
+ clientConfigurationFile = os.path.abspath(
+ "test_fib_matching/test-traffic-client-10.conf")
+ self.startProcess("ndn-traffic-client-10",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ ("-> Starting Traffic Client 10 (Prefix=ndn:/E, MustBeFresh=Yes,"
+ " ExcludeBefore=E, ExpectedContent=Z)"))
+ self.waitForProcessCompletion("ndn-traffic-client-10", 10)
+ self.checkAndReportFailure("ndn-traffic-client-10", "Traffic Client 10")
+ print "-> Traffic Client 10 received data with Content=Z"
+
+ #Stop all four traffic servers
+ self.killProcess("ndn-traffic-server-1")
+ self.killProcess("ndn-traffic-server-2")
+ self.killProcess("ndn-traffic-server-3")
+ self.killProcess("ndn-traffic-server-4")
+ print ">> TEST SUCCESSFUL"