diff options
Diffstat (limited to 'scripts/automation/regression/stateful_tests')
3 files changed, 84 insertions, 23 deletions
diff --git a/scripts/automation/regression/stateful_tests/trex_client_pkg_test.py b/scripts/automation/regression/stateful_tests/trex_client_pkg_test.py new file mode 100755 index 00000000..e2040e73 --- /dev/null +++ b/scripts/automation/regression/stateful_tests/trex_client_pkg_test.py @@ -0,0 +1,31 @@ +#!/router/bin/python +from trex_general_test import CTRexGeneral_Test, CTRexScenario +from misc_methods import run_command +from nose.plugins.attrib import attr + + +@attr('client_package') +class CTRexClientPKG_Test(CTRexGeneral_Test): + """This class tests TRex client package""" + + def setUp(self): + CTRexGeneral_Test.setUp(self) + self.unzip_client_package() + + def run_client_package_stf_example(self, python_version): + commands = [ + 'cd %s' % CTRexScenario.scripts_path, + 'source find_python.sh --%s' % python_version, + 'which $PYTHON', + 'cd trex_client/stf/examples', + '$PYTHON stf_example.py -s %s' % self.configuration.trex['trex_name'], + ] + return_code, _, stderr = run_command("bash -ce '%s'" % '; '.join(commands)) + if return_code: + self.fail('Error in running stf_example using %s: %s' % (python_version, stderr)) + + def test_client_python2(self): + self.run_client_package_stf_example(python_version = 'python2') + + def test_client_python3(self): + self.run_client_package_stf_example(python_version = 'python3') diff --git a/scripts/automation/regression/stateful_tests/trex_general_test.py b/scripts/automation/regression/stateful_tests/trex_general_test.py index 21f5d8aa..5a13e5ff 100755 --- a/scripts/automation/regression/stateful_tests/trex_general_test.py +++ b/scripts/automation/regression/stateful_tests/trex_general_test.py @@ -37,6 +37,7 @@ import threading from tests_exceptions import * from platform_cmd_link import * import unittest +from glob import glob def setUpModule(module): pass @@ -224,13 +225,21 @@ class CTRexGeneral_Test(unittest.TestCase): #trex_exp_gbps = trex_exp_rate/(10**9) if check_latency: - # check that max latency does not exceed 1 msec in regular setup or 100ms in VM - allowed_latency = 9999999 if self.is_VM else 1000 + # check that max latency does not exceed 1 msec + if self.configuration.trex['trex_name'] == '10.56.217.210': # temporary workaround for latency issue in kiwi02, remove it ASAP. http://trex-tgn.cisco.com/youtrack/issue/trex-194 + allowed_latency = 8000 + elif self.is_VM: + allowed_latency = 9999999 + else: # no excuses, check 1ms + allowed_latency = 1000 if max(trex_res.get_max_latency().values()) > allowed_latency: self.fail('LatencyError: Maximal latency exceeds %s (usec)' % allowed_latency) - # check that avg latency does not exceed 1 msec in regular setup or 3ms in VM - allowed_latency = 9999999 if self.is_VM else 1000 + # check that avg latency does not exceed 1 msec + if self.is_VM: + allowed_latency = 9999999 + else: # no excuses, check 1ms + allowed_latency = 1000 if max(trex_res.get_avg_latency().values()) > allowed_latency: self.fail('LatencyError: Average latency exceeds %s (usec)' % allowed_latency) @@ -253,6 +262,21 @@ class CTRexGeneral_Test(unittest.TestCase): # e.args += ('T-Rex has crashed!') # raise + def unzip_client_package(self): + client_pkg_files = glob('%s/trex_client*.tar.gz' % CTRexScenario.scripts_path) + if not len(client_pkg_files): + raise Exception('Could not find client package') + if len(client_pkg_files) > 1: + raise Exception('Found more than one client packages') + client_pkg_name = os.path.basename(client_pkg_files[0]) + if not os.path.exists('%s/trex_client' % CTRexScenario.scripts_path): + print('\nUnzipping package') + return_code, _, stderr = misc_methods.run_command("sh -ec 'cd %s; tar -xzf %s'" % (CTRexScenario.scripts_path, client_pkg_name)) + if return_code: + raise Exception('Could not untar the client package: %s' % stderr) + else: + print('\nClient package is untarred') + # We encountered error, don't fail the test immediately def fail(self, reason = 'Unknown error'): print 'Error: %s' % reason @@ -291,14 +315,12 @@ class CTRexGeneral_Test(unittest.TestCase): # def test_isInitialized(self): # assert CTRexScenario.is_init == True def tearDown(self): - if not self.trex: - return - if not self.trex.is_idle(): + if self.trex and not self.trex.is_idle(): print 'Warning: TRex is not idle at tearDown, trying to stop it.' self.trex.force_kill(confirm = False) if not self.skipping: # print server logs of test run - if CTRexScenario.server_logs: + if self.trex and CTRexScenario.server_logs: try: print termstyle.green('\n>>>>>>>>>>>>>>> Daemon log <<<<<<<<<<<<<<<') daemon_log = self.trex.get_trex_daemon_log() diff --git a/scripts/automation/regression/stateful_tests/trex_imix_test.py b/scripts/automation/regression/stateful_tests/trex_imix_test.py index 43dea900..c93480c3 100755 --- a/scripts/automation/regression/stateful_tests/trex_imix_test.py +++ b/scripts/automation/regression/stateful_tests/trex_imix_test.py @@ -4,6 +4,7 @@ from CPlatform import CStaticRouteConfig from tests_exceptions import * #import sys import time +from nose.tools import nottest class CTRexIMIX_Test(CTRexGeneral_Test): """This class defines the IMIX testcase of the T-Rex traffic generator""" @@ -50,20 +51,18 @@ class CTRexIMIX_Test(CTRexGeneral_Test): # the name intentionally not matches nose default pattern, including the test should be specified explicitly def dummy(self): - self.assertEqual(1, 2, 'boo') - self.assertEqual(2, 2, 'boo') - self.assertEqual(2, 3, 'boo') - #print '' - #print dir(self) - #print locals() - #print '' - #print_r(unittest.TestCase) - #print '' - #print_r(self) - print '' - #print unittest.TestCase.shortDescription(self) - #self.skip("I'm just a dummy test") + ret = self.trex.start_trex( + c = 1, + m = 1, + p = True, + nc = True, + d = 5, + f = 'cap2/imix_fast_1g.yaml', + l = 1000, + trex_development = True) + trex_res = self.trex.sample_to_run_finish() + print trex_res def test_routing_imix (self): # test initializtion @@ -166,7 +165,7 @@ class CTRexIMIX_Test(CTRexGeneral_Test): self.check_CPU_benchmark(trex_res) - def test_jumbo(self): + def test_jumbo(self, duration = 100): if not self.is_loopback: self.router.configure_basic_interfaces(mtu = 9216) self.router.config_pbr(mode = "config") @@ -179,7 +178,7 @@ class CTRexIMIX_Test(CTRexGeneral_Test): m = mult, p = True, nc = True, - d = 100, + d = duration, f = 'cap2/imix_9k.yaml', l = 1000) @@ -193,6 +192,15 @@ class CTRexIMIX_Test(CTRexGeneral_Test): self.check_general_scenario_results(trex_res) self.check_CPU_benchmark(trex_res, minimal_cpu = 0, maximal_cpu = 10) + # don't include it to regular nose search + @nottest + def test_warm_up(self): + try: + self._testMethodName = 'test_jumbo' + self.test_jumbo(duration = 30) + except Exception as e: + print('Ignoring this error: %s' % e) + def tearDown(self): CTRexGeneral_Test.tearDown(self) # remove nbar config here |