blob: a83e4500cfc14c35fd8f5693e0e696a09e5269fe [file] [log] [blame]
jeraldabraham3a2466e2014-04-09 00:19:45 -07001#!/usr/bin/python2
2# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
3#
4# Copyright (C) 2014 University of Arizona
5# Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
6# See COPYING for copyright and distribution information.
7#
8
9import os
10import time
11import unittest
12import process_manager
13
14class test_ndntraffic(unittest.TestCase, process_manager.ProcessManager):
15 """Test case for testing ndn-traffic-generator application"""
16
17 def setUp(self):
18 print "\nTesting ndn-traffic-generator"
19 print "*****************************"
20
21 def tearDown(self):
22 self.killNfd()
23 self.killProcess("ndn-traffic-server")
24 self.killProcess("ndn-traffic")
25 self.cleanupProcesses()
26
27 def test_traffic(self):
28 self.startNfd()
29 time.sleep(1)
Yi Huang53fa8712014-06-10 20:14:26 -070030 self.startNrd()
31 time.sleep(1)
jeraldabraham3a2466e2014-04-09 00:19:45 -070032 serverConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-server.conf")
33 self.startProcess("ndn-traffic-server",
34 ["ndn-traffic-server", "-c 1", serverConfigurationFile],
35 "-> Starting Traffic Server")
36 time.sleep(1)
37 clientConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-client.conf")
38 self.startProcess("ndn-traffic",
39 ["ndn-traffic", "-c 1", clientConfigurationFile],
40 "-> Starting Traffic Client")
41 time.sleep(1)
42 self.waitForProcessCompletion("ndn-traffic", 10)
43 self.waitForProcessCompletion("ndn-traffic-server", 10)
44 if self.hasProcessCompleted("ndn-traffic"):
45 if self.getProcessReturnCode("ndn-traffic") != 0:
46 print self.getProcessError("ndn-traffic")
47 self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic")
48 else:
49 self.fail(">> TEST FAILED - ndn-traffic failed to complete")
50 if self.hasProcessCompleted("ndn-traffic-server"):
51 if self.getProcessReturnCode("ndn-traffic-server") != 0:
52 print self.getProcessError("ndn-traffic-server")
53 self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic-server")
54 else:
55 self.fail(">> TEST FAILED - ndn-traffic-server failed to complete")
56 print ">> TEST SUCCESSFUL"