summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-04-03 15:30:06 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-04-03 15:30:06 +0300
commit82a3c6f217e2bf96d0e9a83239a23b1d950d9011 (patch)
tree14ca983d3c92cf6dcb895e5b926aacd83e59329a /scripts
parent855889efb90a297f8be4e80e4e748983118bd096 (diff)
regression: add testing of TRex client package
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/automation/regression/stateful_tests/trex_client_pkg_test.py31
-rwxr-xr-xscripts/automation/regression/stateful_tests/trex_general_test.py22
-rwxr-xr-xscripts/automation/regression/stateless_tests/trex_client_pkg_test.py31
-rwxr-xr-xscripts/automation/regression/trex_unit_test.py11
4 files changed, 91 insertions, 4 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..0b53ea08
--- /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("timeout 60 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 cddc02dd..366f7d83 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
@@ -261,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 = 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
@@ -299,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/stateless_tests/trex_client_pkg_test.py b/scripts/automation/regression/stateless_tests/trex_client_pkg_test.py
new file mode 100755
index 00000000..779544e3
--- /dev/null
+++ b/scripts/automation/regression/stateless_tests/trex_client_pkg_test.py
@@ -0,0 +1,31 @@
+#!/router/bin/python
+from stl_general_test import CStlGeneral_Test, CTRexScenario
+from misc_methods import run_command
+from nose.plugins.attrib import attr
+
+
+@attr('client_package')
+class CTRexClientPKG_Test(CStlGeneral_Test):
+ """This class tests TRex client package"""
+
+ def setUp(self):
+ CStlGeneral_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/stl/examples',
+ '$PYTHON stl_imix.py -s %s' % self.configuration.trex['trex_name'],
+ ]
+ return_code, _, stderr = run_command("timeout 60 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/trex_unit_test.py b/scripts/automation/regression/trex_unit_test.py
index 1db7d28f..2be3c051 100755
--- a/scripts/automation/regression/trex_unit_test.py
+++ b/scripts/automation/regression/trex_unit_test.py
@@ -147,6 +147,9 @@ class CTRexTestConfiguringPlugin(Plugin):
parser.add_option('--warmup', action="store_true", default = False,
dest="warmup",
help="Warm up the system for stateful: run 30 seconds 9k imix test without check of results.")
+ parser.add_option('--test-client-package', '--test_client_package', action="store_true", default = False,
+ dest="test_client_package",
+ help="Includes tests of client package.")
def configure(self, options, conf):
self.collect_only = options.collect_only
@@ -278,6 +281,10 @@ if __name__ == "__main__":
nose_argv = ['', '-s', '-v', '--exe', '--rednose', '--detailed-errors']
+ test_client_package = False
+ if '--test-client-package' in sys.argv:
+ test_client_package = True
+
if '--collect' in sys.argv:
sys.argv.append('--collect-only')
if '--collect-only' in sys.argv: # this is a user trying simply to view the available tests. no need xunit.
@@ -336,11 +343,15 @@ if __name__ == "__main__":
if '--warmup' in sys.argv:
additional_args.append('stateful_tests/trex_imix_test.py:CTRexIMIX_Test.test_warm_up')
additional_args += CTRexScenario.test_types['stateful_tests']
+ if not test_client_package:
+ additional_args.extend(['-a', '!client_package'])
if xml_arg:
additional_args += ['--with-xunit', xml_arg.replace('.xml', '_stateful.xml')]
result = nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin]) and result
if len(CTRexScenario.test_types['stateless_tests']):
additional_args = ['--stl', 'stateless_tests/stl_general_test.py:STLBasic_Test.test_connectivity'] + CTRexScenario.test_types['stateless_tests']
+ if not test_client_package:
+ additional_args.extend(['-a', '!client_package'])
if xml_arg:
additional_args += ['--with-xunit', xml_arg.replace('.xml', '_stateless.xml')]
result = nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin]) and result