test-ndntraffic: test case for testing ndn-traffic-generator
Change-Id: I117f38a206f0ae2a9d1d994f17884ae22e2c2f12
refs: #1387
diff --git a/test_ndntraffic/README.md b/test_ndntraffic/README.md
new file mode 100644
index 0000000..7f95d2e
--- /dev/null
+++ b/test_ndntraffic/README.md
@@ -0,0 +1,12 @@
+Test Case - ndntraffic
+======================
+
+## Objective ##
+
+To test the ndn-traffic-generator application on a single host.
+
+## Description ##
+
+This test case will run the NFD, ndn-traffic and ndn-traffic-server binaries.
+This will report SUCCESS if one interest/data is successfully exchanged without any data inconsistency between the ndn-traffic and ndn-traffic-server.
+In all other scenarios, the test case will report FAILURE
diff --git a/test_ndntraffic/__init__.py b/test_ndntraffic/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test_ndntraffic/__init__.py
diff --git a/test_ndntraffic/test-traffic-client.conf b/test_ndntraffic/test-traffic-client.conf
new file mode 100644
index 0000000..9c7ff0e
--- /dev/null
+++ b/test_ndntraffic/test-traffic-client.conf
@@ -0,0 +1,4 @@
+TrafficPercentage=100
+Name=/test/ndntraffic
+ExpectedContent=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+MustBeFresh=1
diff --git a/test_ndntraffic/test-traffic-server.conf b/test_ndntraffic/test-traffic-server.conf
new file mode 100644
index 0000000..0cfff54
--- /dev/null
+++ b/test_ndntraffic/test-traffic-server.conf
@@ -0,0 +1,2 @@
+Name=/test/ndntraffic
+Content=ABCDEFGHIJKLMNOPQRSTUVWXYZ
diff --git a/test_ndntraffic/test_ndntraffic.py b/test_ndntraffic/test_ndntraffic.py
new file mode 100644
index 0000000..632c4fe
--- /dev/null
+++ b/test_ndntraffic/test_ndntraffic.py
@@ -0,0 +1,54 @@
+#!/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_ndntraffic(unittest.TestCase, process_manager.ProcessManager):
+ """Test case for testing ndn-traffic-generator application"""
+
+ def setUp(self):
+ print "\nTesting ndn-traffic-generator"
+ print "*****************************"
+
+ def tearDown(self):
+ self.killNfd()
+ self.killProcess("ndn-traffic-server")
+ self.killProcess("ndn-traffic")
+ self.cleanupProcesses()
+
+ def test_traffic(self):
+ self.startNfd()
+ time.sleep(1)
+ serverConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-server.conf")
+ self.startProcess("ndn-traffic-server",
+ ["ndn-traffic-server", "-c 1", serverConfigurationFile],
+ "-> Starting Traffic Server")
+ time.sleep(1)
+ clientConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-client.conf")
+ self.startProcess("ndn-traffic",
+ ["ndn-traffic", "-c 1", clientConfigurationFile],
+ "-> Starting Traffic Client")
+ time.sleep(1)
+ self.waitForProcessCompletion("ndn-traffic", 10)
+ self.waitForProcessCompletion("ndn-traffic-server", 10)
+ if self.hasProcessCompleted("ndn-traffic"):
+ if self.getProcessReturnCode("ndn-traffic") != 0:
+ print self.getProcessError("ndn-traffic")
+ self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic")
+ else:
+ self.fail(">> TEST FAILED - ndn-traffic failed to complete")
+ if self.hasProcessCompleted("ndn-traffic-server"):
+ if self.getProcessReturnCode("ndn-traffic-server") != 0:
+ print self.getProcessError("ndn-traffic-server")
+ self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic-server")
+ else:
+ self.fail(">> TEST FAILED - ndn-traffic-server failed to complete")
+ print ">> TEST SUCCESSFUL"