summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-10 11:01:38 -0500
committerimarom <imarom@cisco.com>2016-01-10 11:36:34 -0500
commit46bbe5603ff96dfaefeeffdd97d8efe9fbb07e71 (patch)
tree92167fa959930649859d093905643c98e623f1d4 /scripts
parentf1c78acf1648abd6c06a070ef4e6465e5478eab8 (diff)
nose tests for stateless
Diffstat (limited to 'scripts')
-rw-r--r--scripts/automation/regression/stl/golden/basic_imix_golden.capbin0 -> 198474 bytes
-rw-r--r--scripts/automation/regression/stl/golden/basic_imix_vm_golden.capbin0 -> 198474 bytes
-rw-r--r--scripts/automation/regression/stl/golden/basic_tuple_gen_golden.capbin0 -> 38024 bytes
-rwxr-xr-xscripts/automation/regression/trex_unit_test.py5
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py130
-rwxr-xr-xscripts/automation/regression/unit_tests/trex_general_test.py1
6 files changed, 135 insertions, 1 deletions
diff --git a/scripts/automation/regression/stl/golden/basic_imix_golden.cap b/scripts/automation/regression/stl/golden/basic_imix_golden.cap
new file mode 100644
index 00000000..c15ee78f
--- /dev/null
+++ b/scripts/automation/regression/stl/golden/basic_imix_golden.cap
Binary files differ
diff --git a/scripts/automation/regression/stl/golden/basic_imix_vm_golden.cap b/scripts/automation/regression/stl/golden/basic_imix_vm_golden.cap
new file mode 100644
index 00000000..c15ee78f
--- /dev/null
+++ b/scripts/automation/regression/stl/golden/basic_imix_vm_golden.cap
Binary files differ
diff --git a/scripts/automation/regression/stl/golden/basic_tuple_gen_golden.cap b/scripts/automation/regression/stl/golden/basic_tuple_gen_golden.cap
new file mode 100644
index 00000000..4f26336f
--- /dev/null
+++ b/scripts/automation/regression/stl/golden/basic_tuple_gen_golden.cap
Binary files differ
diff --git a/scripts/automation/regression/trex_unit_test.py b/scripts/automation/regression/trex_unit_test.py
index a844aa2a..91fab32e 100755
--- a/scripts/automation/regression/trex_unit_test.py
+++ b/scripts/automation/regression/trex_unit_test.py
@@ -1,4 +1,4 @@
-#!/router/bin/python
+#!/usr/bin/env python
__copyright__ = "Copyright 2014"
@@ -113,6 +113,7 @@ class CTRexTestConfiguringPlugin(Plugin):
parser.add_option('--kill-running', '--kill_running', action="store_true", default = False,
dest="kill_running",
help="Kills running TRex process on remote server (useful for regression).")
+
parser.add_option('--local', action="store_true", default = False,
dest="local",
help="Don't connect to remote server for runnning daemon (useful for functional tests).")
@@ -145,11 +146,13 @@ class CTRexTestConfiguringPlugin(Plugin):
CTRexScenario.benchmark = self.benchmark
CTRexScenario.modes = set(self.modes)
CTRexScenario.server_logs = self.server_logs
+ CTRexScenario.scripts_path = get_trex_path()
# launch TRex daemon on relevant setup
if not self.local:
start_trex_remote_server(self.configuration.trex, self.kill_running)
CTRexScenario.trex = CTRexClient(trex_host = self.configuration.trex['trex_name'], verbose = self.verbose_mode)
+
if 'loopback' not in self.modes:
CTRexScenario.router_cfg = dict( config_dict = self.configuration.router,
forceImageReload = self.load_image,
diff --git a/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py b/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
new file mode 100644
index 00000000..27e1c576
--- /dev/null
+++ b/scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py
@@ -0,0 +1,130 @@
+
+import outer_packages
+from platform_cmd_link import *
+import functional_general_test
+from nose.tools import assert_equal
+from nose.tools import assert_not_equal
+from unit_tests.trex_general_test import CTRexScenario
+from dpkt import pcap
+
+import os
+import subprocess
+
+class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
+ def setUp (self):
+ self.test_path = os.path.abspath(os.getcwd())
+ self.scripts_path = CTRexScenario.scripts_path
+
+ self.verify_exists(os.path.join(self.scripts_path, "bp-sim-64-debug"))
+
+ self.stl_sim = os.path.join(self.scripts_path, "automation/trex_control_plane/client/trex_stateless_sim.py")
+ self.verify_exists(self.stl_sim)
+
+ self.profiles_path = os.path.join(self.scripts_path, "stl/")
+
+ self.profiles = {}
+ self.profiles['imix_3pkt'] = os.path.join(self.profiles_path, "imix_3pkt.yaml")
+ self.profiles['imix_3pkt_vm'] = os.path.join(self.profiles_path, "imix_3pkt.yaml")
+ self.profiles['random_size'] = os.path.join(self.profiles_path, "udp_rand_size.yaml")
+ self.profiles['random_size_9k'] = os.path.join(self.profiles_path, "udp_rand_size_9k.yaml")
+ self.profiles['imix_tuple_gen'] = os.path.join(self.profiles_path, "imix_1pkt_tuple_gen.yaml")
+
+ for k, v in self.profiles.iteritems():
+ self.verify_exists(v)
+
+ self.valgrind_profiles = [ self.profiles['imix_3pkt_vm'], self.profiles['random_size_9k'], self.profiles['imix_tuple_gen']]
+
+ self.golden_path = os.path.join(self.test_path,"stl/golden/")
+
+ os.chdir(self.scripts_path)
+
+
+ def tearDown (self):
+ os.chdir(self.test_path)
+
+
+
+ def get_golden (self, name):
+ golden = os.path.join(self.golden_path, name)
+ self.verify_exists(golden)
+ return golden
+
+
+ def verify_exists (self, name):
+ if not os.path.exists(name):
+ raise Exception("cannot find '{0}'".format(name))
+
+
+ def compare_caps (self, cap1, cap2, max_diff_sec = 0.01):
+ f1 = open(cap1, 'r')
+ reader1 = pcap.Reader(f1)
+ pkts1 = reader1.readpkts()
+
+ f2 = open(cap2, 'r')
+ reader2 = pcap.Reader(f2)
+ pkts2 = reader2.readpkts()
+
+ assert_equal(len(pkts1), len(pkts2))
+
+ for pkt1, pkt2, i in zip(pkts1, pkts2, xrange(1, len(pkts1))):
+ ts1 = pkt1[0]
+ ts2 = pkt2[0]
+ if abs(ts1-ts2) > 0.000005: # 5 nsec
+ raise AssertionError("TS error: cap files '{0}', '{1}' differ in cap #{2} - '{3}' vs. '{4}'".format(cap1, cap2, i, ts1, ts2))
+
+ if pkt1[1] != pkt2[1]:
+ raise AssertionError("RAW error: cap files '{0}', '{1}' differ in cap #{2}".format(cap1, cap2, i))
+
+
+
+ def run_sim (self, yaml, output, options = "", silent = False):
+ user_cmd = "{0} {1} {2}".format(yaml, output, options)
+
+ cmd = "{0} {1} {2}".format("python",
+ self.stl_sim,
+ user_cmd)
+
+ if silent:
+ devnull = open('/dev/null', 'w')
+ rc = subprocess.call(cmd, shell = True, stdout = devnull)
+ else:
+ print cmd
+ rc = subprocess.call(cmd, shell = True)
+
+ return (rc == 0)
+
+
+ def golden_run (self, testname, profile, options, silent = False):
+ output_cap = os.path.join(self.test_path, "{0}_test.cap".format(testname))
+ golden_cap = os.path.join(self.test_path, "stl/golden/{0}_golden.cap".format(testname))
+
+ rc = self.run_sim(self.profiles[profile], output_cap, options, silent)
+ assert_equal(rc, True)
+
+ self.compare_caps(output_cap, golden_cap)
+
+
+
+ # test for IMIX
+ def test_imix (self):
+ self.golden_run("basic_imix", "imix_3pkt", "-m 50kpps --limit 500 --cores 8", silent = False)
+
+
+ def test_vm (self):
+ self.golden_run("basic_imix_vm", "imix_3pkt_vm", "-m 50kpps --limit 500 --cores 8", silent = False)
+
+
+ def test_tuple_gen (self):
+ self.golden_run("basic_tuple_gen", "imix_tuple_gen", "-m 50kpps --limit 500 --cores 8", silent = False)
+
+
+ # valgrind tests
+ def test_valgrind_various_profiles (self):
+
+ print "\n"
+ for profile in self.valgrind_profiles:
+ print "\n*** testing profile '{0}' ***\n".format(profile)
+ rc = self.run_sim(profile, output = "dummy.cap", options = "--dry --cores 8 --limit 500 --valgrind", silent = False)
+ assert_equal(rc, True)
+
+
diff --git a/scripts/automation/regression/unit_tests/trex_general_test.py b/scripts/automation/regression/unit_tests/trex_general_test.py
index efe24711..78ce3c91 100755
--- a/scripts/automation/regression/unit_tests/trex_general_test.py
+++ b/scripts/automation/regression/unit_tests/trex_general_test.py
@@ -53,6 +53,7 @@ class CTRexScenario():
setup_dir = None
router_image = None
trex_version = None
+ scripts_path = None
report_dir = 'reports'
# logger = None
scripts_dir = None