summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/regression')
-rw-r--r--scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py3
-rwxr-xr-xscripts/automation/regression/misc_methods.py8
-rwxr-xr-xscripts/automation/regression/outer_packages.py4
-rw-r--r--scripts/automation/regression/setups/trex09/config.yaml31
-rw-r--r--scripts/automation/regression/setups/trex14/benchmark.yaml26
-rwxr-xr-xscripts/automation/regression/stateful_tests/trex_client_pkg_test.py31
-rwxr-xr-xscripts/automation/regression/stateful_tests/trex_general_test.py38
-rwxr-xr-xscripts/automation/regression/stateful_tests/trex_imix_test.py38
-rw-r--r--scripts/automation/regression/stateless_tests/stl_client_test.py294
-rw-r--r--scripts/automation/regression/stateless_tests/stl_rx_test.py32
-rwxr-xr-xscripts/automation/regression/stateless_tests/trex_client_pkg_test.py31
-rwxr-xr-xscripts/automation/regression/trex_unit_test.py61
12 files changed, 501 insertions, 96 deletions
diff --git a/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py b/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py
index a3fcd091..5d34e5df 100644
--- a/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py
+++ b/scripts/automation/regression/functional_tests/scapy_pkt_builder_test.py
@@ -238,7 +238,8 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
d= pkt_builder.get_vm_data()
except CTRexPacketBuildException as e:
- assert_equal(str(e), "[errcode:-11] 'variable my_valn_err does not exists '")
+ error=str(e)
+ assert_equal(error.find("[errcode:-11]"),0);
def test_simple_tuple_gen(self):
vm = STLScVmRaw( [ STLVmTupleGen(name="tuple"), # define tuple gen
diff --git a/scripts/automation/regression/misc_methods.py b/scripts/automation/regression/misc_methods.py
index 54e3ba5d..6873622e 100755
--- a/scripts/automation/regression/misc_methods.py
+++ b/scripts/automation/regression/misc_methods.py
@@ -25,12 +25,12 @@ def mix_string (str):
# executes given command, returns tuple (return_code, stdout, stderr)
def run_command(cmd, background = False):
if background:
- print('Running command in background:', cmd)
+ print('Running command in background: %s' % cmd)
with open(os.devnull, 'w') as tempf:
subprocess.Popen(shlex.split(cmd), stdin=tempf, stdout=tempf, stderr=tempf)
return (None,)*3
else:
- print('Running command:', cmd)
+ print('Running command: %s' % cmd)
proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
if stdout:
@@ -42,8 +42,8 @@ def run_command(cmd, background = False):
return (proc.returncode, stdout, stderr)
-def run_remote_command(host, command_string, background = False):
- cmd = 'ssh -tt %s \'sudo sh -ec "%s"\'' % (host, command_string)
+def run_remote_command(host, command_string, background = False, timeout = 20):
+ cmd = 'ssh -tt %s \'sudo%s sh -ec "%s"\'' % (host, (' timeout %s' % timeout) if (timeout and not background) else '', command_string)
return run_command(cmd, background)
diff --git a/scripts/automation/regression/outer_packages.py b/scripts/automation/regression/outer_packages.py
index bec9fe21..61ddc5cd 100755
--- a/scripts/automation/regression/outer_packages.py
+++ b/scripts/automation/regression/outer_packages.py
@@ -9,6 +9,7 @@ if not TREX_PATH or not os.path.isfile('%s/trex_daemon_server' % TREX_PATH):
TREX_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir, os.pardir))
PATH_TO_PYTHON_LIB = os.path.abspath(os.path.join(TREX_PATH, 'external_libs'))
PATH_TO_CTRL_PLANE = os.path.abspath(os.path.join(TREX_PATH, 'automation', 'trex_control_plane'))
+PATH_STF_API = os.path.abspath(os.path.join(PATH_TO_CTRL_PLANE, 'stf'))
PATH_STL_API = os.path.abspath(os.path.join(PATH_TO_CTRL_PLANE, 'stl'))
@@ -57,8 +58,9 @@ def import_module_list(modules_list):
def import_nightly_modules ():
sys.path.append(TREX_PATH)
- sys.path.append(PATH_TO_CTRL_PLANE)
+ #sys.path.append(PATH_TO_CTRL_PLANE)
sys.path.append(PATH_STL_API)
+ sys.path.append(PATH_STF_API)
import_module_list(NIGHTLY_MODULES)
diff --git a/scripts/automation/regression/setups/trex09/config.yaml b/scripts/automation/regression/setups/trex09/config.yaml
index 9820ce6e..585ca17a 100644
--- a/scripts/automation/regression/setups/trex09/config.yaml
+++ b/scripts/automation/regression/setups/trex09/config.yaml
@@ -35,33 +35,4 @@
trex:
hostname : csi-trex-09
cores : 2
-
-router:
- model : 1RU
- hostname : ASR1001_T-Rex
- ip_address : 10.56.199.247
- image : asr1001-universalk9.BLD_V155_1_S_XE314_THROTTLE_LATEST_20141112_090734-std.bin
- #image : asr1001-universalk9.BLD_V155_2_S_XE315_THROTTLE_LATEST_20150121_110036-std.bin
- #image : asr1001-universalk9.BLD_V155_2_S_XE315_THROTTLE_LATEST_20150324_100047-std.bin
- line_password : lab
- en_password : lab
- mgmt_interface : GigabitEthernet0/0/0
- clean_config : /Configurations/danklei/asr1001_TRex_clean_config.cfg
- intf_masking : 255.255.255.0
- ipv6_mask : 64
- interfaces :
- - client :
- name : GigabitEthernet0/0/1
- src_mac_addr : 0000.0001.0000
- dest_mac_addr : 0000.0001.0000
- server :
- name : GigabitEthernet0/0/2
- src_mac_addr : 0000.0001.0000
- dest_mac_addr : 0000.0001.0000
- vrf_name : null
-
-tftp:
- hostname : ats-asr-srv-1
- ip_address : 10.56.128.23
- root_dir : /auto/avc-devtest/
- images_path : /images/1RU/
+ modes : ['loopback']
diff --git a/scripts/automation/regression/setups/trex14/benchmark.yaml b/scripts/automation/regression/setups/trex14/benchmark.yaml
index 28e287bf..e602ad1a 100644
--- a/scripts/automation/regression/setups/trex14/benchmark.yaml
+++ b/scripts/automation/regression/setups/trex14/benchmark.yaml
@@ -12,18 +12,20 @@ test_nbar_simple :
exp_max_latency : 1000
nbar_classification:
- rtp : 35.24
- http : 30.41
- oracle_sqlnet : 11.3
- ssl : 6.03
+ http : 32.58
+ rtp-audio : 21.21
+ oracle_sqlnet : 11.41
+ exchange : 11.22
+ rtp : 11.2
citrix : 5.65
- exchange : 4.99
+ rtsp : 2.87
dns : 1.96
smtp : 0.57
pop3 : 0.37
+ ssl : 0.28
sctp : 0.13
sip : 0.09
- unknown : 3.22
+ unknown : 0.45
test_rx_check :
multiplier : 13
@@ -109,15 +111,15 @@ test_static_routing_imix_asymmetric:
exp_latency : 1
test_ipv6_simple :
- multiplier : 18
- cores : 4
+ multiplier : 9
+ cores : 2
cpu_to_core_ratio : 30070000
cpu2core_custom_dev: YES
cpu2core_dev : 0.07
test_rx_check_sfr:
- multiplier : 15
+ multiplier : 10
cores : 3
rx_sample_rate : 16
# allow 0.03% errors, bad router
@@ -127,11 +129,11 @@ test_rx_check_http:
multiplier : 15000
cores : 1
rx_sample_rate : 16
- # allow 0.03% errors, bad router
+ # allow 0.03% errors, bad routerifconfig
error_tolerance : 0.03
test_rx_check_sfr_ipv6:
- multiplier : 15
+ multiplier : 10
cores : 3
rx_sample_rate : 16
# allow 0.03% errors, bad router
@@ -165,5 +167,5 @@ test_rx_check_http_negative:
test_jumbo:
- multiplier : 28
+ multiplier : 17
cores : 1
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
diff --git a/scripts/automation/regression/stateless_tests/stl_client_test.py b/scripts/automation/regression/stateless_tests/stl_client_test.py
new file mode 100644
index 00000000..01a90250
--- /dev/null
+++ b/scripts/automation/regression/stateless_tests/stl_client_test.py
@@ -0,0 +1,294 @@
+#!/router/bin/python
+from stl_general_test import CStlGeneral_Test, CTRexScenario
+from trex_stl_lib.api import *
+import os, sys
+import glob
+
+
+def get_error_in_percentage (golden, value):
+ return abs(golden - value) / float(golden)
+
+def get_stl_profiles ():
+ profiles_path = os.path.join(CTRexScenario.scripts_path, 'stl/')
+ profiles = glob.glob(profiles_path + "/*.py") + glob.glob(profiles_path + "yaml/*.yaml")
+
+ return profiles
+
+
+class STLClient_Test(CStlGeneral_Test):
+ """Tests for stateless client"""
+
+ def setUp(self):
+ CStlGeneral_Test.setUp(self)
+
+ if self.is_virt_nics:
+ self.percentage = 5
+ self.pps = 500
+ else:
+ self.percentage = 50
+ self.pps = 50000
+
+ # strict mode is only for 'wire only' connection
+ self.strict = True if self.is_loopback and not self.is_virt_nics else False
+
+ assert 'bi' in CTRexScenario.stl_ports_map
+
+ self.c = CTRexScenario.stl_trex
+
+ self.tx_port, self.rx_port = CTRexScenario.stl_ports_map['bi'][0]
+
+ self.c.connect()
+ self.c.reset(ports = [self.tx_port, self.rx_port])
+
+ self.pkt = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()/'a_payload_example')
+ self.profiles = get_stl_profiles()
+
+
+ @classmethod
+ def tearDownClass(cls):
+ # connect back at end of tests
+ if not cls.is_connected():
+ CTRexScenario.stl_trex.connect()
+
+
+ def verify (self, expected, got):
+ if self.strict:
+ assert expected == got
+ else:
+ assert get_error_in_percentage(expected, got) < 0.05
+
+
+ def test_basic_connect_disconnect (self):
+ try:
+ self.c.connect()
+ assert self.c.is_connected(), 'client should be connected'
+ self.c.disconnect()
+ assert not self.c.is_connected(), 'client should be disconnected'
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+ def test_basic_single_burst (self):
+
+ try:
+ b1 = STLStream(name = 'burst',
+ packet = self.pkt,
+ mode = STLTXSingleBurst(total_pkts = 100,
+ percentage = self.percentage)
+ )
+
+ for i in range(0, 5):
+ self.c.add_streams([b1], ports = [self.tx_port, self.rx_port])
+
+ self.c.clear_stats()
+ self.c.start(ports = [self.tx_port, self.rx_port])
+
+ assert self.c.ports[self.tx_port].is_transmitting(), 'port should be active'
+ assert self.c.ports[self.rx_port].is_transmitting(), 'port should be active'
+
+ self.c.wait_on_traffic(ports = [self.tx_port, self.rx_port])
+ stats = self.c.get_stats()
+
+ assert self.tx_port in stats
+ assert self.rx_port in stats
+
+ self.verify(100, stats[self.tx_port]['opackets'])
+ self.verify(100, stats[self.rx_port]['ipackets'])
+
+ self.verify(100, stats[self.rx_port]['opackets'])
+ self.verify(100, stats[self.tx_port]['ipackets'])
+
+
+ self.c.remove_all_streams(ports = [self.tx_port, self.rx_port])
+
+
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+ #
+ def test_basic_multi_burst (self):
+ try:
+ b1 = STLStream(name = 'burst',
+ packet = self.pkt,
+ mode = STLTXMultiBurst(pkts_per_burst = 10,
+ count = 20,
+ percentage = self.percentage)
+ )
+
+ for i in range(0, 5):
+ self.c.add_streams([b1], ports = [self.tx_port, self.rx_port])
+
+ self.c.clear_stats()
+ self.c.start(ports = [self.tx_port, self.rx_port])
+
+ assert self.c.ports[self.tx_port].is_transmitting(), 'port should be active'
+ assert self.c.ports[self.rx_port].is_transmitting(), 'port should be active'
+
+ self.c.wait_on_traffic(ports = [self.tx_port, self.rx_port])
+ stats = self.c.get_stats()
+
+ assert self.tx_port in stats
+ assert self.rx_port in stats
+
+ self.verify(200, stats[self.tx_port]['opackets'])
+ self.verify(200, stats[self.rx_port]['ipackets'])
+
+ self.verify(200, stats[self.rx_port]['opackets'])
+ self.verify(200, stats[self.tx_port]['ipackets'])
+
+ self.c.remove_all_streams(ports = [self.tx_port, self.rx_port])
+
+
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+ #
+ def test_basic_cont (self):
+ pps = self.pps
+ duration = 0.1
+ golden = pps * duration
+
+ try:
+ b1 = STLStream(name = 'burst',
+ packet = self.pkt,
+ mode = STLTXCont(pps = pps)
+ )
+
+ for i in range(0, 5):
+ self.c.add_streams([b1], ports = [self.tx_port, self.rx_port])
+
+ self.c.clear_stats()
+ self.c.start(ports = [self.tx_port, self.rx_port], duration = duration)
+
+ assert self.c.ports[self.tx_port].is_transmitting(), 'port should be active'
+ assert self.c.ports[self.rx_port].is_transmitting(), 'port should be active'
+
+ self.c.wait_on_traffic(ports = [self.tx_port, self.rx_port])
+ stats = self.c.get_stats()
+
+ assert self.tx_port in stats
+ assert self.rx_port in stats
+
+ # cont. with duration should be quite percise - 5% error is relaxed enough
+
+ assert get_error_in_percentage(stats[self.tx_port]['opackets'], golden) < 0.05
+ assert get_error_in_percentage(stats[self.rx_port]['ipackets'], golden) < 0.05
+
+ assert get_error_in_percentage(stats[self.rx_port]['opackets'], golden) < 0.05
+ assert get_error_in_percentage(stats[self.tx_port]['ipackets'], golden) < 0.05
+
+
+ self.c.remove_all_streams(ports = [self.tx_port, self.rx_port])
+
+
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+ def test_stress_connect_disconnect (self):
+ try:
+ for i in range(0, 100):
+ self.c.connect()
+ assert self.c.is_connected(), 'client should be connected'
+ self.c.disconnect()
+ assert not self.c.is_connected(), 'client should be disconnected'
+
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+
+ def test_stress_tx (self):
+ try:
+ s1 = STLStream(name = 'stress',
+ packet = self.pkt,
+ mode = STLTXCont(percentage = self.percentage))
+
+ # add both streams to ports
+ self.c.add_streams([s1], ports = [self.tx_port, self.rx_port])
+ for i in range(0, 100):
+
+ self.c.start(ports = [self.tx_port, self.rx_port])
+
+ assert self.c.ports[self.tx_port].is_transmitting(), 'port should be active'
+ assert self.c.ports[self.rx_port].is_transmitting(), 'port should be active'
+
+ self.c.pause(ports = [self.tx_port, self.rx_port])
+
+ assert self.c.ports[self.tx_port].is_paused(), 'port should be paused'
+ assert self.c.ports[self.rx_port].is_paused(), 'port should be paused'
+
+ self.c.resume(ports = [self.tx_port, self.rx_port])
+
+ assert self.c.ports[self.tx_port].is_transmitting(), 'port should be active'
+ assert self.c.ports[self.rx_port].is_transmitting(), 'port should be active'
+
+ self.c.stop(ports = [self.tx_port, self.rx_port])
+
+ assert not self.c.ports[self.tx_port].is_active(), 'port should be idle'
+ assert not self.c.ports[self.rx_port].is_active(), 'port should be idle'
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+ def test_all_profiles (self):
+ # need promiscious for this one...
+ if self.is_virt_nics or not self.is_loopback:
+ self.skip('skipping profile tests for virtual NICs')
+ return
+
+ try:
+ self.c.set_port_attr(ports = [self.tx_port, self.rx_port], promiscuous = True)
+
+ for profile in self.profiles:
+ print("now testing profile {0}...\n").format(profile)
+
+ p1 = STLProfile.load(profile, port_id = self.tx_port)
+ p2 = STLProfile.load(profile, port_id = self.rx_port)
+
+ if p1.has_flow_stats():
+ print("profile needs RX caps - skipping...")
+ continue
+
+ self.c.add_streams(p1, ports = self.tx_port)
+ self.c.add_streams(p2, ports = self.rx_port)
+
+ self.c.clear_stats()
+
+ self.c.start(ports = [self.tx_port, self.rx_port], mult = "30%")
+ time.sleep(100 / 1000.0)
+
+ if p1.is_pauseable() and p2.is_pauseable():
+ self.c.pause(ports = [self.tx_port, self.rx_port])
+ time.sleep(100 / 1000.0)
+
+ self.c.resume(ports = [self.tx_port, self.rx_port])
+ time.sleep(100 / 1000.0)
+
+ self.c.stop(ports = [self.tx_port, self.rx_port])
+
+ stats = self.c.get_stats()
+
+ assert self.tx_port in stats, '{0} - no stats for TX port'.format(profile)
+ assert self.rx_port in stats, '{0} - no stats for RX port'.format(profile)
+
+ assert stats[self.tx_port]['opackets'] == stats[self.rx_port]['ipackets'], '{0} - number of TX packets differ from RX packets'.format(profile)
+
+ assert stats[self.rx_port]['opackets'] == stats[self.tx_port]['ipackets'], '{0} - number of TX packets differ from RX packets'.format(profile)
+
+ self.c.remove_all_streams(ports = [self.tx_port, self.rx_port])
+
+ except STLError as e:
+ assert False , '{0}'.format(e)
+
+
+ finally:
+ self.c.set_port_attr(ports = [self.tx_port, self.rx_port], promiscuous = False)
diff --git a/scripts/automation/regression/stateless_tests/stl_rx_test.py b/scripts/automation/regression/stateless_tests/stl_rx_test.py
index 90082c59..bb682b6c 100644
--- a/scripts/automation/regression/stateless_tests/stl_rx_test.py
+++ b/scripts/automation/regression/stateless_tests/stl_rx_test.py
@@ -7,6 +7,9 @@ class STLRX_Test(CStlGeneral_Test):
"""Tests for RX feature"""
def setUp(self):
+ per_driver_params = {"rte_vmxnet3_pmd": [1, 50], "rte_ixgbe_pmd": [30, 5000], "rte_i40e_pmd": [80, 5000],
+ "rte_igb_pmd": [80, 500], "rte_em_pmd": [1, 50], "rte_virtio_pmd": [1, 50]}
+
CStlGeneral_Test.setUp(self)
assert 'bi' in CTRexScenario.stl_ports_map
@@ -14,11 +17,13 @@ class STLRX_Test(CStlGeneral_Test):
self.tx_port, self.rx_port = CTRexScenario.stl_ports_map['bi'][0]
- cap = self.c.get_port_info(ports = self.rx_port)[0]['rx']['caps']
+ port_info = self.c.get_port_info(ports = self.rx_port)[0]
+ cap = port_info['rx']['caps']
if cap != 1:
self.skip('port {0} does not support RX'.format(self.rx_port))
-
+ self.rate_percent = per_driver_params[port_info['driver']][0]
+ self.total_pkts = per_driver_params[port_info['driver']][1]
self.c.reset(ports = [self.tx_port, self.rx_port])
self.pkt = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()/'a_payload_example')
@@ -68,14 +73,14 @@ class STLRX_Test(CStlGeneral_Test):
# one simple stream on TX --> RX
def test_one_stream(self):
- total_pkts = 500000
+ total_pkts = self.total_pkts * 10
try:
s1 = STLStream(name = 'rx',
packet = self.pkt,
flow_stats = STLFlowStats(pg_id = 5),
mode = STLTXSingleBurst(total_pkts = total_pkts,
- percentage = 80
+ percentage = self.rate_percent
))
# add both streams to ports
@@ -94,21 +99,26 @@ class STLRX_Test(CStlGeneral_Test):
# one simple stream on TX --> RX
def test_multiple_streams(self):
- total_pkts = 500000
+ num_streams = 10
+ total_pkts = self.total_pkts / num_streams
+ if total_pkts == 0:
+ total_pkts = 1
+ percent = self.rate_percent / num_streams
+ if percent == 0:
+ percent = 1
try:
streams = []
exp = []
# 10 identical streams
- for pg_id in range(1, 10):
+ for pg_id in range(1, num_streams):
streams.append(STLStream(name = 'rx {0}'.format(pg_id),
packet = self.pkt,
flow_stats = STLFlowStats(pg_id = pg_id),
- mode = STLTXSingleBurst(total_pkts = total_pkts * pg_id,
- pps = total_pkts * pg_id)))
+ mode = STLTXSingleBurst(total_pkts = total_pkts+pg_id, percentage = percent)))
- exp.append({'pg_id': pg_id, 'total_pkts': total_pkts * pg_id, 'pkt_len': self.pkt.get_pkt_len()})
+ exp.append({'pg_id': pg_id, 'total_pkts': total_pkts+pg_id, 'pkt_len': self.pkt.get_pkt_len()})
# add both streams to ports
self.c.add_streams(streams, ports = [self.tx_port])
@@ -120,14 +130,14 @@ class STLRX_Test(CStlGeneral_Test):
assert False , '{0}'.format(e)
def test_1_stream_many_iterations (self):
- total_pkts = 50000
+ total_pkts = self.total_pkts
try:
s1 = STLStream(name = 'rx',
packet = self.pkt,
flow_stats = STLFlowStats(pg_id = 5),
mode = STLTXSingleBurst(total_pkts = total_pkts,
- percentage = 80
+ percentage = self.rate_percent
))
# add both streams to ports
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..6e2de230
--- /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("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 fb666382..2be3c051 100755
--- a/scripts/automation/regression/trex_unit_test.py
+++ b/scripts/automation/regression/trex_unit_test.py
@@ -36,8 +36,8 @@ import misc_methods
from rednose import RedNose
import termstyle
from trex import CTRexScenario
-from stf.trex_client import *
-from stf.trex_exceptions import *
+from trex_stf_lib.trex_client import *
+from trex_stf_lib.trex_exceptions import *
from trex_stl_lib.api import *
import trex
import socket
@@ -67,10 +67,10 @@ STATEFUL_STOP_COMMAND = './trex_daemon_server stop; sleep 1; ./trex_daemon_serve
STATEFUL_RUN_COMMAND = 'rm /var/log/trex/trex_daemon_server.log; ./trex_daemon_server start; sleep 2; ./trex_daemon_server show'
TREX_FILES = ('_t-rex-64', '_t-rex-64-o', '_t-rex-64-debug', '_t-rex-64-debug-o')
-def trex_remote_command(trex_data, command, background = False, from_scripts = True):
+def trex_remote_command(trex_data, command, background = False, from_scripts = True, timeout = 20):
if from_scripts:
- return misc_methods.run_remote_command(trex_data['trex_name'], ('cd %s; ' % CTRexScenario.scripts_path)+ command, background)
- return misc_methods.run_remote_command(trex_data['trex_name'], command, background)
+ return misc_methods.run_remote_command(trex_data['trex_name'], ('cd %s; ' % CTRexScenario.scripts_path)+ command, background, timeout)
+ return misc_methods.run_remote_command(trex_data['trex_name'], command, background, timeout)
# 1 = running, 0 - not running
def check_trex_running(trex_data):
@@ -141,6 +141,15 @@ class CTRexTestConfiguringPlugin(Plugin):
parser.add_option('--no-ssh', '--no_ssh', action="store_true", default = False,
dest="no_ssh",
help="Flag to disable any ssh to server machine.")
+ parser.add_option('--collect', action="store_true", default = False,
+ dest="collect",
+ help="Alias to --collect-only.")
+ 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
@@ -183,7 +192,7 @@ class CTRexTestConfiguringPlugin(Plugin):
new_path = '/tmp/trex-scripts'
rsync_template = 'rm -rf /tmp/trex-scripts; mkdir -p %s; rsync -Lc %s /tmp; tar -mxzf /tmp/%s -C %s; mv %s/v*.*/* %s'
rsync_command = rsync_template % (new_path, self.pkg, os.path.basename(self.pkg), new_path, new_path, new_path)
- return_code, stdout, stderr = trex_remote_command(self.configuration.trex, rsync_command, from_scripts = False)
+ return_code, stdout, stderr = trex_remote_command(self.configuration.trex, rsync_command, from_scripts = False, timeout = 300)
if return_code:
print('Failed copying')
sys.exit(-1)
@@ -272,6 +281,12 @@ 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.
CTRexScenario.is_test_list = True
xml_arg = ''
@@ -324,23 +339,31 @@ if __name__ == "__main__":
additional_args += ['--with-xunit', xml_arg.replace('.xml', '_functional.xml')]
result = nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin])
if len(CTRexScenario.test_types['stateful_tests']):
- additional_args = ['--stf'] + CTRexScenario.test_types['stateful_tests']
+ additional_args = ['--stf']
+ 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
- except Exception as e:
- result = False
- print(e)
+ #except Exception as e:
+ # result = False
+ # print(e)
finally:
save_setup_info()
- if (result == True and not CTRexScenario.is_test_list):
- print(termstyle.green("""
+ if not CTRexScenario.is_test_list:
+ if result == True:
+ print(termstyle.green("""
..::''''::..
.;'' ``;.
:: :: :: ::
@@ -358,8 +381,18 @@ if __name__ == "__main__":
/_/ /_/ |_/___/___(_)
"""))
- sys.exit(0)
- sys.exit(-1)
+ sys.exit(0)
+ else:
+ print(termstyle.red("""
+ /\_/\
+ ( o.o )
+ > ^ <
+
+This cat is sad, test failed.
+ """))
+ sys.exit(-1)
+
+