jeraldabraham | 3a2466e | 2014-04-09 00:19:45 -0700 | [diff] [blame] | 1 | #!/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 | |
| 9 | import os |
| 10 | import time |
| 11 | import unittest |
| 12 | import process_manager |
| 13 | |
| 14 | class 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) |
jeraldabraham | 3a2466e | 2014-04-09 00:19:45 -0700 | [diff] [blame] | 30 | serverConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-server.conf") |
| 31 | self.startProcess("ndn-traffic-server", |
| 32 | ["ndn-traffic-server", "-c 1", serverConfigurationFile], |
| 33 | "-> Starting Traffic Server") |
| 34 | time.sleep(1) |
| 35 | clientConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-client.conf") |
| 36 | self.startProcess("ndn-traffic", |
| 37 | ["ndn-traffic", "-c 1", clientConfigurationFile], |
| 38 | "-> Starting Traffic Client") |
| 39 | time.sleep(1) |
| 40 | self.waitForProcessCompletion("ndn-traffic", 10) |
| 41 | self.waitForProcessCompletion("ndn-traffic-server", 10) |
| 42 | if self.hasProcessCompleted("ndn-traffic"): |
| 43 | if self.getProcessReturnCode("ndn-traffic") != 0: |
| 44 | print self.getProcessError("ndn-traffic") |
| 45 | self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic") |
| 46 | else: |
| 47 | self.fail(">> TEST FAILED - ndn-traffic failed to complete") |
| 48 | if self.hasProcessCompleted("ndn-traffic-server"): |
| 49 | if self.getProcessReturnCode("ndn-traffic-server") != 0: |
| 50 | print self.getProcessError("ndn-traffic-server") |
| 51 | self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic-server") |
| 52 | else: |
| 53 | self.fail(">> TEST FAILED - ndn-traffic-server failed to complete") |
| 54 | print ">> TEST SUCCESSFUL" |