This is an initial code cleanup after major redesign of LNST.
Most of it is removal of code that cannot be used anymore due to API change. I did also some pylint checks on the code where I found minor issues.
Jan Tluka (20): lnst/Slave/NetTestSlave.py: remove NetTestCommand references remove already ported IcmpPing and Icmp6Ping test modules remove legacy PacketAssert test module remove legacy Iperf test module remove legacy test_modules remove deprecated regression_tests move DEFAULT_TIMEOUT definiton from NetTestCommand to Job remove legacy TestsCommon remove legacy NetTestCommand class remove pyrecipes lnst/Common/Parameters: fix missing parameter in ListParam type_check lnst/Common/TestRecipe: fix typo lnst.RecipeCommon.Perf.Results: remove deprecated __setslice__ BaselineEvaluator: fix missing self handle in describe_group_results remove obsolete NetConfigDevice module remove obsolete NmConfigDevice module lnst.Slave.InterfaceManager: add missing import of DeviceError remove directory obsolete remove obsolete recipe_conv.py remove obsolete recipe-schema.rng
lnst/Common/NetTestCommand.py | 571 ----------- lnst/Common/Parameters.py | 4 +- lnst/Common/TestsCommon.py | 147 --- lnst/Controller/Job.py | 3 +- lnst/Controller/Namespace.py | 2 +- lnst/Controller/NetNamespace.py | 1 - .../Perf/Evaluators/BaselineEvaluator.py | 2 +- lnst/RecipeCommon/Perf/Results.py | 16 +- lnst/RecipeCommon/TestRecipe.py | 2 +- lnst/Slave/InterfaceManager.py | 3 +- lnst/Slave/NetConfigDevice.py | 741 --------------- lnst/Slave/NetTestSlave.py | 19 - lnst/Slave/NmConfigDevice.py | 888 ------------------ misc/recipe_conv.py | 134 --- obsolete/SwSwitch/SwSwitch.py | 387 -------- obsolete/SwSwitch/__init__.py | 0 obsolete/Switch/Drivers/SwSwitch.py | 49 - obsolete/Switch/Drivers/__init__.py | 0 obsolete/Switch/SwitchConfigParse.py | 73 -- obsolete/Switch/SwitchCtl.py | 42 - obsolete/Switch/SwitchDriversCommon.py | 51 - obsolete/Switch/__init__.py | 0 obsolete/netconfig.py | 206 ---- obsolete/switchconfig.py | 87 -- obsolete/swswitch.py | 90 -- pyrecipes/3_vlans.py | 34 - pyrecipes/example.py | 33 - pyrecipes/ping_flood.py | 48 - regression-tests/README.md | 112 --- regression-tests/env/lnst-ctl.conf | 16 - regression-tests/run-test.sh | 253 ----- regression-tests/tests/0/desc | 6 - regression-tests/tests/0/run.sh | 24 - regression-tests/tests/1/desc | 4 - regression-tests/tests/1/recipe.xml | 33 - regression-tests/tests/1/run.sh | 12 - regression-tests/tests/10/desc | 4 - .../tests/10/prefix-check-taskapi.xml | 33 - regression-tests/tests/10/prefix-check.py | 15 - regression-tests/tests/10/prefix-check.xml | 44 - regression-tests/tests/10/run.sh | 39 - regression-tests/tests/11/desc | 3 - regression-tests/tests/11/recipe.xml | 33 - regression-tests/tests/11/run.sh | 15 - regression-tests/tests/12/desc | 1 - regression-tests/tests/12/run.sh | 12 - regression-tests/tests/12/sm01.xml | 7 - regression-tests/tests/12/sm02.xml | 7 - regression-tests/tests/12/xinclude-check.xml | 13 - regression-tests/tests/13/desc | 1 - regression-tests/tests/13/run.sh | 22 - .../tests/13/taskapi-alias-check.py | 9 - .../tests/13/taskapi-alias-check.xml | 38 - .../tests/13/taskapi-alias-namespace-check.py | 8 - .../13/taskapi-alias-namespace-check.xml | 41 - regression-tests/tests/14/desc | 3 - regression-tests/tests/14/recipe1.xml | 68 -- regression-tests/tests/14/recipe2.xml | 79 -- regression-tests/tests/14/run.sh | 17 - regression-tests/tests/15/desc | 3 - regression-tests/tests/15/recipe.xml | 33 - regression-tests/tests/15/run.sh | 12 - regression-tests/tests/16/desc | 3 - regression-tests/tests/16/recipe.xml | 37 - regression-tests/tests/16/run.sh | 14 - regression-tests/tests/17/desc | 3 - regression-tests/tests/17/recipe.xml | 38 - regression-tests/tests/17/run.sh | 14 - regression-tests/tests/18/desc | 6 - regression-tests/tests/18/recipe.xml | 26 - regression-tests/tests/18/run.sh | 19 - regression-tests/tests/19/desc | 3 - regression-tests/tests/19/recipe.xml | 17 - regression-tests/tests/19/run.sh | 19 - regression-tests/tests/2/desc | 5 - regression-tests/tests/2/recipe.xml | 74 -- regression-tests/tests/2/run.sh | 12 - regression-tests/tests/20/desc | 3 - regression-tests/tests/20/recipe1.xml | 47 - regression-tests/tests/20/recipe2.xml | 31 - regression-tests/tests/20/run.sh | 20 - regression-tests/tests/21/desc | 3 - regression-tests/tests/21/lnst-ctl.conf | 3 - regression-tests/tests/21/recipe.xml | 55 -- regression-tests/tests/21/run.sh | 18 - .../tests/21/test_modules/TCPConnection.py | 60 -- .../tests/21/test_tools/tcp_conn/Makefile | 12 - .../21/test_tools/tcp_conn/lnst-setup.sh | 3 - .../21/test_tools/tcp_conn/tcp_connect.c | 281 ------ .../tests/21/test_tools/tcp_conn/tcp_listen.c | 330 ------- regression-tests/tests/22/desc | 3 - regression-tests/tests/22/lnst-ctl.conf | 2 - regression-tests/tests/22/pool/slave1.xml | 6 - regression-tests/tests/22/pool/slave2.xml | 6 - regression-tests/tests/22/recipe.xml | 26 - regression-tests/tests/22/run.sh | 18 - regression-tests/tests/23/desc | 3 - regression-tests/tests/23/lnst-ctl.conf | 2 - regression-tests/tests/23/recipe.xml | 42 - regression-tests/tests/23/run.sh | 19 - .../tests/23/test_modules/IcmpPing.py | 71 -- regression-tests/tests/24/desc | 6 - regression-tests/tests/24/recipe_fail.xml | 33 - regression-tests/tests/24/recipe_pass.xml | 33 - regression-tests/tests/24/run.sh | 22 - regression-tests/tests/25/desc | 12 - regression-tests/tests/25/recipe1.xml | 44 - regression-tests/tests/25/recipe2.xml | 53 -- regression-tests/tests/25/recipe3.xml | 28 - regression-tests/tests/25/run.sh | 27 - regression-tests/tests/26/desc | 7 - regression-tests/tests/26/recipe1.xml | 46 - regression-tests/tests/26/recipe2.xml | 46 - regression-tests/tests/26/run.sh | 24 - regression-tests/tests/27/desc | 10 - regression-tests/tests/27/recipe1.xml | 32 - regression-tests/tests/27/recipe2.xml | 32 - regression-tests/tests/27/recipe3.xml | 31 - regression-tests/tests/27/recipe4.xml | 31 - regression-tests/tests/27/recipe5.xml | 32 - regression-tests/tests/27/recipe6.xml | 30 - regression-tests/tests/27/recipe7.xml | 30 - regression-tests/tests/27/recipe8.xml | 32 - regression-tests/tests/27/run.sh | 48 - regression-tests/tests/28/desc | 6 - regression-tests/tests/28/recipe1.py | 20 - regression-tests/tests/28/recipe1.xml | 16 - regression-tests/tests/28/recipe2.py | 18 - regression-tests/tests/28/recipe2.xml | 16 - regression-tests/tests/28/recipe3.py | 11 - regression-tests/tests/28/recipe3.xml | 16 - regression-tests/tests/28/recipe4.py | 15 - regression-tests/tests/28/recipe4.xml | 16 - regression-tests/tests/28/run.sh | 34 - regression-tests/tests/3/desc | 8 - regression-tests/tests/3/recipe.xml | 21 - regression-tests/tests/3/run.sh | 12 - regression-tests/tests/4/desc | 3 - regression-tests/tests/4/recipe.xml | 43 - regression-tests/tests/4/run.sh | 19 - regression-tests/tests/5/desc | 3 - regression-tests/tests/5/recipe.xml | 29 - regression-tests/tests/5/run.sh | 20 - regression-tests/tests/6/desc | 4 - regression-tests/tests/6/recipe.xml | 35 - regression-tests/tests/6/run.sh | 19 - regression-tests/tests/7/desc | 4 - regression-tests/tests/7/recipe.xml | 24 - regression-tests/tests/7/run.sh | 19 - regression-tests/tests/7/task.py | 23 - regression-tests/tests/8/desc | 3 - regression-tests/tests/8/recipe.xml | 26 - regression-tests/tests/8/run.sh | 12 - regression-tests/tests/9/desc | 3 - regression-tests/tests/9/recipe.xml | 24 - regression-tests/tests/9/run.sh | 12 - regression-tests/tests/9/task.py | 9 - regression-tests/tests/lib.sh | 67 -- schema-recipe.rng | 715 -------------- test_modules/Custom.py | 31 - test_modules/DummyFailing.py | 19 - test_modules/Icmp6Ping.py | 74 -- test_modules/IcmpPing.py | 71 -- test_modules/Iperf.py | 160 ---- test_modules/LinkNeg.py | 59 -- test_modules/Multicast.py | 134 --- test_modules/NetCat.py | 69 -- test_modules/Netperf.py | 579 ------------ test_modules/PacketAssert.py | 148 --- test_modules/PktCounter.py | 89 -- test_modules/PktgenTx.py | 93 -- test_modules/TCPConnection.py | 60 -- 172 files changed, 18 insertions(+), 9589 deletions(-) delete mode 100644 lnst/Common/NetTestCommand.py delete mode 100644 lnst/Common/TestsCommon.py delete mode 100644 lnst/Slave/NetConfigDevice.py delete mode 100644 lnst/Slave/NmConfigDevice.py delete mode 100755 misc/recipe_conv.py delete mode 100644 obsolete/SwSwitch/SwSwitch.py delete mode 100644 obsolete/SwSwitch/__init__.py delete mode 100644 obsolete/Switch/Drivers/SwSwitch.py delete mode 100644 obsolete/Switch/Drivers/__init__.py delete mode 100644 obsolete/Switch/SwitchConfigParse.py delete mode 100644 obsolete/Switch/SwitchCtl.py delete mode 100644 obsolete/Switch/SwitchDriversCommon.py delete mode 100644 obsolete/Switch/__init__.py delete mode 100755 obsolete/netconfig.py delete mode 100755 obsolete/switchconfig.py delete mode 100755 obsolete/swswitch.py delete mode 100644 pyrecipes/3_vlans.py delete mode 100644 pyrecipes/example.py delete mode 100644 pyrecipes/ping_flood.py delete mode 100644 regression-tests/README.md delete mode 100644 regression-tests/env/lnst-ctl.conf delete mode 100755 regression-tests/run-test.sh delete mode 100644 regression-tests/tests/0/desc delete mode 100755 regression-tests/tests/0/run.sh delete mode 100644 regression-tests/tests/1/desc delete mode 100644 regression-tests/tests/1/recipe.xml delete mode 100755 regression-tests/tests/1/run.sh delete mode 100644 regression-tests/tests/10/desc delete mode 100644 regression-tests/tests/10/prefix-check-taskapi.xml delete mode 100644 regression-tests/tests/10/prefix-check.py delete mode 100644 regression-tests/tests/10/prefix-check.xml delete mode 100755 regression-tests/tests/10/run.sh delete mode 100644 regression-tests/tests/11/desc delete mode 100644 regression-tests/tests/11/recipe.xml delete mode 100755 regression-tests/tests/11/run.sh delete mode 100644 regression-tests/tests/12/desc delete mode 100755 regression-tests/tests/12/run.sh delete mode 100644 regression-tests/tests/12/sm01.xml delete mode 100644 regression-tests/tests/12/sm02.xml delete mode 100644 regression-tests/tests/12/xinclude-check.xml delete mode 100644 regression-tests/tests/13/desc delete mode 100755 regression-tests/tests/13/run.sh delete mode 100644 regression-tests/tests/13/taskapi-alias-check.py delete mode 100644 regression-tests/tests/13/taskapi-alias-check.xml delete mode 100644 regression-tests/tests/13/taskapi-alias-namespace-check.py delete mode 100644 regression-tests/tests/13/taskapi-alias-namespace-check.xml delete mode 100644 regression-tests/tests/14/desc delete mode 100644 regression-tests/tests/14/recipe1.xml delete mode 100644 regression-tests/tests/14/recipe2.xml delete mode 100755 regression-tests/tests/14/run.sh delete mode 100644 regression-tests/tests/15/desc delete mode 100644 regression-tests/tests/15/recipe.xml delete mode 100755 regression-tests/tests/15/run.sh delete mode 100644 regression-tests/tests/16/desc delete mode 100644 regression-tests/tests/16/recipe.xml delete mode 100755 regression-tests/tests/16/run.sh delete mode 100644 regression-tests/tests/17/desc delete mode 100644 regression-tests/tests/17/recipe.xml delete mode 100755 regression-tests/tests/17/run.sh delete mode 100644 regression-tests/tests/18/desc delete mode 100644 regression-tests/tests/18/recipe.xml delete mode 100755 regression-tests/tests/18/run.sh delete mode 100644 regression-tests/tests/19/desc delete mode 100644 regression-tests/tests/19/recipe.xml delete mode 100755 regression-tests/tests/19/run.sh delete mode 100644 regression-tests/tests/2/desc delete mode 100644 regression-tests/tests/2/recipe.xml delete mode 100755 regression-tests/tests/2/run.sh delete mode 100644 regression-tests/tests/20/desc delete mode 100644 regression-tests/tests/20/recipe1.xml delete mode 100644 regression-tests/tests/20/recipe2.xml delete mode 100755 regression-tests/tests/20/run.sh delete mode 100644 regression-tests/tests/21/desc delete mode 100644 regression-tests/tests/21/lnst-ctl.conf delete mode 100644 regression-tests/tests/21/recipe.xml delete mode 100755 regression-tests/tests/21/run.sh delete mode 100644 regression-tests/tests/21/test_modules/TCPConnection.py delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/Makefile delete mode 100755 regression-tests/tests/21/test_tools/tcp_conn/lnst-setup.sh delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/tcp_connect.c delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/tcp_listen.c delete mode 100644 regression-tests/tests/22/desc delete mode 100644 regression-tests/tests/22/lnst-ctl.conf delete mode 100644 regression-tests/tests/22/pool/slave1.xml delete mode 100644 regression-tests/tests/22/pool/slave2.xml delete mode 100644 regression-tests/tests/22/recipe.xml delete mode 100755 regression-tests/tests/22/run.sh delete mode 100644 regression-tests/tests/23/desc delete mode 100644 regression-tests/tests/23/lnst-ctl.conf delete mode 100644 regression-tests/tests/23/recipe.xml delete mode 100755 regression-tests/tests/23/run.sh delete mode 100644 regression-tests/tests/23/test_modules/IcmpPing.py delete mode 100644 regression-tests/tests/24/desc delete mode 100644 regression-tests/tests/24/recipe_fail.xml delete mode 100644 regression-tests/tests/24/recipe_pass.xml delete mode 100755 regression-tests/tests/24/run.sh delete mode 100644 regression-tests/tests/25/desc delete mode 100644 regression-tests/tests/25/recipe1.xml delete mode 100644 regression-tests/tests/25/recipe2.xml delete mode 100644 regression-tests/tests/25/recipe3.xml delete mode 100755 regression-tests/tests/25/run.sh delete mode 100644 regression-tests/tests/26/desc delete mode 100644 regression-tests/tests/26/recipe1.xml delete mode 100644 regression-tests/tests/26/recipe2.xml delete mode 100755 regression-tests/tests/26/run.sh delete mode 100644 regression-tests/tests/27/desc delete mode 100644 regression-tests/tests/27/recipe1.xml delete mode 100644 regression-tests/tests/27/recipe2.xml delete mode 100644 regression-tests/tests/27/recipe3.xml delete mode 100644 regression-tests/tests/27/recipe4.xml delete mode 100644 regression-tests/tests/27/recipe5.xml delete mode 100644 regression-tests/tests/27/recipe6.xml delete mode 100644 regression-tests/tests/27/recipe7.xml delete mode 100644 regression-tests/tests/27/recipe8.xml delete mode 100755 regression-tests/tests/27/run.sh delete mode 100644 regression-tests/tests/28/desc delete mode 100644 regression-tests/tests/28/recipe1.py delete mode 100644 regression-tests/tests/28/recipe1.xml delete mode 100644 regression-tests/tests/28/recipe2.py delete mode 100644 regression-tests/tests/28/recipe2.xml delete mode 100644 regression-tests/tests/28/recipe3.py delete mode 100644 regression-tests/tests/28/recipe3.xml delete mode 100644 regression-tests/tests/28/recipe4.py delete mode 100644 regression-tests/tests/28/recipe4.xml delete mode 100755 regression-tests/tests/28/run.sh delete mode 100644 regression-tests/tests/3/desc delete mode 100644 regression-tests/tests/3/recipe.xml delete mode 100755 regression-tests/tests/3/run.sh delete mode 100644 regression-tests/tests/4/desc delete mode 100644 regression-tests/tests/4/recipe.xml delete mode 100755 regression-tests/tests/4/run.sh delete mode 100644 regression-tests/tests/5/desc delete mode 100644 regression-tests/tests/5/recipe.xml delete mode 100755 regression-tests/tests/5/run.sh delete mode 100644 regression-tests/tests/6/desc delete mode 100644 regression-tests/tests/6/recipe.xml delete mode 100755 regression-tests/tests/6/run.sh delete mode 100644 regression-tests/tests/7/desc delete mode 100644 regression-tests/tests/7/recipe.xml delete mode 100755 regression-tests/tests/7/run.sh delete mode 100644 regression-tests/tests/7/task.py delete mode 100644 regression-tests/tests/8/desc delete mode 100644 regression-tests/tests/8/recipe.xml delete mode 100755 regression-tests/tests/8/run.sh delete mode 100644 regression-tests/tests/9/desc delete mode 100644 regression-tests/tests/9/recipe.xml delete mode 100755 regression-tests/tests/9/run.sh delete mode 100644 regression-tests/tests/9/task.py delete mode 100644 regression-tests/tests/lib.sh delete mode 100644 schema-recipe.rng delete mode 100644 test_modules/Custom.py delete mode 100644 test_modules/DummyFailing.py delete mode 100644 test_modules/Icmp6Ping.py delete mode 100644 test_modules/IcmpPing.py delete mode 100644 test_modules/Iperf.py delete mode 100644 test_modules/LinkNeg.py delete mode 100644 test_modules/Multicast.py delete mode 100644 test_modules/NetCat.py delete mode 100644 test_modules/Netperf.py delete mode 100644 test_modules/PacketAssert.py delete mode 100644 test_modules/PktCounter.py delete mode 100644 test_modules/PktgenTx.py delete mode 100644 test_modules/TCPConnection.py
removes also SlaveMethods.get_remaining_time()
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Slave/NetTestSlave.py | 19 ------------------- 1 file changed, 19 deletions(-)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index 4f5fc9f..47eb8ce 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -29,9 +29,6 @@ from lnst.Common.PacketCapture import PacketCapture from lnst.Common.Utils import die_when_parent_die from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail from lnst.Common.ResourceCache import ResourceCache -from lnst.Common.NetTestCommand import NetTestCommandContext -from lnst.Common.NetTestCommand import NetTestCommand -from lnst.Common.NetTestCommand import DEFAULT_TIMEOUT from lnst.Common.Utils import check_process_running from lnst.Common.Utils import is_installed from lnst.Common.ConnectionHandler import send_data @@ -394,22 +391,6 @@ class SlaveMethods: self._system_config = {} return True
- def get_remaining_time(self, bg_id): - cmd = self._command_context.get_cmd(bg_id) - if "timeout" in cmd._command: - cmd_timeout = cmd._command["timeout"] - else: - cmd_timeout = DEFAULT_TIMEOUT - - start_time = cmd._start_time - current_time = time() - - remaining = cmd_timeout - (current_time - start_time) - if remaining < 0: - remaining = 0 - - return int(remaining) - def run_job(self, job): job_instance = Job(job, self._log_ctl) self._job_context.add_job(job_instance)
Ported version is available in lnst/Tests/Ping.py
Signed-off-by: Jan Tluka jtluka@redhat.com --- test_modules/Icmp6Ping.py | 74 --------------------------------------- test_modules/IcmpPing.py | 71 ------------------------------------- 2 files changed, 145 deletions(-) delete mode 100644 test_modules/Icmp6Ping.py delete mode 100644 test_modules/IcmpPing.py
diff --git a/test_modules/Icmp6Ping.py b/test_modules/Icmp6Ping.py deleted file mode 100644 index 405c756..0000000 --- a/test_modules/Icmp6Ping.py +++ /dev/null @@ -1,74 +0,0 @@ -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -jmalanik@redhat.com (Jan Malanik) -jtluka@redhat.com (Jan Tluka) -""" - - -import logging -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ExecCmd import exec_cmd - - -class Icmp6Ping(TestGeneric): - def compose_cmd(self): - addr = self.get_mopt("addr", opt_type="addr") - cmd = "ping6 %s" % addr - - iface = self.get_opt("iface") - if iface: - cmd += " -I %s" % iface - - count = self.get_opt("count") - if count: - cmd += " -c %s" % count - - interval = self.get_opt("interval") - if interval: - cmd += " -i %s" % interval - - size = self.get_opt("size") - if size: - cmd += " -s %s" % size - - return cmd - - def run(self): - cmd = self.compose_cmd() - logging.debug("%s" % cmd) - - limit_rate = self.get_opt("limit_rate", default=80) - data_stdout = exec_cmd(cmd, die_on_err=False)[0] - - stat_pttr1 = r'(\d+) packets transmitted, (\d+) received' - stat_pttr2 = r'rtt min/avg/max/mdev = (\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+) ms' - - match = re.search(stat_pttr1, data_stdout) - if not match: - res_data = {"msg": "expected pattern not found"} - return self.set_fail(res_data) - - trans_pkts, recv_pkts = match.groups() - rate = int(round((float(recv_pkts) / float(trans_pkts)) * 100)) - logging.debug("Transmitted "%s", received "%s", " \ - "rate "%d%%", limit_rate "%d%%"" \ - % (trans_pkts, recv_pkts, rate, limit_rate )) - - res_data = {"rate": rate, - "limit_rate": limit_rate} - - match = re.search(stat_pttr2, data_stdout) - if match: - tmin, tavg, tmax, tmdev = [float(x) for x in match.groups()] - logging .debug("rtt min "%.3f", avg "%.3f", max "%.3f", " - "mdev "%.3f"" % (tmin, tavg, tmax, tmdev)) - - res_data["rtt_min"] = tmin - res_data["rtt_max"] = tmax - - if rate < limit_rate : - res_data["msg"] = "rate is lower than limit" - return self.set_fail(res_data) - - return self.set_pass(res_data) diff --git a/test_modules/IcmpPing.py b/test_modules/IcmpPing.py deleted file mode 100644 index 5b9d888..0000000 --- a/test_modules/IcmpPing.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -This module defines icmp ping test - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ExecCmd import exec_cmd - -class IcmpPing(TestGeneric): - def _compose_cmd(self): - addr = self.get_mopt("addr", opt_type="addr") - cmd = "ping %s" % addr - count = self.get_opt("count") - if count: - cmd += " -c %s" % count - interval = self.get_opt("interval") - if interval: - cmd += " -i %s" % interval - iface = self.get_opt("iface") - if iface: - cmd += " -I %s" % iface - size = self.get_opt("size") - if size: - cmd += " -s %s" % size - return cmd - - def run(self): - cmd = self._compose_cmd() - limit_rate = self.get_opt("limit_rate", default=80) - - data_stdout = exec_cmd(cmd, die_on_err=False)[0] - stat_pttr1 = r'(\d+) packets transmitted, (\d+) received' - stat_pttr2 = r'rtt min/avg/max/mdev = (\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+) ms' - - match = re.search(stat_pttr1, data_stdout) - if not match: - res_data = {"msg": "expected pattern not found"} - return self.set_fail(res_data) - - trans_pkts, recv_pkts = match.groups() - rate = int(round((float(recv_pkts) / float(trans_pkts)) * 100)) - logging.debug("Transmitted "%s", received "%s", " - "rate "%d%%", limit_rate "%d%%"" - % (trans_pkts, recv_pkts, rate, limit_rate)) - - res_data = {"rate": rate, - "limit_rate": limit_rate} - - match = re.search(stat_pttr2, data_stdout) - if match: - tmin, tavg, tmax, tmdev = [float(x) for x in match.groups()] - logging.debug("rtt min "%.3f", avg "%.3f", max "%.3f", " - "mdev "%.3f"" % (tmin, tavg, tmax, tmdev)) - - res_data["rtt_min"] = tmin - res_data["rtt_max"] = tmax - - if rate < limit_rate: - res_data["msg"] = "rate is lower than limit" - return self.set_fail(res_data) - - return self.set_pass(res_data)
This module has been ported to lnst/Tests/PacketAssert.py.
There's a slight modification of the test module.
The min and max parameters used for pass/fail evaluation were removed as it can and should be done outside of the test module.
Signed-off-by: Jan Tluka jtluka@redhat.com --- test_modules/PacketAssert.py | 148 ----------------------------------- 1 file changed, 148 deletions(-) delete mode 100644 test_modules/PacketAssert.py
diff --git a/test_modules/PacketAssert.py b/test_modules/PacketAssert.py deleted file mode 100644 index 1f3c4cb..0000000 --- a/test_modules/PacketAssert.py +++ /dev/null @@ -1,148 +0,0 @@ -""" -Test if packets were transfered through some interface correctly. -This test is using tcpdump. - -Copyright 2012 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -rpazdera@redhat.com (Radek Pazdera) -""" - -import logging -import subprocess -import re -import signal -import time -import os -import tempfile -from lnst.Common.TestsCommon import TestGeneric - -class PacketAssert(TestGeneric): - """ Assert for number of incomming/outgoing packets - Capturing backend of this class is provided by - tcpdump(8). - """ - - _cmd = "" - _tcpdump = None - _tcpdump_capture_file = None - _grep_filters = [] - - _min_cond = 1 - _max_cond = None - - _num_recv = 0 - - def _prepare_grep_filters(self): - """ Parse `grep_for' test options """ - filters = self.get_multi_opt("grep_for") - - for filt in filters: - if filt != None: - self._grep_filters.append(filt) - - def _prepare_conditions(self): - """ Parse `min' and `max' """ - min_packets = self.get_opt("min") - max_packets = self.get_opt("max") - - if min_packets != None: - self._min_cond = int(min_packets) - - if max_packets != None: - self._max_cond = int(max_packets) - - def _compose_cmd(self): - """ Create a command from the recipe options """ - cmd = "" - - interface = self.get_mopt("interface") - pcap_filter = self.get_opt("filter") - promiscuous = self.get_opt("promiscuous", default=False) - if not pcap_filter: - pcap_filter = "" - - promiscuous_str = "" if promiscuous else "-p" - - cmd = "tcpdump %s -nn -i %s "%s"" % (promiscuous_str, interface, - pcap_filter) - logging.debug("PacketAssert tcpdump command: %s" % cmd) - self._cmd = cmd - - def _execute_tcpdump(self): - """ Start tcpdump in the background """ - cmd = self._cmd - tcpdump_file = tempfile.NamedTemporaryFile(delete=False) - self._tcpdump_capture_file = tcpdump_file.name - - proc = subprocess.Popen(cmd, shell=True, stdout=tcpdump_file, - stderr=None) - self._tcpdump = proc - - def _process_captured_line(self, line): - """ Apply filters and see if the packet passed them """ - if len(self._grep_filters): - for filt in self._grep_filters: - if not re.search(filt, line): - return - - self._num_recv += 1 - - def _evaluate_results(self): - """ Compare results with the conditions """ - num = self._num_recv - if num >= self._min_cond: - if self._max_cond != None: - return num <= self._max_cond - return True - return False - - def run(self): - self._prepare_grep_filters() - self._prepare_conditions() - self._compose_cmd() - self._execute_tcpdump() - - logging.info("Capturing started") - - while True: - if self._tcpdump.poll() != None: - if self._tcpdump.returncode > 0: - raise Exception("tcpdump terminated with error") - else: - break - else: - time.sleep(1) - continue - - # get and evalute the tcpdump's output - # empty string returned by readline() means the EOF has been reached - tcpdump_file = open(self._tcpdump_capture_file, 'r') - line = "\n" - while line != "": - try: - line = tcpdump_file.readline() - except (OSError, IOError): - logging.debug("Caught exception while reading tcpdump output") - break - - line = line.strip("\n") - if len(line) != 0: - self._process_captured_line(line) - - tcpdump_file.close() - os.remove(tcpdump_file.name) - - logging.info("Capturing finished. Received %d packets", self._num_recv) - res = {"received": self._num_recv, - "min": self._min_cond, - "max": self._max_cond} - - if self._evaluate_results(): - return self.set_pass(res) - - res["msg"] = "PacketAssert failed!" - return self.set_fail(res)
The module has been replaced by lnst/Tests/Iperf.py.
The only difference is that the new test module uses iperf3 instead of iperf that is not maintained anymore.
Signed-off-by: Jan Tluka jtluka@redhat.com --- test_modules/Iperf.py | 160 ------------------------------------------ 1 file changed, 160 deletions(-) delete mode 100644 test_modules/Iperf.py
diff --git a/test_modules/Iperf.py b/test_modules/Iperf.py deleted file mode 100644 index 77bd1a0..0000000 --- a/test_modules/Iperf.py +++ /dev/null @@ -1,160 +0,0 @@ -""" -This module defines iperf test -""" - -__author__ = """ -jtluka@redhat.com (Jan Tluka) -""" - -import logging -import time -import errno -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ExecCmd import exec_cmd -from lnst.Common.ShellProcess import ShellProcess -from lnst.Common.Utils import is_installed - -class Iperf(TestGeneric): - def _compose_iperf_cmd(self, role): - iperf_options = self.get_opt("iperf_opts") - if iperf_options is None: - iperf_options = "" - - cmd = "" - if role == "client": - iperf_server = self.get_mopt("iperf_server", opt_type="addr") - cmd = "iperf --%s %s -t %s %s" % (role, iperf_server, self.duration, iperf_options) - elif role == "server": - bind = self.get_opt("bind", opt_type="addr") - if bind != None: - cmd = "iperf --%s -B %s %s" % (role, bind, iperf_options) - else: - cmd = "iperf --%s %s" % (role, iperf_options) - - return cmd - - def _rate_over_threshold(self, rate): - # convert rate to the same unit as threshold unit - pattern = "(\d*(.\d*){0,1})\s*([ kKMGT])bits/sec" - - # parse threshold value - r1 = re.match(pattern, self.threshold) - thr_units = r1.group(3).upper() - - # parse measured rate value - r2 = re.match(pattern, rate) - rate_units = r2.group(3).upper() - - thr_val = float(r1.group(1)) - - rate_val = float(r2.group(1)) - - # do the conversion of rate units - if thr_units != rate_units: - # remove any k,M,G,T from measured rate - if rate_units == 'K': - rate_val *= 1000 - elif rate_units == 'M': - rate_val *= 1000*1000 - elif rate_units == 'G': - rate_val *= 1000*1000*1000 - - # divide by k or M or G if present - if thr_units == 'K': - rate_val /= 1000 - elif thr_units == 'M': - rate_val /= 1000*1000 - elif thr_units == 'G': - rate_val /= 1000*1000*1000 - - if rate_val < thr_val: - logging.info("measured rate is below threshold! " \ - "(measured: %s < threshold: %s)" % \ - (rate, self.threshold)) - return False - - return True - - def run_client(self, cmd): - client = ShellProcess(cmd) - try: - client.wait() - except OSError as e: - # we got interrupted, let's gather data - if e.errno == errno.EINTR: - client.kill() - - output = client.read_nonblocking() - - if re.search("connect failed:", output): - logging.info("Iperf connection failed!") - return (False, "Iperf connection failed!") - - m = re.search("[[^0-9]*[0-9]*]\s*0.0+-\s*\d*.\d+\s*sec\s*\d*(.\d*){0,1}\s*[ kGMT]Bytes\s*(\d*(.\d*){0,1}\s*[ kGMT]bits/sec)", output, re.IGNORECASE) - if m is None: - logging.info("Could not get performance throughput!") - return (False, "Could not get performance throughput!") - - rate = m.group(2) - if self.threshold is not None: - # check if expected threshold is reached - result = self._rate_over_threshold(rate) - if result: - return (True, "Measured rate (%s) is over threshold (%s)." % - (rate, self.threshold)) - else: - return (False, "Measured rate (%s) is below threshold (%s)!" % - (rate, self.threshold)) - else: - return True, "Measured rate: %s" % rate - - def run_server(self, cmd): - server = ShellProcess(cmd) - - if not self._keep_server_running: - time.sleep(float(self.duration)) - server.read_nonblocking() - server.kill() - else: - try: - server.wait() - except OSError as e: - if e.errno == errno.EINTR: - server.kill() - - server.read_nonblocking() - - def run(self): - self._keep_server_running = True - - self.duration = self.get_opt("duration") - if self.duration is None: - self.duration = 60 # for client purposes - else: - self._keep_server_running = False # for server purposes - - self.threshold = self.get_opt("threshold") - - role = self.get_mopt("role") - cmd = self._compose_iperf_cmd(role) - logging.debug("compiled command: %s" % cmd) - if not is_installed("iperf"): - res_data = {} - res_data["msg"] = "Iperf is not installed on this machine!" - logging.error(res_data["msg"]) - return self.set_fail(res_data) - - if role == "server": - logging.debug("running as server ...") - self.run_server(cmd) - - return self.set_pass() - elif role == "client": - logging.debug("running as client ...") - (rv, message) = self.run_client(cmd) - res_data = {"msg": message} - if rv == False: - return self.set_fail(res_data) - - return self.set_pass(res_data)
All test modules in test_modules directory are deprecated.
Some of the modules have been already ported, the rest can be ported later.
Signed-off-by: Jan Tluka jtluka@redhat.com --- test_modules/Custom.py | 31 -- test_modules/DummyFailing.py | 19 -- test_modules/LinkNeg.py | 59 ---- test_modules/Multicast.py | 134 -------- test_modules/NetCat.py | 69 ---- test_modules/Netperf.py | 579 ---------------------------------- test_modules/PktCounter.py | 89 ------ test_modules/PktgenTx.py | 93 ------ test_modules/TCPConnection.py | 60 ---- 9 files changed, 1133 deletions(-) delete mode 100644 test_modules/Custom.py delete mode 100644 test_modules/DummyFailing.py delete mode 100644 test_modules/LinkNeg.py delete mode 100644 test_modules/Multicast.py delete mode 100644 test_modules/NetCat.py delete mode 100644 test_modules/Netperf.py delete mode 100644 test_modules/PktCounter.py delete mode 100644 test_modules/PktgenTx.py delete mode 100644 test_modules/TCPConnection.py
diff --git a/test_modules/Custom.py b/test_modules/Custom.py deleted file mode 100644 index ac3c742..0000000 --- a/test_modules/Custom.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -This module defines custom test - -Copyright 2016 Mellanox Technologies. All rights reserved. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jiri@mellanox.com (Jiri Pirko) -""" - -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.Utils import bool_it - -class Custom(TestGeneric): - def run(self): - fail_str = self.get_opt("fail") - if not fail_str: - fail = False - else: - fail = bool_it(fail_str) - - res_data = self.get_single_opts() - if "fail" in res_data: - del(res_data["fail"]) - - if fail: - return self.set_fail(res_data) - - return self.set_pass(res_data) diff --git a/test_modules/DummyFailing.py b/test_modules/DummyFailing.py deleted file mode 100644 index fed9fe4..0000000 --- a/test_modules/DummyFailing.py +++ /dev/null @@ -1,19 +0,0 @@ -""" -This module defines dummy failing test - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -from lnst.Common.TestsCommon import TestGeneric - -class DummyFailing(TestGeneric): - def run(self): - res_data = {"msg": "what else did you expect?"} - return self.set_fail(res_data) diff --git a/test_modules/LinkNeg.py b/test_modules/LinkNeg.py deleted file mode 100644 index 97bcf4c..0000000 --- a/test_modules/LinkNeg.py +++ /dev/null @@ -1,59 +0,0 @@ -""" -This module defines the link negotiation test -""" - -__author__ = """ -idosch@mellanox.com (Ido Schimmel) -""" - -import logging -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.Utils import bool_it -from lnst.Common.ExecCmd import exec_cmd -from pyroute2 import IPDB - - -class LinkNeg(TestGeneric): - def get_speed(self, iface): - data_stdout = exec_cmd("ethtool %s" % iface)[0] - match = re.search('Speed: ([0-9]*)', data_stdout) - return 0 if match is None else int(match.group(1)) - - def _cb(self, ipdb, msg, action): - if action == 'RTM_NEWLINK': - self.oper_state = msg.get_attr('IFLA_OPERSTATE', '') - - def run(self): - logging.info('Started LinkNeg...') - iface = self.get_mopt('iface') - state = bool_it(self.get_mopt('state')) - admin_speed = self.get_opt('speed', default=0) - timeout = self.get_opt('timeout', default=10) - - ip = IPDB() - self.oper_state = ip.interfaces[iface]['operstate'] - wd = ip.watchdog(ifname=iface) - cuid = ip.register_callback(self._cb) - - wd.wait(timeout=timeout) - ip.unregister_callback(cuid) - ip.release() - - admin_state = 'UP' if state else 'DOWN' - oper_state = self.oper_state - - if admin_state == oper_state and admin_speed: - oper_speed = self.get_speed(iface) - else: - oper_speed = 0 - - res_data = {'admin_state': admin_state, 'oper_state': oper_state} - if admin_speed: - res_data['admin_speed'] = "%s Mb/s" % admin_speed - res_data['oper_speed'] = "%s Mb/s" % oper_speed - - if admin_state == oper_state and admin_speed == oper_speed: - self.set_pass(res_data) - else: - self.set_fail(res_data) diff --git a/test_modules/Multicast.py b/test_modules/Multicast.py deleted file mode 100644 index b366c9b..0000000 --- a/test_modules/Multicast.py +++ /dev/null @@ -1,134 +0,0 @@ -""" -Wrapper for executing the multicast test tools in LNST - -Copyright 2012 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -rpazdera@redhat.com (Radek Pazdera) -""" - -import logging -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.NetTestCommand import CommandException -from lnst.Common.ExecCmd import exec_cmd - -class Multicast(TestGeneric): - """ Wrapper for executing the multicast test tools in LNST - - Running this test executes specified test setup from - multicast tools and evaluates the results. The behavior - is defined entirely by behavior of the selected setup. - - """ - - _conditions = {} - - @staticmethod - def _remove_mask(address_in_string): - """ Remove mask suffix from the IP address """ - if address_in_string != None: - return address_in_string.split('/')[0] - else: - return address_in_string - - def _compose_cmd(self): - """ Setup a command from the recipe options """ - cmd = "" - opts = {} - - setup = self.get_mopt("setup") - opts["multicast_address"] = self._remove_mask(self.get_opt("address")) - opts["port"] = self.get_opt("port") - opts["interface"] = self._remove_mask(self.get_opt("interface")) - opts["duration"] = self.get_opt("duration") - - # sender-specific - opts["loop"] = self.get_opt("loop") - opts["ttl"] = self.get_opt("ttl") - opts["delay"] = self.get_opt("delay") - - # receiver-specific - opts["source_address"] = self._remove_mask(self.get_opt("source")) - - # igmp-specific - opts["query_type"] = self.get_opt("query_type") - opts["dest_address"] = self.get_opt("dest_address") - opts["max_resp_time"] = self.get_opt("max_resp_time") - - cmd = "./{0} ".format(setup) - - for optname, optval in opts.iteritems(): - if optval != None: - cmd += "--{0} "{1}" ".format(optname, optval) - - return cmd - - def _evaluate_result(self, name, value): - """ Check if the result meets required conditions """ - if name in self._conditions: - try: - float(value) - except ValueError: - value = '"' + value + '"' - - result = eval(value + self._conditions[name]) - logging.info("Condition evaluated {2}: {0}{1}".format(name, - self._conditions[name], str(result))) - - return result - else: - return True - - def _prepare_conditions(self): - """ Search for var names in conditions """ - varname_r = r"[a-zA-Z_][a-zA-Z0-9_]*" - - conds = self.get_multi_opt("condition") - logging.debug(conds) - for cond in conds: - if cond == None: - continue - logging.debug(cond) - match = re.match(varname_r, cond) - if match: - name = match.group(0) - self._conditions[name] = cond.replace(name, "") - else: - raise CommandException(self) - - - def run(self): - self._prepare_conditions() - - setup_name = self.get_mopt("setup") - logging.info("Started Multicast test setup {0}".format(setup_name)) - - cmd = self._compose_cmd() - data_stdout = self.exec_from("multicast", cmd, die_on_err=False, - log_outputs=False)[0] - - res = {} - - # line format matches name=value pairs with optional - # double quotes around the value - line_format_r = r"([a-zA-Z0-9_ -.]+)="?([a-zA-Z0-9_ ]*)"?" - - for line in data_stdout.split("\n"): - match = re.search(line_format_r, line) - if match: - name = match.group(1).strip() - value = match.group(2).strip() - - logging.info("Test result: {0} = {1}".format(name, value)) - - name = name.replace(' ', '_') - res[name] = value - if not self._evaluate_result(name, value): - res["msg"] = "Conditions not met!" - return self.set_fail(res) - - return self.set_pass(res) diff --git a/test_modules/NetCat.py b/test_modules/NetCat.py deleted file mode 100644 index ffa4c9f..0000000 --- a/test_modules/NetCat.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -This module defines netcat stream test - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jtluka@redhat.com (Jan Tluka) -""" - -import re -import time -import logging -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ShellProcess import ShellProcess - -class NetCat(TestGeneric): - def _get_stream(self): - return self.get_opt("stream", default="tcp") - - def _compose_nc_cmd(self): - cmd = "yes | nc -v" - - if self._get_stream() == "udp": - cmd += " -u" - - ipv = self.get_opt("ipv") # IP protocol version - 4 or 6 - if ipv: - cmd += " -%s" % ipv - - addr = self.get_mopt("addr", opt_type="addr") - port = self.get_mopt("port") - cmd += " %s %s" % (addr, port) - - return cmd - - def _compose_tcpdump_cmd(self): - cmd = ("tcpdump -c 10 -i any %s port %s and host %s" % - (self._get_stream(), - self.get_mopt("port"), - self.get_mopt("addr", opt_type="addr"))) - return cmd - - def run(self): - nc = ShellProcess(self._compose_nc_cmd()) - - # check whether anything is being sent over the line - td = ShellProcess(self._compose_tcpdump_cmd()) - - try: - td.read_until_output_matches("10 packets captured", timeout=5) - except ShellProcess.ProcessTerminatedError: - res_data = {"msg": "tcpdump process died unexpectedly!"} - return self.set_fail(res_data) - except ShellProcess.ProcessTimeoutError: - res_data = {"msg": "No stream detected!"} - return self.set_fail(res_data) - - td.kill() - - duration = self.get_opt("duration", default=30) - time.sleep(duration) - - nc.kill() - - logging.info("nc stream with duration of %s secs" % duration) - return self.set_pass() diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py deleted file mode 100644 index 0c3c8d0..0000000 --- a/test_modules/Netperf.py +++ /dev/null @@ -1,579 +0,0 @@ -""" -Netperf test module -""" - -__author__ = """ -jprochaz@redhat.com (Jiri Prochazka) -""" - -import logging -import errno -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ShellProcess import ShellProcess -from lnst.Common.Utils import std_deviation, is_installed, int_it - -class Netperf(TestGeneric): - - supported_tests = ["TCP_STREAM", "TCP_RR", "UDP_STREAM", "UDP_RR", - "SCTP_STREAM", "SCTP_STREAM_MANY", "SCTP_RR"] - - omni_tests = ["TCP_STREAM", "TCP_RR", "UDP_STREAM", "UDP_RR"] - - def __init__(self, command): - super(Netperf, self).__init__(command) - - self._role = self.get_mopt("role") - - if self._role == "client": - self._netperf_server = self.get_mopt("netperf_server", - opt_type="addr") - - self._netperf_opts = self.get_opt("netperf_opts") - self._duration = self.get_opt("duration") - self._port = self.get_opt("port") - self._testname = self.get_opt("testname", default="TCP_STREAM") - self._testoptions = self.get_opt("testoptions") - self._confidence = self.get_opt("confidence") - self._bind = self.get_opt("bind", opt_type="addr") - self._cpu_util = self.get_opt("cpu_util") - self._num_parallel = int(self.get_opt("num_parallel", default=1)) - self._runs = self.get_opt("runs", default=1) - self._debug = int_it(self.get_opt("debug", default=0)) - - self._threshold = self._parse_threshold(self.get_opt("threshold")) - self._threshold_deviation = self._parse_threshold( - self.get_opt("threshold_deviation")) - if self._threshold_deviation is None: - self._threshold_deviation = {"rate" : 0.0, - "unit" : "bps"} - - if self._threshold is not None: - rate = self._threshold["rate"] - deviation = self._threshold_deviation["rate"] - self._threshold_interval = (rate - deviation, - rate + deviation) - else: - self._threshold_interval = None - - self._max_deviation = self._parse_max_deviation( - self.get_opt("max_deviation", default=None)) - - def _is_omni(self): - return self._testname in self.omni_tests - - def _compose_cmd(self): - """ - composes commands for netperf and netserver based on xml recipe - """ - if self._role == "client": - cmd = "netperf -H %s -f k" % self._netperf_server - if self._is_omni(): - # -P 0 disables banner header of output - cmd += " -P 0" - if self._bind is not None: - """ - application is bound to this address - """ - cmd += " -L %s" % self._bind - if self._port is not None: - """ - client connects on this port - """ - cmd += " -p %s" % self._port - if self._duration is not None: - """ - test will last this duration - """ - cmd += " -l %s" % self._duration - if self._testname is not None: - """ - test that will be performed - """ - if self._testname not in self.supported_tests: - logging.warning("Only TCP_STREAM, TCP_RR, UDP_STREAM, " - "UDP_RR, SCTP_STREAM, SCTP_STREAM_MANY and SCTP_RR tests " - "are now officialy supported by LNST. You " - "can use other tests, but test result may not be correct.") - cmd += " -t %s" % self._testname - - if self._confidence is not None and self._num_parallel <= 1: - """ - confidence level that Netperf should try to achieve - """ - cmd += " -I %s" % self._confidence - if self._runs >= 3: - cmd += " -i %d,%d" % (self._runs, self._runs) - self._runs = 1 - - if self._cpu_util is not None: - if self._cpu_util.lower() == "both": - cmd += " -c -C" - elif self._cpu_util.lower() == "local": - cmd += " -c" - elif self._cpu_util.lower() == "remote": - cmd += " -C" - - if self._debug > 0: - cmd += " -%s" % ('d' * self._debug) - - if self._netperf_opts is not None: - """ - custom options for netperf - """ - cmd += " %s" % self._netperf_opts - - if self._num_parallel > 1: - """ - wait 1 second before starting the data transfer - taken from the super_netperf script, can be removed if it - doesn't make sense - """ - cmd += " -s 1" - - # Print only relevant output - if self._is_omni(): - cmd += ' -- -k "THROUGHPUT, LOCAL_CPU_UTIL, REMOTE_CPU_UTIL, CONFIDENCE_LEVEL, THROUGHPUT_CONFID"' - - if self._testoptions: - if self._is_omni(): - cmd += " %s" % self._testoptions - else: - cmd += " -- %s" % self._testoptions - - elif self._role == "server": - cmd = "netserver -D" - if self._bind is not None: - """ - server is bound to this address - """ - cmd += " -L %s" % self._bind - if self._port is not None: - """ - server listens on this port - """ - cmd += " -p %s" % self._port - if self._netperf_opts is not None: - """ - custom options for netperf - """ - cmd += " %s" % self._netperf_opts - return cmd - - def _parse_output(self, output): - res_val = None - - if self._is_omni(): - res_val = self._parse_omni_output(output) - else: - res_val = self._parse_non_omni_output(output) - - if self._confidence is not None: - confidence = self._parse_confidence(output) - res_val["confidence"] = confidence - - return res_val - - def _parse_omni_output(self, output): - res_val = {} - - pattern_throughput = "THROUGHPUT=(\d+.\d+)" - throughput = re.search(pattern_throughput, output) - - if throughput is None: - rate_in_kb = 0.0 - else: - rate_in_kb = float(throughput.group(1)) - - res_val["rate"] = rate_in_kb*1000 - res_val["unit"] = "bps" - - if self._cpu_util is not None: - if self._cpu_util == "local" or self._cpu_util == "both": - pattern_loc_cpu_util = "LOCAL_CPU_UTIL=([-]?\d+.\d+)" - loc_cpu_util = re.search(pattern_loc_cpu_util, output) - res_val["LOCAL_CPU_UTIL"] = float(loc_cpu_util.group(1)) - - if self._cpu_util == "remote" or self._cpu_util == "both": - pattern_rem_cpu_util = "REMOTE_CPU_UTIL=([-]?\d+.\d+)" - rem_cpu_util = re.search(pattern_rem_cpu_util, output) - res_val["REMOTE_CPU_UTIL"] = float(rem_cpu_util.group(1)) - - return res_val - - def _parse_non_omni_output(self, output): - res_val = {} - - # pattern for SCTP streams and other tests - # decimal decimal decimal float (float) - pattern = "\d+\s+\d+\s+\d+\s+\d+.\d+\s+(\d+(?:.\d+){0,1})" - if self._cpu_util: - # cpu utilization data in format: float float - pattern += "\s+(\d+(?:.\d+){0,1})\s+(\d+(?:.\d+){0,1})" - - r2 = re.search(pattern, output.lower()) - - if r2 is None: - rate_in_kb = 0.0 - else: - rate_in_kb = float(r2.group(1)) - if self._cpu_util: - res_val["LOCAL_CPU_UTIL"] = float(r2.group(2)) - res_val["REMOTE_CPU_UTIL"] = float(r2.group(3)) - - res_val["rate"] = rate_in_kb*1000 - res_val["unit"] = "bps" - - return res_val - - def _parse_confidence(self, output): - if self._is_omni(): - return self._parse_confidence_omni(output) - else: - return self._parse_confidence_non_omni(output) - - def _parse_confidence_omni(self, output): - pattern_throughput_confid = "THROUGHPUT_CONFID=([-]?\d+.\d+)" - pattern_confidence_level = "CONFIDENCE_LEVEL=(\d+)" - - throughput_confid = re.search(pattern_throughput_confid, output) - confidence_level = re.search(pattern_confidence_level, output) - - if throughput_confid is not None and confidence_level is not None: - throughput_confid = float(throughput_confid.group(1)) - confidence_level = int(confidence_level.group(1)) - real_confidence = (confidence_level, throughput_confid/2) - return real_confidence - else: - return (0, 0.0) - - def _parse_confidence_non_omni(self, output): - normal_pattern = r'+/-(\d+.\d*)% @ (\d+)% conf.' - warning_pattern = r'!!! Confidence intervals: Throughput\s+: (\d+.\d*)%' - normal_confidence = re.search(normal_pattern, output) - warning_confidence = re.search(warning_pattern, output) - - if normal_confidence is None: - logging.error("Failed to parse confidence!!") - return (0, 0.0) - - if warning_confidence is None: - real_confidence = (float(normal_confidence.group(2)), - float(normal_confidence.group(1))) - else: - real_confidence = (float(normal_confidence.group(2)), - float(warning_confidence.group(1))/2) - - return real_confidence - - def _parse_threshold(self, threshold): - res_data = {} - - if threshold is None: - return None - # pattern for threshold - # group(1) ... threshold value - # group(3) ... threshold units - # group(4) ... bytes/bits - if (self._testname == "TCP_STREAM" or - self._testname == "UDP_STREAM" or - self._testname == "SCTP_STREAM" or - self._testname == "SCTP_STREAM_MANY"): - pattern_stream = "(\d*(.\d*)?)\s*([ kmgtKMGT])(bits|bytes)/sec" - r1 = re.search(pattern_stream, threshold) - if r1 is None: - res_data["msg"] = "Invalid unit type in the "\ - "throughput option" - return (False, res_data) - threshold_rate = float(r1.group(1)) - threshold_unit_size = r1.group(3) - threshold_unit_type = r1.group(4) - if threshold_unit_size == 'k': - threshold_rate *= 1000 - elif threshold_unit_size == 'K': - threshold_rate *= 1024 - elif threshold_unit_size == 'm': - threshold_rate *= 1000*1000 - elif threshold_unit_size == 'M': - threshold_rate *= 1024*1024 - elif threshold_unit_size == 'g': - threshold_rate *= 1000*1000*1000 - elif threshold_unit_size == 'G': - threshold_rate *= 1024*1024*1024 - elif threshold_unit_size == 't': - threshold_rate *= 1000 * 1000 * 1000 * 1000 - elif threshold_unit_size == 'T': - threshold_rate *= 1024 * 1024 * 1024 * 1024 - if threshold_unit_type == "bytes": - threshold_rate *= 8 - threshold_unit_type = "bps" - elif (self._testname == "TCP_RR" or self._testname == "UDP_RR" or - self._testname == "SCTP_RR"): - pattern_rr = "(\d*(.\d*)?)\s*trans./sec" - r1 = re.search(pattern_rr, threshold.lower()) - if r1 is None: - res_data["msg"] = "Invalid unit type in the "\ - "throughput option" - return (False, res_data) - threshold_rate = float(r1.group(1)) - threshold_unit_type = "tps" - - return {"rate": threshold_rate, - "unit": threshold_unit_type} - - def _parse_max_deviation(self, deviation): - if deviation is None: - return None - percentual_deviation = r"(\d+(.\d+)?)\s*%" - match = re.match(percentual_deviation, deviation) - if match: - return {"type": "percent", - "value": float(match.group(1))} - else: - val = self._parse_threshold(deviation) - if val is not None: - return {"type": "absolute", - "value": val} - return None - - def _sum_results(self, first, second): - result = {} - - #add rates - if first["unit"] == second["unit"]: - result["unit"] = first["unit"] - result["rate"] = first["rate"] + second["rate"] - - # netperf measures the complete cpu utilization of the machine, - # so both second and first should be +- the same number - if "LOCAL_CPU_UTIL" in first and "LOCAL_CPU_UTIL" in second: - result["LOCAL_CPU_UTIL"] = first["LOCAL_CPU_UTIL"] - - if "REMOTE_CPU_UTIL" in first and "REMOTE_CPU_UTIL" in second: - result["REMOTE_CPU_UTIL"] = first["REMOTE_CPU_UTIL"] - - #ignoring confidence because it doesn't make sense to sum those - return result - - def _run_server(self, cmd): - logging.debug("running as server...") - server = ShellProcess(cmd) - try: - server.wait() - except OSError as e: - if e.errno == errno.EINTR: - server.kill() - - def _pretty_rate(self, rate, unit=None): - pretty_rate = {} - if unit is None: - if rate < 1000: - pretty_rate["unit"] = "bits/sec" - pretty_rate["rate"] = rate - elif rate < 1000 * 1000: - pretty_rate["unit"] = "kbits/sec" - pretty_rate["rate"] = rate / 1000 - elif rate < 1000 * 1000 * 1000: - pretty_rate["unit"] = "mbits/sec" - pretty_rate["rate"] = rate / (1000 * 1000) - elif rate < 1000 * 1000 * 1000 * 1000: - pretty_rate["unit"] = "gbits/sec" - pretty_rate["rate"] = rate / (1000 * 1000 * 1000) - elif rate < 1000 * 1000 * 1000 * 1000 * 1000: - pretty_rate["unit"] = "tbits/sec" - pretty_rate["rate"] = rate / (1000 * 1000 * 1000 * 1000) - else: - if unit == "bits/sec": - pretty_rate["unit"] = "bits/sec" - pretty_rate["rate"] = rate - elif unit == "Kbits/sec": - pretty_rate["unit"] = "Kbits/sec" - pretty_rate["rate"] = rate / 1024 - elif unit == "kbits/sec": - pretty_rate["unit"] = "kbits/sec" - pretty_rate["rate"] = rate / 1000 - elif unit == "Mbits/sec": - pretty_rate["unit"] = "Mbits/sec" - pretty_rate["rate"] = rate / (1024 * 1024) - elif unit == "mbits/sec": - pretty_rate["unit"] = "mbits/sec" - pretty_rate["rate"] = rate / (1000 * 1000) - elif unit == "Gbits/sec": - pretty_rate["unit"] = "Gbits/sec" - pretty_rate["rate"] = rate / (1024 * 1024 * 1024) - elif unit == "gbits/sec": - pretty_rate["unit"] = "gbits/sec" - pretty_rate["rate"] = rate / (1000 * 1000 * 1000) - elif unit == "Tbits/sec": - pretty_rate["unit"] = "Tbits/sec" - pretty_rate["rate"] = rate / (1024 * 1024 * 1024 * 1024) - elif unit == "tbits/sec": - pretty_rate["unit"] = "tbits/sec" - pretty_rate["rate"] = rate / (1000 * 1000 * 1000 * 1000) - - return pretty_rate - - def _run_client(self, cmd): - logging.debug("running as client...") - - res_data = {} - res_data["testname"] = self._testname - - rv = 0 - results = [] - rates = [] - for i in range(1, self._runs+1): - if self._runs > 1: - logging.info("Netperf starting run %d" % i) - clients = [] - client_results = [] - for i in range(0, self._num_parallel): - clients.append(ShellProcess(cmd)) - - for client in clients: - ret_code = None - try: - ret_code = client.wait() - rv += ret_code - except OSError as e: - if e.errno == errno.EINTR: - client.kill() - - output = client.read_nonblocking() - logging.debug(output) - - if ret_code is not None and ret_code == 0: - client_results.append(self._parse_output(output)) - - if len(client_results) > 0: - #accumulate all the parallel results into one - result = client_results[0] - for res in client_results[1:]: - result = self._sum_results(result, res) - - results.append(result) - rates.append(results[-1]["rate"]) - - if results > 1: - res_data["results"] = results - - if len(rates) > 0: - rate = sum(rates)/len(rates) - else: - rate = 0.0 - - if len(rates) > 1: - # setting deviation to 2xstd_deviation because of the 68-95-99.7 - # rule this seems comparable to the -I 99 netperf setting - res_data["std_deviation"] = std_deviation(rates) - rate_deviation = 2*res_data["std_deviation"] - elif len(rates) == 1 and self._confidence is not None: - result = results[0] - rate_deviation = rate * (float(result["confidence"][1]) / 100) - else: - rate_deviation = 0.0 - - res_data["rate"] = rate - res_data["rate_deviation"] = rate_deviation - - rate_pretty = self._pretty_rate(rate) - rate_dev_pretty = self._pretty_rate(rate_deviation, unit=rate_pretty["unit"]) - - if rv != 0 and self._runs == 1: - res_data["msg"] = "Could not get performance throughput!" - logging.info(res_data["msg"]) - return (False, res_data) - elif rv != 0 and self._runs > 1: - res_data["msg"] = "At least one of the Netperf runs failed, "\ - "check the logs and result data for more "\ - "information." - logging.info(res_data["msg"]) - return (False, res_data) - - res_val = False - if self._max_deviation is not None: - if self._max_deviation["type"] == "percent": - percentual_deviation = (rate_deviation / rate) * 100 - if percentual_deviation > self._max_deviation["value"]: - res_val = False - res_data["msg"] = "Measured rate %.2f +-%.2f %s has bigger "\ - "deviation than allowed (+-%.2f %%)" %\ - (rate_pretty["rate"], - rate_dev_pretty["rate"], - rate_pretty["unit"], - self._max_deviation["value"]) - return (res_val, res_data) - elif self._max_deviation["type"] == "absolute": - if rate_deviation > self._max_deviation["value"]["rate"]: - pretty_deviation = self._pretty_rate(self._max_deviation["value"]["rate"]) - res_val = False - res_data["msg"] = "Measured rate %.2f +-%.2f %s has bigger "\ - "deviation than allowed (+-%.2f %s)" %\ - (rate_pretty["rate"], - rate_dev_pretty["rate"], - rate_pretty["unit"], - pretty_deviation["rate"], - pretty_deviation["unit"]) - return (res_val, res_data) - if self._threshold_interval is not None: - result_interval = (rate - rate_deviation, - rate + rate_deviation) - - threshold_pretty = self._pretty_rate(self._threshold["rate"]) - threshold_dev_pretty = self._pretty_rate(self._threshold_deviation["rate"], - unit = threshold_pretty["unit"]) - - if self._threshold_interval[0] > result_interval[1]: - res_val = False - res_data["msg"] = "Measured rate %.2f +-%.2f %s is lower "\ - "than threshold %.2f +-%.2f %s" %\ - (rate_pretty["rate"], - rate_dev_pretty["rate"], - rate_pretty["unit"], - threshold_pretty["rate"], - threshold_dev_pretty["rate"], - threshold_pretty["unit"]) - return (res_val, res_data) - else: - res_val = True - res_data["msg"] = "Measured rate %.2f +-%.2f %s is higher "\ - "than threshold %.2f +-%.2f %s" %\ - (rate_pretty["rate"], - rate_dev_pretty["rate"], - rate_pretty["unit"], - threshold_pretty["rate"], - threshold_dev_pretty["rate"], - threshold_pretty["unit"]) - return (res_val, res_data) - else: - if rate > 0.0: - res_val = True - else: - res_val = False - res_data["msg"] = "Measured rate was %.2f +-%.2f %s" %\ - (rate_pretty["rate"], - rate_dev_pretty["rate"], - rate_pretty["unit"]) - return (res_val, res_data) - - def run(self): - cmd = self._compose_cmd() - logging.debug("compiled command: %s" % cmd) - if self._role == "client": - if not is_installed("netperf"): - res_data = {} - res_data["msg"] = "Netperf is not installed on this machine!" - logging.error(res_data["msg"]) - return self.set_fail(res_data) - - (rv, res_data) = self._run_client(cmd) - if rv == False: - return self.set_fail(res_data) - return self.set_pass(res_data) - elif self._role == "server": - if not is_installed("netserver"): - res_data = {} - res_data["msg"] = "Netserver is not installed on this machine!" - logging.error(res_data["msg"]) - return self.set_fail(res_data) - self._run_server(cmd) diff --git a/test_modules/PktCounter.py b/test_modules/PktCounter.py deleted file mode 100644 index 52a1c30..0000000 --- a/test_modules/PktCounter.py +++ /dev/null @@ -1,89 +0,0 @@ -""" -This module defines packet counter implemented by iptables - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import re -import os -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail -from lnst.Common.Utils import bool_it - -class PktCounter(TestGeneric): - def _iptables_exec(self, param_str): - if self._is_ipv6: - cmd = "ip6tables" - else: - cmd = "iptables" - return exec_cmd("%s %s" % (cmd, param_str)) - - def _get_pttr(self, p_proto, p_indev_name, p_protodport): - if self._is_ipv6: - return r'\s*(\d+)\s+\d+\s+%s\s+%s\s+*\s+::/0\s+::/0\s*%s' % (p_proto, p_indev_name, p_protodport) - else: - return r'\s*(\d+)\s+\d+\s+%s\s+--\s+%s\s+*\s+0.0.0.0/0\s+0.0.0.0/0\s*%s' % (p_proto, p_indev_name, p_protodport) - - def _get_pkt_count(self, indev_name, dport, proto): - if indev_name: - p_indev_name = indev_name - else: - p_indev_name = "*" - if proto: - p_proto = proto - if dport: - p_protodport = "%s dpt:%s" % (proto, dport) - else: - p_protodport = "" - else: - p_proto = "all" - p_protodport = "" - pttr = self._get_pttr(p_proto, p_indev_name, p_protodport) - data_stdout = self._iptables_exec("-L -v -x -n")[0] - match = re.search(pttr, data_stdout) - if not match: - return None - return match.groups()[0] - - def run(self): - indev_name = self.get_opt("input_netdev_name") - dport = self.get_opt("dport") - proto = self.get_opt("proto") - ipv6 = self.get_opt("ipv6") - self._is_ipv6 = False - if ipv6 and bool_it(ipv6): - self._is_ipv6 = True - params = "" - if indev_name: - params += " -i %s" % indev_name - - if proto: - params += " -p %s" % proto - - if dport: - params += " --dport %s" % dport - - ''' - Remove all same already existing rules - ''' - while True: - if self._get_pkt_count(indev_name, dport, proto) == None: - break - self._iptables_exec("-D INPUT%s" % params) - - self._iptables_exec("-I INPUT%s" % params) - - self.wait_on_interrupt() - - count = self._get_pkt_count(indev_name, dport, proto) - - self._iptables_exec("-D INPUT%s" % params) - - return self.set_pass(res_data={"pkt_count": count}) diff --git a/test_modules/PktgenTx.py b/test_modules/PktgenTx.py deleted file mode 100644 index cf35b5f..0000000 --- a/test_modules/PktgenTx.py +++ /dev/null @@ -1,93 +0,0 @@ -""" -This module defines pktgen test, Tx side - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import re -import os -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail - -class Pktgen: - def __init__(self, dev): - self._dev = dev - - def set(self, val): - exec_cmd("echo "%s" > %s" % (val, self._dev)) - -class PktgenWorkers: - def __init__(self): - self._current = 0 - self._cpunum = int(os.sysconf('SC_NPROCESSORS_ONLN')) - self._wrkrs = {} - - def _init_current_wrkr(self): - num = self._current - wrkr = Pktgen("/proc/net/pktgen/kpktgend_%d" % (num)) - wrkr.set("rem_device_all") - wrkr.set("max_before_softirq 5000") - self._wrkrs[num] = wrkr - - def _get_wrkr(self): - num = self._current - if not num in self._wrkrs: - self._init_current_wrkr() - wrkr = self._wrkrs[num] - num += 1 - if num == self._cpunum: - num = 0 - self._current = num - return wrkr - - def add_device(self, dev_name): - wrkr = self._get_wrkr() - wrkr.set("add_device %s" % dev_name) - -def pktget_options_merge(pktgen_options, default_pktgen_options): - opts = [re.split('\s+', opt) for opt in pktgen_options] - def_opts = [re.split('\s+', opt) for opt in default_pktgen_options] - res = [] - for def_opt in def_opts: - if not def_opt[0] in [opt[0] for opt in opts]: - res.append(def_opt) - res = res + opts - return [" ".join(opt) for opt in res] - -class PktgenTx(TestGeneric): - def run(self): - dev_names = self.get_multi_mopt("netdev_name") - pktgen_options = self.get_multi_mopt("pktgen_option") - - default_pktgen_options = [ - "count 10000000", - "clone_skb 100000", - "pkt_size 60", - ] - pktgen_options = pktget_options_merge(pktgen_options, - default_pktgen_options) - - exec_cmd("modprobe pktgen") - - pgctl = Pktgen("/proc/net/pktgen/pgctrl") - pgwrkr = PktgenWorkers() - - try: - for dev_name in dev_names: - pgwrkr.add_device(dev_name) - pg = Pktgen("/proc/net/pktgen/%s" % dev_name) - for pktgen_option in pktgen_options: - pg.set(pktgen_option) - pgctl.set("start") - except ExecCmdFail: - res_data = {"msg": "pktgen failed"} - return self.set_fail(res_data) - - return self.set_pass() diff --git a/test_modules/TCPConnection.py b/test_modules/TCPConnection.py deleted file mode 100644 index 43b88a9..0000000 --- a/test_modules/TCPConnection.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -This module defines TCPConnection test, -a python wrapper for LNST's tcp_conn test tool -""" - -__author__ = """ -jtluka@redhat.com (Jan Tluka) -""" - -import re -import errno -import logging -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.Utils import bool_it - -class TCPConnection(TestGeneric): - def run(self): - mode = self.get_mopt("mode") - address = self.get_mopt("address") - portrange = self.get_mopt("portrange") - - continuous = self.get_opt("continuous") - debug = self.get_opt("debug") - ipv6 = self.get_opt("ipv6") - - cmd = "" - if (mode == "server"): - logging.debug("TCPConnection: running as server") - cmd += "./tcp_listen" - elif (mode == "client"): - logging.debug("TCPConnection: running as client") - cmd += "./tcp_connect" - else: - raise Exception("Invalid mode value for TCPConnection test module!") - - cmd += " -a %s -p %s" % (address, portrange) - - if continuous and bool_it(continuous): - cmd += " -c" - - if debug and bool_it(debug): - cmd += " -d" - - if ipv6 and bool_it(ipv6): - cmd += " -6" - - output = self.exec_from("tcp_conn", cmd, die_on_err=False, log_outputs=True)[0] - - logging.debug("TCPConnection done, inspecting logs ...") - - m = None - if (mode == "client"): - m = re.search("made [0-9]* connections", output) - elif (mode == "server"): - m = re.search("handled [0-9]* connections", output) - - if m is None: - return self.set_fail({'msg': "Unexpected error"}) - else: - return self.set_pass({'msg': m.group(0)})
The legacy regression tests heavily depend on the legacy API.
It's much more efficient to build this from scratch than trying to port this to new API.
Signed-off-by: Jan Tluka jtluka@redhat.com --- regression-tests/README.md | 112 ------ regression-tests/env/lnst-ctl.conf | 16 - regression-tests/run-test.sh | 253 -------------- regression-tests/tests/0/desc | 6 - regression-tests/tests/0/run.sh | 24 -- regression-tests/tests/1/desc | 4 - regression-tests/tests/1/recipe.xml | 33 -- regression-tests/tests/1/run.sh | 12 - regression-tests/tests/10/desc | 4 - .../tests/10/prefix-check-taskapi.xml | 33 -- regression-tests/tests/10/prefix-check.py | 15 - regression-tests/tests/10/prefix-check.xml | 44 --- regression-tests/tests/10/run.sh | 39 --- regression-tests/tests/11/desc | 3 - regression-tests/tests/11/recipe.xml | 33 -- regression-tests/tests/11/run.sh | 15 - regression-tests/tests/12/desc | 1 - regression-tests/tests/12/run.sh | 12 - regression-tests/tests/12/sm01.xml | 7 - regression-tests/tests/12/sm02.xml | 7 - regression-tests/tests/12/xinclude-check.xml | 13 - regression-tests/tests/13/desc | 1 - regression-tests/tests/13/run.sh | 22 -- .../tests/13/taskapi-alias-check.py | 9 - .../tests/13/taskapi-alias-check.xml | 38 -- .../tests/13/taskapi-alias-namespace-check.py | 8 - .../13/taskapi-alias-namespace-check.xml | 41 --- regression-tests/tests/14/desc | 3 - regression-tests/tests/14/recipe1.xml | 68 ---- regression-tests/tests/14/recipe2.xml | 79 ----- regression-tests/tests/14/run.sh | 17 - regression-tests/tests/15/desc | 3 - regression-tests/tests/15/recipe.xml | 33 -- regression-tests/tests/15/run.sh | 12 - regression-tests/tests/16/desc | 3 - regression-tests/tests/16/recipe.xml | 37 -- regression-tests/tests/16/run.sh | 14 - regression-tests/tests/17/desc | 3 - regression-tests/tests/17/recipe.xml | 38 -- regression-tests/tests/17/run.sh | 14 - regression-tests/tests/18/desc | 6 - regression-tests/tests/18/recipe.xml | 26 -- regression-tests/tests/18/run.sh | 19 - regression-tests/tests/19/desc | 3 - regression-tests/tests/19/recipe.xml | 17 - regression-tests/tests/19/run.sh | 19 - regression-tests/tests/2/desc | 5 - regression-tests/tests/2/recipe.xml | 74 ---- regression-tests/tests/2/run.sh | 12 - regression-tests/tests/20/desc | 3 - regression-tests/tests/20/recipe1.xml | 47 --- regression-tests/tests/20/recipe2.xml | 31 -- regression-tests/tests/20/run.sh | 20 -- regression-tests/tests/21/desc | 3 - regression-tests/tests/21/lnst-ctl.conf | 3 - regression-tests/tests/21/recipe.xml | 55 --- regression-tests/tests/21/run.sh | 18 - .../tests/21/test_modules/TCPConnection.py | 60 ---- .../tests/21/test_tools/tcp_conn/Makefile | 12 - .../21/test_tools/tcp_conn/lnst-setup.sh | 3 - .../21/test_tools/tcp_conn/tcp_connect.c | 281 --------------- .../tests/21/test_tools/tcp_conn/tcp_listen.c | 330 ------------------ regression-tests/tests/22/desc | 3 - regression-tests/tests/22/lnst-ctl.conf | 2 - regression-tests/tests/22/pool/slave1.xml | 6 - regression-tests/tests/22/pool/slave2.xml | 6 - regression-tests/tests/22/recipe.xml | 26 -- regression-tests/tests/22/run.sh | 18 - regression-tests/tests/23/desc | 3 - regression-tests/tests/23/lnst-ctl.conf | 2 - regression-tests/tests/23/recipe.xml | 42 --- regression-tests/tests/23/run.sh | 19 - .../tests/23/test_modules/IcmpPing.py | 71 ---- regression-tests/tests/24/desc | 6 - regression-tests/tests/24/recipe_fail.xml | 33 -- regression-tests/tests/24/recipe_pass.xml | 33 -- regression-tests/tests/24/run.sh | 22 -- regression-tests/tests/25/desc | 12 - regression-tests/tests/25/recipe1.xml | 44 --- regression-tests/tests/25/recipe2.xml | 53 --- regression-tests/tests/25/recipe3.xml | 28 -- regression-tests/tests/25/run.sh | 27 -- regression-tests/tests/26/desc | 7 - regression-tests/tests/26/recipe1.xml | 46 --- regression-tests/tests/26/recipe2.xml | 46 --- regression-tests/tests/26/run.sh | 24 -- regression-tests/tests/27/desc | 10 - regression-tests/tests/27/recipe1.xml | 32 -- regression-tests/tests/27/recipe2.xml | 32 -- regression-tests/tests/27/recipe3.xml | 31 -- regression-tests/tests/27/recipe4.xml | 31 -- regression-tests/tests/27/recipe5.xml | 32 -- regression-tests/tests/27/recipe6.xml | 30 -- regression-tests/tests/27/recipe7.xml | 30 -- regression-tests/tests/27/recipe8.xml | 32 -- regression-tests/tests/27/run.sh | 48 --- regression-tests/tests/28/desc | 6 - regression-tests/tests/28/recipe1.py | 20 -- regression-tests/tests/28/recipe1.xml | 16 - regression-tests/tests/28/recipe2.py | 18 - regression-tests/tests/28/recipe2.xml | 16 - regression-tests/tests/28/recipe3.py | 11 - regression-tests/tests/28/recipe3.xml | 16 - regression-tests/tests/28/recipe4.py | 15 - regression-tests/tests/28/recipe4.xml | 16 - regression-tests/tests/28/run.sh | 34 -- regression-tests/tests/3/desc | 8 - regression-tests/tests/3/recipe.xml | 21 -- regression-tests/tests/3/run.sh | 12 - regression-tests/tests/4/desc | 3 - regression-tests/tests/4/recipe.xml | 43 --- regression-tests/tests/4/run.sh | 19 - regression-tests/tests/5/desc | 3 - regression-tests/tests/5/recipe.xml | 29 -- regression-tests/tests/5/run.sh | 20 -- regression-tests/tests/6/desc | 4 - regression-tests/tests/6/recipe.xml | 35 -- regression-tests/tests/6/run.sh | 19 - regression-tests/tests/7/desc | 4 - regression-tests/tests/7/recipe.xml | 24 -- regression-tests/tests/7/run.sh | 19 - regression-tests/tests/7/task.py | 23 -- regression-tests/tests/8/desc | 3 - regression-tests/tests/8/recipe.xml | 26 -- regression-tests/tests/8/run.sh | 12 - regression-tests/tests/9/desc | 3 - regression-tests/tests/9/recipe.xml | 24 -- regression-tests/tests/9/run.sh | 12 - regression-tests/tests/9/task.py | 9 - regression-tests/tests/lib.sh | 67 ---- 130 files changed, 3673 deletions(-) delete mode 100644 regression-tests/README.md delete mode 100644 regression-tests/env/lnst-ctl.conf delete mode 100755 regression-tests/run-test.sh delete mode 100644 regression-tests/tests/0/desc delete mode 100755 regression-tests/tests/0/run.sh delete mode 100644 regression-tests/tests/1/desc delete mode 100644 regression-tests/tests/1/recipe.xml delete mode 100755 regression-tests/tests/1/run.sh delete mode 100644 regression-tests/tests/10/desc delete mode 100644 regression-tests/tests/10/prefix-check-taskapi.xml delete mode 100644 regression-tests/tests/10/prefix-check.py delete mode 100644 regression-tests/tests/10/prefix-check.xml delete mode 100755 regression-tests/tests/10/run.sh delete mode 100644 regression-tests/tests/11/desc delete mode 100644 regression-tests/tests/11/recipe.xml delete mode 100755 regression-tests/tests/11/run.sh delete mode 100644 regression-tests/tests/12/desc delete mode 100755 regression-tests/tests/12/run.sh delete mode 100644 regression-tests/tests/12/sm01.xml delete mode 100644 regression-tests/tests/12/sm02.xml delete mode 100644 regression-tests/tests/12/xinclude-check.xml delete mode 100644 regression-tests/tests/13/desc delete mode 100755 regression-tests/tests/13/run.sh delete mode 100644 regression-tests/tests/13/taskapi-alias-check.py delete mode 100644 regression-tests/tests/13/taskapi-alias-check.xml delete mode 100644 regression-tests/tests/13/taskapi-alias-namespace-check.py delete mode 100644 regression-tests/tests/13/taskapi-alias-namespace-check.xml delete mode 100644 regression-tests/tests/14/desc delete mode 100644 regression-tests/tests/14/recipe1.xml delete mode 100644 regression-tests/tests/14/recipe2.xml delete mode 100755 regression-tests/tests/14/run.sh delete mode 100644 regression-tests/tests/15/desc delete mode 100644 regression-tests/tests/15/recipe.xml delete mode 100755 regression-tests/tests/15/run.sh delete mode 100644 regression-tests/tests/16/desc delete mode 100644 regression-tests/tests/16/recipe.xml delete mode 100755 regression-tests/tests/16/run.sh delete mode 100644 regression-tests/tests/17/desc delete mode 100644 regression-tests/tests/17/recipe.xml delete mode 100755 regression-tests/tests/17/run.sh delete mode 100644 regression-tests/tests/18/desc delete mode 100644 regression-tests/tests/18/recipe.xml delete mode 100755 regression-tests/tests/18/run.sh delete mode 100644 regression-tests/tests/19/desc delete mode 100644 regression-tests/tests/19/recipe.xml delete mode 100755 regression-tests/tests/19/run.sh delete mode 100644 regression-tests/tests/2/desc delete mode 100644 regression-tests/tests/2/recipe.xml delete mode 100755 regression-tests/tests/2/run.sh delete mode 100644 regression-tests/tests/20/desc delete mode 100644 regression-tests/tests/20/recipe1.xml delete mode 100644 regression-tests/tests/20/recipe2.xml delete mode 100755 regression-tests/tests/20/run.sh delete mode 100644 regression-tests/tests/21/desc delete mode 100644 regression-tests/tests/21/lnst-ctl.conf delete mode 100644 regression-tests/tests/21/recipe.xml delete mode 100755 regression-tests/tests/21/run.sh delete mode 100644 regression-tests/tests/21/test_modules/TCPConnection.py delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/Makefile delete mode 100755 regression-tests/tests/21/test_tools/tcp_conn/lnst-setup.sh delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/tcp_connect.c delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/tcp_listen.c delete mode 100644 regression-tests/tests/22/desc delete mode 100644 regression-tests/tests/22/lnst-ctl.conf delete mode 100644 regression-tests/tests/22/pool/slave1.xml delete mode 100644 regression-tests/tests/22/pool/slave2.xml delete mode 100644 regression-tests/tests/22/recipe.xml delete mode 100755 regression-tests/tests/22/run.sh delete mode 100644 regression-tests/tests/23/desc delete mode 100644 regression-tests/tests/23/lnst-ctl.conf delete mode 100644 regression-tests/tests/23/recipe.xml delete mode 100755 regression-tests/tests/23/run.sh delete mode 100644 regression-tests/tests/23/test_modules/IcmpPing.py delete mode 100644 regression-tests/tests/24/desc delete mode 100644 regression-tests/tests/24/recipe_fail.xml delete mode 100644 regression-tests/tests/24/recipe_pass.xml delete mode 100755 regression-tests/tests/24/run.sh delete mode 100644 regression-tests/tests/25/desc delete mode 100644 regression-tests/tests/25/recipe1.xml delete mode 100644 regression-tests/tests/25/recipe2.xml delete mode 100644 regression-tests/tests/25/recipe3.xml delete mode 100755 regression-tests/tests/25/run.sh delete mode 100644 regression-tests/tests/26/desc delete mode 100644 regression-tests/tests/26/recipe1.xml delete mode 100644 regression-tests/tests/26/recipe2.xml delete mode 100755 regression-tests/tests/26/run.sh delete mode 100644 regression-tests/tests/27/desc delete mode 100644 regression-tests/tests/27/recipe1.xml delete mode 100644 regression-tests/tests/27/recipe2.xml delete mode 100644 regression-tests/tests/27/recipe3.xml delete mode 100644 regression-tests/tests/27/recipe4.xml delete mode 100644 regression-tests/tests/27/recipe5.xml delete mode 100644 regression-tests/tests/27/recipe6.xml delete mode 100644 regression-tests/tests/27/recipe7.xml delete mode 100644 regression-tests/tests/27/recipe8.xml delete mode 100755 regression-tests/tests/27/run.sh delete mode 100644 regression-tests/tests/28/desc delete mode 100644 regression-tests/tests/28/recipe1.py delete mode 100644 regression-tests/tests/28/recipe1.xml delete mode 100644 regression-tests/tests/28/recipe2.py delete mode 100644 regression-tests/tests/28/recipe2.xml delete mode 100644 regression-tests/tests/28/recipe3.py delete mode 100644 regression-tests/tests/28/recipe3.xml delete mode 100644 regression-tests/tests/28/recipe4.py delete mode 100644 regression-tests/tests/28/recipe4.xml delete mode 100755 regression-tests/tests/28/run.sh delete mode 100644 regression-tests/tests/3/desc delete mode 100644 regression-tests/tests/3/recipe.xml delete mode 100755 regression-tests/tests/3/run.sh delete mode 100644 regression-tests/tests/4/desc delete mode 100644 regression-tests/tests/4/recipe.xml delete mode 100755 regression-tests/tests/4/run.sh delete mode 100644 regression-tests/tests/5/desc delete mode 100644 regression-tests/tests/5/recipe.xml delete mode 100755 regression-tests/tests/5/run.sh delete mode 100644 regression-tests/tests/6/desc delete mode 100644 regression-tests/tests/6/recipe.xml delete mode 100755 regression-tests/tests/6/run.sh delete mode 100644 regression-tests/tests/7/desc delete mode 100644 regression-tests/tests/7/recipe.xml delete mode 100755 regression-tests/tests/7/run.sh delete mode 100644 regression-tests/tests/7/task.py delete mode 100644 regression-tests/tests/8/desc delete mode 100644 regression-tests/tests/8/recipe.xml delete mode 100755 regression-tests/tests/8/run.sh delete mode 100644 regression-tests/tests/9/desc delete mode 100644 regression-tests/tests/9/recipe.xml delete mode 100755 regression-tests/tests/9/run.sh delete mode 100644 regression-tests/tests/9/task.py delete mode 100644 regression-tests/tests/lib.sh
diff --git a/regression-tests/README.md b/regression-tests/README.md deleted file mode 100644 index 7798333..0000000 --- a/regression-tests/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# lnst-tests - -**lnst-tests** is a regression test suite for the Linux Network Stack Test -Project. It contains a number of test cases and scenario to verify LNST -before releases and also to catch bugs and regressions. - -In case you're interested in contributing to our project you should be -interested in this page as well since we won't be accepting contributions that -break any of our tests. - -Currently there are two sets of tests that reside in our repository: -* smoke tests, located in ```recipes/smoke/``` -* regression tests, located in ```regression-tests/``` - -It is important to note that all of these tests were created to test LNST -functionality for bugs. For this reason we assume that when running these -tests, they're being run on stable systems. - -## Required Non-default Packages on slave machines - -* rsync -* python-lxml (usually installed by default) -* python-pyroute2 (available in fedora repositories, epel6 and epel7) -* tar -* bzip2 -* make -* gcc - -## Smoke tests - -Smoke tests were created to cover a wide area of basic LNST functionality, but -avoid testing for more complex/in-depth bugs. - -As was mentioned before, smoke tests are located in the ```recipes/smoke/``` -directory. Here you can find a subdirectory ```lib/``` and a python script -```generate-recipes.py```. The ```lib/``` directory contains 4 types of files: -* ```recipe-temp.xml``` recipe template file, -* ```conf-*.xml``` network configuration files, -* ```task-*.xml``` task definition files, -* ```variables.conf``` file. - -The generate-recipes script loads the remplate file and fills it with two -configuration files and all the task files to create recipes for all possible -configuration combinations. The generated recipes are placed in the -```recipes/smoke/tests/``` directory. - -Finally the variables file defines values for some variables (e.g. result of a -command), that are dependent on the combination of the configuration files. -When a recipe file is generated these variables are replaced with their -respective values. - -To run these recipes you need to have 2 machines available in the pool you've -configured and you can use the following command: -``` -lnst-ctl -d run recipes/smoke/tests/* -``` - -## Regression tests - -Regression tests were created as a means to test for specific bugs that we have -already fixed. Our policy is to add a new regression test every time we fix a -more serious bug, however this isn't always possible due to different reasons. -If you find a bug in LNST and you want to contribute a patch that fixes it, it -is **highly recommended** to also create a regression test. - -The directory structure for regression tests is as follows: -* ```regression-tests/``` is the main directory where everything related to - regression tests is located. -* ```regression-tests/env/``` contains a LNST environment that is used by the - regression tests. It contains a lnst-ctl configuration file and you're - expected to create a machine pool directory here. -* ```regression-tests/tests/``` contains all the regression tests we currently - have, isolated in their own directories that are numbered. You can also find - the ```lib.sh``` file which contains definitions of some useful functions. -* ```regression-tests/tests/<test_number>/``` represents a regression test. It - contains everything the tests needs. You can always find at least 2 files - here: the ```run.sh``` script that executes the test, and ```desc``` which is - a text file that contains the description of the test. -* ```regression-tests/run-test.sh``` is the script that controls the execution - of regression tests. - -Before running the regression tests, you need to prepare the environment. As -was mentioned the ```env/``` directory already contains the ```lnst-ctl.conf``` -file. In addition to that you are also expected to create a machine pool -directory ```regression-tests/env/pool/``` and fill it with at least two slave -machine description files that should be used. Alternatively you can also use -your local configuration in ```~/.lnst/```, to do this you just need to use the -**-c** argument of the run-test.sh script. - -In addition to this you need to ensure that the slave machines are running and -you have configured automatic ssh access to them. This is all the preparation -you need to do to run the regression tests, the ```run-test.sh``` script will -take care of synchronizing LNST to all the necessary machines, running -lnst-slave and lnst-ctl processes and cleaning them up in the end as well. - -When it comes to running the tests you first need to change to the -```regression-tests``` directory and from here you have several options -depending on how you run the ```run-test.sh``` script. -```sh -Usage: ./run-test.sh [-c] [-r revision] [-l logdir] [-t list_of_tests] [-u url] [-n] - -r revision Test a specific git branch/rev/tag - Note: ignored when -s is used - -l logdir Save test results to a directory - -t list_of_tests Run only these tests - Example: -t 0,1,2 will run tests 0, 1, and 2 - -n Disable use of NetworkManager on slavemachines - Note: enabled by default - -u url URL pointing to LNST repository that should be used - Note: git clone and checkout by default - -s use rsync instead of git - -c use user configuration -``` diff --git a/regression-tests/env/lnst-ctl.conf b/regression-tests/env/lnst-ctl.conf deleted file mode 100644 index 12db8c9..0000000 --- a/regression-tests/env/lnst-ctl.conf +++ /dev/null @@ -1,16 +0,0 @@ -[environment] -mac_pool_range = 52:54:01:00:00:01 52:54:01:FF:FF:FF -rpcport = 9999 -test_tool_dirs = ./test_tools -test_module_dirs = ./test_modules -log_dir = ./Logs -xslt_url = http://www.lnst-project.org/files/result_xslt/xml_to_html.xsl -allow_virtual = True - -[colours] -faded = extended(242) default 0 -info = extended(228) default 1 -warning = extended(208) default 1 - -[pools] -lnst = ./pool/ diff --git a/regression-tests/run-test.sh b/regression-tests/run-test.sh deleted file mode 100755 index 02fa126..0000000 --- a/regression-tests/run-test.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/bash - -function get_hostname -{ - sed -n "s/.*param name=['"]hostname['"] value=['"]([^'"]+)['"].*/\1/p" $1 -} - -function log -{ - if [ -n "$log_dir" ]; then - echo "$1" | tee -a "$log_dir/log" - else - echo "$1" - fi -} - -function logn -{ - if [ -n "$log_dir" ]; then - echo -n "$1" | tee -a "$log_dir/log" - else - echo -n "$1" - fi -} - -function logtest -{ - if [ -n "$log_dir" ]; then - log_path="$log_dir/$test_dir" - mkdir -p "$log_path" - (tee $log_path/stdout.log) 3>&1 1>&2 2>&3 | tee $log_path/stderr.log - else - cat - fi -} - -function print_separator -{ - log "--------------------------------------------------------------------------------" -} - -function usage -{ - echo "Usage: $0 [-c] [-r revision] [-l logdir] [-t list_of_tests] [-u url] [-n]" - echo " -r revision Test a specific git branch/rev/tag" - echo " Note: ignored when -s is used" - echo " -l logdir Save test results to a directory" - echo " -t list_of_tests Run only these tests" - echo " Example: -t 0,1,2 will run tests 0, 1, and 2" - echo " -n Disable use of NetworkManager on slavemachines" - echo " Note: enabled by default" - echo " -u url URL pointing to LNST repository that should be used" - echo " Note: git clone and checkout by default" - echo " -s use rsync instead of git" - echo " -c use user configuration" - exit 0 -} - -function get_pool_dirs -{ - if [ "$use_user_conf" = "true" ]; then - command lnst-ctl --dump-pools 2>/dev/null | cut -d = -f2 - else - command lnst-ctl -C $repo/lnst-ctl.conf --dump-pools 2>/dev/null | - cut -d = -f2 - fi -} - -# --- - -#default repository url -url="../" -use_git=true -export use_user_conf="false" - -while getopts "chlr:t:g:ns" OPTION -do - case $OPTION in - c) use_user_conf="true" ;; - h) usage ;; - l) log_dir_name="results-`date "+%Y-%m-%d-%I-%M-%S"`" - mkdir -p $log_dir_name - log_dir=`realpath $log_dir_name`;; - r) rev="$OPTARG";; - t) tests="`tr "," " " <<<"$OPTARG"`" ;; - n) nm_off="yes";; - g) url="$OPTARG";; - s) use_git=false;; - ?) exit 1;; - esac -done - -# Check for test suite lock -if [ -e .lock ]; then - pid=`cat .lock` - echo "The test suite is locked by process $pid." \ - "Someone might be using it right now." - echo "Type 'unlock' if you wish to proceed anyway:" - read -e input - if [ "$input" != "unlock" ]; then - exit 1 - fi -fi - -# Lock the test suite -echo "$$" >.lock - -# Clone the repo -export repo=`mktemp -d` -if $use_git ; then - git clone $url $repo -else - rsync -r $url $repo -fi - -if $use_git ; then - # Checkout the appropriate revision/tag - if [ ! -z "$rev" ]; then - pushd . >/dev/null - cd $repo - git checkout "$rev" - popd >/dev/null - else - log "Revision not specified, using HEAD." - rev="HEAD" - fi -fi - -# Load the proper config -#rm -rf ~/.lnst -#cp -r env ~/.lnst -cp -r env/* $repo/ - -pool_dirs=`PATH="$repo:$PATH" get_pool_dirs` - -# Scan the pool and prepare the machines in it -for pool_dir in $pool_dirs; do - for machine in `ls -1 $pool_dir`; do - hostname=`get_hostname $pool_dir/$machine` - - # In case this script was killed and there are any slave processes - # left hanging on the machine. - ssh "root@$hostname" 'for p in `pgrep lnst-slave`; do kill -9 $p; done' - - # Create a temporary dir for the git tree to be tested - remote_repo=`ssh "root@$hostname" "mktemp -d"` - - # Transfer the repo to the machine - rsync -r --exclude "Logs" --exclude ".git" "$repo/" \ - "root@$hostname:$remote_repo" - - if [ ! -z $nm_off ]; then - ssh "root@$hostname" "cd $remote_repo && echo "use_nm = false" >> lnst-slave.conf" - fi - - # Start the slave process - ssh -n -t -t "root@$hostname" "cd $remote_repo && ./lnst-slave" >/dev/null \ - 2>/dev/null & - pid=$! - - # Save the status (hostname, pid of the ssh session, repo path) - # so we can cleanup things properly after the tests. - if [ -z "$slave_status" ]; then - slave_status="$hostname $pid $remote_repo" - else - slave_status="$hostname $pid $remote_repo - $slave_status" - fi - done -done - -sleep 1 - -summary="Summary:" - -# Run the tests in the tests/ directory -print_separator - -# In case the list of test names to run was omitted, run all of them -if [ -z "$tests" ]; then - tests="`command ls -1 tests/ | grep -v '.sh$' | sort -n`" -fi - -for test_name in $tests; do - test_dir=`realpath tests/$test_name` - if [ -e "$test_dir/run.sh" ]; then - logn "Running test #$test_name: " - if [ -e $test_dir/desc ]; then - while read line; do log " $line"; done < $test_dir/desc - else - logn "\n" - fi - print_separator - - pushd . >/dev/null - cd $test_dir - - chmod +x run.sh - if [ -n "$log_dir" ]; then - log_path="$log_dir/$test_name" - mkdir -p "$log_path" - - # A bit of black magic in bash. - # Explanation: http://bit.ly/1dxuMJI - log "`PATH="$repo:$PATH" ./run.sh \ - > >(tee $log_path/stdout.log) \ - 2> >(tee $log_path/stderr.log >&2)`" - else - PATH="$repo:$PATH" ./run.sh - fi - - rv=$? - - popd >/dev/null - - print_separator - if [ "$rv" -eq "0" ]; then - log "Result #$test_name: PASS" - summary=`echo -e "$summary\n test #$test_name: PASS"` - else - log "Result #$test_name: FAIL" - summary=`echo -e "$summary\n test #$test_name: FAIL"` - #break - fi - print_separator - else - log "Skipping test #$test_name, run.sh file not found." - print_separator - summary=`echo -e "$summary\n test #$test_name: SKIPPED"` - fi -done - -log "$summary" -print_separator - -sleep 1 - -# Cleanup -if [ -n "$slave_status" ]; then - while read line; do - hostname=`awk '{print $1}' <<<"$line"` - pid=`awk '{print $2}' <<<"$line"` - remote_repo=`awk '{print $3}' <<<"$line"` - - echo "kill $pid" - kill $pid - ssh -n "root@$hostname" "rm -r $remote_repo" - done <<< "$slave_status" -fi - -rm -rf $repo - -rm -rf .lock diff --git a/regression-tests/tests/0/desc b/regression-tests/tests/0/desc deleted file mode 100644 index 3e9a2cf..0000000 --- a/regression-tests/tests/0/desc +++ /dev/null @@ -1,6 +0,0 @@ -Run lnst-ctl without any parameters - -A test for Issue #6. The lnst-ctl script failed in case it was run with -no arguments at all. - -https://github.com/jpirko/lnst/issues/6 diff --git a/regression-tests/tests/0/run.sh b/regression-tests/tests/0/run.sh deleted file mode 100755 index ced2cbd..0000000 --- a/regression-tests/tests/0/run.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -# initialize the test -init_test - -# In this case, we want to catch the log for asserts. -log="`lnst-ctl`" -rv=$? - -# But we also want the log to be shown in test results. -echo "$log" - -# To keep the lnst-ctl log separated from the asserts -print_separator - -assert_log "ERROR" "No action specified" "$log" - -# Check the return value -assert_status "error" $rv - -# finish the test -end_test diff --git a/regression-tests/tests/1/desc b/regression-tests/tests/1/desc deleted file mode 100644 index d14cd8a..0000000 --- a/regression-tests/tests/1/desc +++ /dev/null @@ -1,4 +0,0 @@ -Basic sanity ping test - -This test just executes a ping between two arbitrary machines with a -single plain ethernet interface. diff --git a/regression-tests/tests/1/recipe.xml b/regression-tests/tests/1/recipe.xml deleted file mode 100644 index 33fdaf1..0000000 --- a/regression-tests/tests/1/recipe.xml +++ /dev/null @@ -1,33 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run module="IcmpPing" host="1" timeout="30"> - <options> - <option name="addr" value="{ip(2,testiface)}"/> - <option name="count" value="40"/> - <option name="interval" value="0.2"/> - <option name="limit_rate" value="95"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/1/run.sh b/regression-tests/tests/1/run.sh deleted file mode 100755 index 45e9995..0000000 --- a/regression-tests/tests/1/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl run recipe.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/10/desc b/regression-tests/tests/10/desc deleted file mode 100644 index 77fc69a..0000000 --- a/regression-tests/tests/10/desc +++ /dev/null @@ -1,4 +0,0 @@ -Check the prefix template function - -Check that the prefix function works correctly from the recipe and also from -a python program using Task API. diff --git a/regression-tests/tests/10/prefix-check-taskapi.xml b/regression-tests/tests/10/prefix-check-taskapi.xml deleted file mode 100644 index efc96b9..0000000 --- a/regression-tests/tests/10/prefix-check-taskapi.xml +++ /dev/null @@ -1,33 +0,0 @@ -<lnstrecipe> - <network> - <host id="client"> - <interfaces> - <eth id="nic1" label="inet"> - <addresses> - <address value="192.168.200.3/24"/> - </addresses> - </eth> - <eth id="nic2" label="inet"> - <addresses> - <address value="192.168.202.3/16"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="lb"> - <interfaces> - <eth id="nic1" label="inet"> - <addresses> - <address value="192.168.200.4/24"/> - </addresses> - </eth> - <eth id="nic2" label="inet"> - <addresses> - <address value="192.168.202.4/16"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - <task python="./prefix-check.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/10/prefix-check.py b/regression-tests/tests/10/prefix-check.py deleted file mode 100644 index 34d674d..0000000 --- a/regression-tests/tests/10/prefix-check.py +++ /dev/null @@ -1,15 +0,0 @@ -from lnst.Controller.Task import ctl - -m = ctl.get_host("lb") - -addr1 = m.get_ip("nic1") -addr2 = m.get_ip("nic2") - -pfx1 = m.get_prefix("nic1") -pfx2 = m.get_prefix("nic2") - -m.run("echo %s" % addr1) -m.run("echo %s" % addr2) -m.run("echo %s" % pfx1) -m.run("echo %s" % pfx2) - diff --git a/regression-tests/tests/10/prefix-check.xml b/regression-tests/tests/10/prefix-check.xml deleted file mode 100644 index 1b9ecba..0000000 --- a/regression-tests/tests/10/prefix-check.xml +++ /dev/null @@ -1,44 +0,0 @@ -<lnstrecipe> - <network> - <host id="client"> - <interfaces> - <eth id="nic1" label="inet"> - <addresses> - <address value="192.168.200.3/24"/> - </addresses> - </eth> - <eth id="nic2" label="inet"> - <addresses> - <address value="192.168.202.3/16"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="lb"> - <interfaces> - <eth id="nic1" label="inet"> - <addresses> - <address value="192.168.200.4/24"/> - </addresses> - </eth> - <eth id="nic2" label="inet"> - <addresses> - <address value="192.168.202.4/16"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - <task> - <run module="IcmpPing" host="client"> - <options> - <option name="addr" value="{ip(lb,nic1)}"/> - <option name="count" value="1"/> - </options> - </run> - <run host="lb" command="echo {ip(lb,nic1)}"/> - <run host="lb" command="echo {prefix(lb,nic1)}"/> - <run host="lb" command="echo {ip(lb,nic2,0)}"/> - <run host="lb" command="echo {prefix(lb,nic2,0)}"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/10/run.sh b/regression-tests/tests/10/run.sh deleted file mode 100755 index 55d7815..0000000 --- a/regression-tests/tests/10/run.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run prefix-check.xml | tee test10.log -rv=${PIPESTATUS[0]} - -log=`cat test10.log` - -rm -f test10.log - -print_separator - -assert_status "pass" "$rv" - -assert_log "DEBUG" "echo 24" "$log" -assert_log "DEBUG" "echo 192.168.200.4" "$log" -assert_log "DEBUG" "echo 16" "$log" -assert_log "DEBUG" "echo 192.168.202.4" "$log" - -lnst-ctl -d run prefix-check-taskapi.xml | tee test10-api.log -rv=${PIPESTATUS[0]} - -log=`cat test10-api.log` - -rm -f test10-api.log - -print_separator - -assert_status "pass" "$rv" - -assert_log "DEBUG" "echo 24" "$log" -assert_log "DEBUG" "echo 192.168.200.4" "$log" -assert_log "DEBUG" "echo 16" "$log" -assert_log "DEBUG" "echo 192.168.202.4" "$log" - -end_test diff --git a/regression-tests/tests/11/desc b/regression-tests/tests/11/desc deleted file mode 100644 index 6744e6c..0000000 --- a/regression-tests/tests/11/desc +++ /dev/null @@ -1,3 +0,0 @@ -An exception raised during configuration - -This causes the slave to die! diff --git a/regression-tests/tests/11/recipe.xml b/regression-tests/tests/11/recipe.xml deleted file mode 100644 index 2bb2c8d..0000000 --- a/regression-tests/tests/11/recipe.xml +++ /dev/null @@ -1,33 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="a192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run module="IcmpPing" host="1" timeout="30"> - <options> - <option name="addr" value="{ip(2,testiface)}"/> - <option name="count" value="40"/> - <option name="interval" value="0.2"/> - <option name="limit_rate" value="95"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/11/run.sh b/regression-tests/tests/11/run.sh deleted file mode 100755 index d32561f..0000000 --- a/regression-tests/tests/11/run.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml -rv=$? - -assert_status "error" "$rv" - -lnst-ctl -d run recipe.xml -rv=$? - -end_test diff --git a/regression-tests/tests/12/desc b/regression-tests/tests/12/desc deleted file mode 100644 index e8dbb4b..0000000 --- a/regression-tests/tests/12/desc +++ /dev/null @@ -1 +0,0 @@ -Check xinclude resolving as described in issue #29 diff --git a/regression-tests/tests/12/run.sh b/regression-tests/tests/12/run.sh deleted file mode 100755 index db8e724..0000000 --- a/regression-tests/tests/12/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run xinclude-check.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/12/sm01.xml b/regression-tests/tests/12/sm01.xml deleted file mode 100644 index 96a4f6f..0000000 --- a/regression-tests/tests/12/sm01.xml +++ /dev/null @@ -1,7 +0,0 @@ -<interfaces> - <eth id="1" label="testnet"> - <addresses> - <address value="192.168.100.10/24" /> - </addresses> - </eth> -</interfaces> diff --git a/regression-tests/tests/12/sm02.xml b/regression-tests/tests/12/sm02.xml deleted file mode 100644 index f1e1f02..0000000 --- a/regression-tests/tests/12/sm02.xml +++ /dev/null @@ -1,7 +0,0 @@ -<interfaces> - <eth id="1" label="testnet"> - <addresses> - <address value="192.168.100.20/24" /> - </addresses> - </eth> -</interfaces> diff --git a/regression-tests/tests/12/xinclude-check.xml b/regression-tests/tests/12/xinclude-check.xml deleted file mode 100644 index 6bdf7bf..0000000 --- a/regression-tests/tests/12/xinclude-check.xml +++ /dev/null @@ -1,13 +0,0 @@ -<lnstrecipe xmlns:xi="http://www.w3.org/2003/XInclude"> - <network> - <host id="1"> - <xi:include href="sm01.xml"/> - </host> - <host id="2"> - <xi:include href="sm02.xml"/> - </host> - </network> - <task> - <run command="echo {ip(1,1)}" host="2"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/13/desc b/regression-tests/tests/13/desc deleted file mode 100644 index 22b8aeb..0000000 --- a/regression-tests/tests/13/desc +++ /dev/null @@ -1 +0,0 @@ -This test checks that aliases are visible in python tasks diff --git a/regression-tests/tests/13/run.sh b/regression-tests/tests/13/run.sh deleted file mode 100755 index b72d1e2..0000000 --- a/regression-tests/tests/13/run.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run taskapi-alias-check.xml -rv=$? - -assert_status "pass" "$rv" - -lnst-ctl -d -A alias1="value2" run taskapi-alias-check.xml -rv=$? - -assert_status "fail" "$rv" - -lnst-ctl -d run taskapi-alias-namespace-check.xml -rv=$? - -assert_status "fail" "$rv" - -end_test diff --git a/regression-tests/tests/13/taskapi-alias-check.py b/regression-tests/tests/13/taskapi-alias-check.py deleted file mode 100644 index 422fdd3..0000000 --- a/regression-tests/tests/13/taskapi-alias-check.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("m1") -m2 = ctl.get_host("m2") - -m1.run("[ "%s" == "value1" ]" % ctl.get_alias("alias1")) -m2.run("[ "%s" == "value2" ]" % ctl.get_alias("alias2")) - diff --git a/regression-tests/tests/13/taskapi-alias-check.xml b/regression-tests/tests/13/taskapi-alias-check.xml deleted file mode 100644 index 2745c00..0000000 --- a/regression-tests/tests/13/taskapi-alias-check.xml +++ /dev/null @@ -1,38 +0,0 @@ -<lnstrecipe> - <define> - <alias name="alias1" value="value1"/> - </define> - <network> - <define> - <alias name="m1_addr" value="192.168.111.1/24"/> - </define> - <host id="m1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address>{$m1_addr}</address> - </addresses> - </eth> - </interfaces> - </host> - - <define> - <alias name="m2_addr" value="192.168.111.2/24"/> - </define> - <host id="m2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="{$m1_addr}"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <define> - <alias name="alias2" value="value2"/> - </define> - - <task python="taskapi-alias-check.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/13/taskapi-alias-namespace-check.py b/regression-tests/tests/13/taskapi-alias-namespace-check.py deleted file mode 100644 index afed22d..0000000 --- a/regression-tests/tests/13/taskapi-alias-namespace-check.py +++ /dev/null @@ -1,8 +0,0 @@ -import sys -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("m1") - -# this should fail -m1.run("[ "%s" == "value1" ]" % ctl.get_alias("foo")) - diff --git a/regression-tests/tests/13/taskapi-alias-namespace-check.xml b/regression-tests/tests/13/taskapi-alias-namespace-check.xml deleted file mode 100644 index 9f9109d..0000000 --- a/regression-tests/tests/13/taskapi-alias-namespace-check.xml +++ /dev/null @@ -1,41 +0,0 @@ -<lnstrecipe> - <define> - <alias name="alias1" value="value1"/> - </define> - <network> - <define> - <alias name="m1_addr" value="192.168.111.1/24"/> - </define> - <host id="m1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address>{$m1_addr}</address> - </addresses> - </eth> - </interfaces> - </host> - - <define> - <alias name="m2_addr" value="192.168.111.2/24"/> - </define> - <host id="m2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="{$m1_addr}"/> - </addresses> - </eth> - </interfaces> - </host> - <define> - <alias name="foo" value="bar"/> - </define> - </network> - - <define> - <alias name="alias2" value="value2"/> - </define> - - <task python="taskapi-alias-namespace-check.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/14/desc b/regression-tests/tests/14/desc deleted file mode 100644 index b595c43..0000000 --- a/regression-tests/tests/14/desc +++ /dev/null @@ -1,3 +0,0 @@ -crash with more than two masters in stack with NetworkManager - -https://github.com/jpirko/lnst/issues/70 diff --git a/regression-tests/tests/14/recipe1.xml b/regression-tests/tests/14/recipe1.xml deleted file mode 100644 index 9d9d45a..0000000 --- a/regression-tests/tests/14/recipe1.xml +++ /dev/null @@ -1,68 +0,0 @@ -<lnstrecipe> - <network> - <host id="slave1"> - <params/> - <interfaces> - <eth id="1" label="A"/> - <team id="team"> - <slaves> - <slave id="1"/> - </slaves> - <options> - <option name="teamd_config"> - { - "hwaddr": "00:11:22:33:44:55", - "runner": {"name": "activebackup"}, - "link_watch": {"name": "ethtool"} - } - </option> - </options> - <addresses> - <address value="192.168.100.3/24"/> - </addresses> - </team> - <vlan id="vlan"> - <options> - <option name="vlan_tci" value="1"/> - </options> - <addresses> - <address value="192.168.101.1/24"/> - </addresses> - <slaves> - <slave id="team"/> - </slaves> - </vlan> - </interfaces> - </host> - - <host id="slave2"> - <params/> - <interfaces> - <eth id="2" label="A"/> - <vlan id="testifc2"> - <options> - <option name="vlan_tci" value="1"/> - </options> - <addresses> - <address value="192.168.101.2/24"/> - </addresses> - <slaves> - <slave id="2"/> - </slaves> - </vlan> - </interfaces> - </host> - - </network> - - <task> - <run host="slave1" command="ip a"/> - <run host="slave1" module="IcmpPing"> - <options> - <option name="addr" value="{ip(slave2,testifc2)}"/> - <option name="count" value="3"/> - <option name="iface" value="{devname(slave1, vlan)}"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/14/recipe2.xml b/regression-tests/tests/14/recipe2.xml deleted file mode 100644 index 4d165f6..0000000 --- a/regression-tests/tests/14/recipe2.xml +++ /dev/null @@ -1,79 +0,0 @@ -<lnstrecipe> - <network> - <host id="slave1"> - <params/> - <interfaces> - <eth id="1" label="A"/> - <vlan id="vlan1"> - <options> - <option name="vlan_tci" value="1"/> - </options> - <addresses> - <address value="192.168.100.1/24"/> - </addresses> - <slaves> - <slave id="1"/> - </slaves> - </vlan> - <vlan id="vlan2"> - <options> - <option name="vlan_tci" value="2"/> - </options> - <addresses> - <address value="192.168.101.2/24"/> - </addresses> - <slaves> - <slave id="1"/> - </slaves> - </vlan> - </interfaces> - </host> - - <host id="slave2"> - <params/> - <interfaces> - <eth id="2" label="A"/> - <vlan id="vlan1"> - <options> - <option name="vlan_tci" value="1"/> - </options> - <addresses> - <address value="192.168.100.3/24"/> - </addresses> - <slaves> - <slave id="2"/> - </slaves> - </vlan> - <vlan id="vlan2"> - <options> - <option name="vlan_tci" value="2"/> - </options> - <addresses> - <address value="192.168.101.4/24"/> - </addresses> - <slaves> - <slave id="2"/> - </slaves> - </vlan> - </interfaces> - </host> - - </network> - - <task> - <run host="slave1" module="IcmpPing"> - <options> - <option name="addr" value="{ip(slave2, vlan1)}"/> - <option name="count" value="3"/> - <option name="iface" value="{devname(slave1, vlan1)}"/> - </options> - </run> - <run host="slave1" module="IcmpPing"> - <options> - <option name="addr" value="{ip(slave2, vlan2)}"/> - <option name="count" value="3"/> - <option name="iface" value="{devname(slave1, vlan2)}"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/14/run.sh b/regression-tests/tests/14/run.sh deleted file mode 100755 index 42ccbcc..0000000 --- a/regression-tests/tests/14/run.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe1.xml -rv=$? - -assert_status "pass" "$rv" - -lnst-ctl -d run recipe2.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/15/desc b/regression-tests/tests/15/desc deleted file mode 100644 index 29c8517..0000000 --- a/regression-tests/tests/15/desc +++ /dev/null @@ -1,3 +0,0 @@ -devname updates not reflected in {Net,Nm}DeviceConfig classes - -https://github.com/jpirko/lnst/issues/65 diff --git a/regression-tests/tests/15/recipe.xml b/regression-tests/tests/15/recipe.xml deleted file mode 100644 index 3225b26..0000000 --- a/regression-tests/tests/15/recipe.xml +++ /dev/null @@ -1,33 +0,0 @@ -<lnstrecipe> - <network> - <host id="slave1"> - <params/> - <interfaces> - <eth id="1" label="A"> - <addresses> - <address value="192.168.101.1/24"/> - </addresses> - </eth> - </interfaces> - </host> - - <host id="slave2"> - <params/> - <interfaces> - <eth id="1" label="A"> - <addresses> - <address value="192.168.101.2/24"/> - </addresses> - </eth> - </interfaces> - </host> - - </network> - - <task> - <run host="slave1" command="ip link set {devname(slave1, 1)} down"/> - <run host="slave1" command="ip link set {devname(slave1, 1)} name xyz"/> - <run host="slave1" command="ip link set {devname(slave1, 1)} up"/> - <run host="slave1" command="ip a show dev xyz"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/15/run.sh b/regression-tests/tests/15/run.sh deleted file mode 100755 index 50ab9ce..0000000 --- a/regression-tests/tests/15/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/16/desc b/regression-tests/tests/16/desc deleted file mode 100644 index a063e3a..0000000 --- a/regression-tests/tests/16/desc +++ /dev/null @@ -1,3 +0,0 @@ -address tag should accept value in the tag contents or the 'value' attribute - -https://github.com/jpirko/lnst/issues/31 diff --git a/regression-tests/tests/16/recipe.xml b/regression-tests/tests/16/recipe.xml deleted file mode 100644 index 3d8887e..0000000 --- a/regression-tests/tests/16/recipe.xml +++ /dev/null @@ -1,37 +0,0 @@ -<lnstrecipe> - <network> - <host id="slave1"> - <interfaces> - <eth id="testifc1" label="A"> - <addresses> - <address>fd00::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - - <host id="slave2"> - <interfaces> - <eth id="testifc3" label="A"> - <addresses> - <address value="fd00::2/64"/> - </addresses> - </eth> - </interfaces> - </host> - - </network> - - <task> - <ctl_wait seconds="5"/> - <config host="slave1" option="/proc/sys/net/ipv4/igmp_max_memberships" value="5"/> - <run host="slave1" module="Icmp6Ping"> - <options> - <option name="addr" value="{ip(slave2,testifc3)}"/> - <option name="count" value="20"/> - <option name="interval" value="0"/> - </options> - </run> - </task> - -</lnstrecipe> diff --git a/regression-tests/tests/16/run.sh b/regression-tests/tests/16/run.sh deleted file mode 100755 index 6b80eb5..0000000 --- a/regression-tests/tests/16/run.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml -rv=$? - -print_separator - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/17/desc b/regression-tests/tests/17/desc deleted file mode 100644 index af02d5b..0000000 --- a/regression-tests/tests/17/desc +++ /dev/null @@ -1,3 +0,0 @@ -Unknown options to a test module result in a stack trace - -https://github.com/jpirko/lnst/issues/38 diff --git a/regression-tests/tests/17/recipe.xml b/regression-tests/tests/17/recipe.xml deleted file mode 100644 index 56f9216..0000000 --- a/regression-tests/tests/17/recipe.xml +++ /dev/null @@ -1,38 +0,0 @@ -<lnstrecipe> - <network> - <host id="slave1"> - <interfaces> - <eth id="testiface" label="A"> - <addresses> - <address value="fd00::1/64"/> - </addresses> - </eth> - </interfaces> - </host> - - <host id="slave2"> - <interfaces> - <eth id="testiface" label="A"> - <addresses> - <address value="fd00::2/64"/> - </addresses> - </eth> - </interfaces> - </host> - - </network> - - <task> - <ctl_wait seconds="5"/> - <run module="Icmp6Ping" host="slave1" timeout="30"> - <options> - <option name="addre" value="{ip(slave2,testiface)}"/> <!-- this is wrong --> - <option name="addr" value="{ip(slave2,testiface)}"/> <!-- this is correct --> - <option name="count" value="10"/> - <option name="interval" value="0.0"/> - <option name="limit_rate" value="95"/> - </options> - </run> - </task> - -</lnstrecipe> diff --git a/regression-tests/tests/17/run.sh b/regression-tests/tests/17/run.sh deleted file mode 100755 index 6b80eb5..0000000 --- a/regression-tests/tests/17/run.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml -rv=$? - -print_separator - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/18/desc b/regression-tests/tests/18/desc deleted file mode 100644 index bca06cc..0000000 --- a/regression-tests/tests/18/desc +++ /dev/null @@ -1,6 +0,0 @@ -Empty task results in uhandled exception - -Instead we should require at least one command or end with an error, but not a -stack trace. - -https://github.com/jpirko/lnst/issues/53 diff --git a/regression-tests/tests/18/recipe.xml b/regression-tests/tests/18/recipe.xml deleted file mode 100644 index 75db68c..0000000 --- a/regression-tests/tests/18/recipe.xml +++ /dev/null @@ -1,26 +0,0 @@ -<lnstrecipe> - <network> - <host id="slave1"> - <interfaces> - <eth id="testiface" label="A"> - <addresses> - <address value="fd00::1/64"/> - </addresses> - </eth> - </interfaces> - </host> - - <host id="slave2"> - <interfaces> - <eth id="testiface" label="A"> - <addresses> - <address value="fd00::2/64"/> - </addresses> - </eth> - </interfaces> - </host> - - </network> - - <task/> -</lnstrecipe> diff --git a/regression-tests/tests/18/run.sh b/regression-tests/tests/18/run.sh deleted file mode 100755 index ba19649..0000000 --- a/regression-tests/tests/18/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml | tee test.log -rv=${PIPESTATUS[0]} - -log=`cat test.log` - -rm -f test.log - -print_separator - -assert_status "error" "$rv" -assert_log "ERROR" "Parser error:" "$log" - -end_test diff --git a/regression-tests/tests/19/desc b/regression-tests/tests/19/desc deleted file mode 100644 index a704a88..0000000 --- a/regression-tests/tests/19/desc +++ /dev/null @@ -1,3 +0,0 @@ -undefined interface id in template function - -https://github.com/jpirko/lnst/issues/55 diff --git a/regression-tests/tests/19/recipe.xml b/regression-tests/tests/19/recipe.xml deleted file mode 100644 index 4fa9892..0000000 --- a/regression-tests/tests/19/recipe.xml +++ /dev/null @@ -1,17 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" command="ethtool -i {ip(tm1,nic2)}"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/19/run.sh b/regression-tests/tests/19/run.sh deleted file mode 100755 index 001c35b..0000000 --- a/regression-tests/tests/19/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml | tee test.log -rv=${PIPESTATUS[0]} - -log=`cat test.log` - -rm -f test.log - -print_separator - -assert_status "error" "$rv" -assert_log "ERROR" "Second parameter of function ip() is invalid" "$log" - -end_test diff --git a/regression-tests/tests/2/desc b/regression-tests/tests/2/desc deleted file mode 100644 index 9f606a7..0000000 --- a/regression-tests/tests/2/desc +++ /dev/null @@ -1,5 +0,0 @@ -RecipeParser: Lots of comments in a XML - -There was a problem with comments at some places in the recipe XML. -This recipe should cover all the possibilities and make sure they are -properly ignored. diff --git a/regression-tests/tests/2/recipe.xml b/regression-tests/tests/2/recipe.xml deleted file mode 100644 index 0565f47..0000000 --- a/regression-tests/tests/2/recipe.xml +++ /dev/null @@ -1,74 +0,0 @@ -<!--comment--> -<lnstrecipe> - <!--comment--> - <network> - <!--comment--> - <host id="1"> - <!--comment--> - <params> - <!--comment--> - </params> - <!--comment--> - <interfaces> - <!--comment--> - <eth label="tnet" id="testiface"> - <!--comment--> - <addresses> - <!--comment--> - <address value="192.168.100.10/24"/> - <!--comment--> - </addresses> - <!--comment--> - </eth> - <!--comment--> - </interfaces> - <!--comment--> - </host> - <!--comment--> - <host id="2"> - <!--comment--> - <params> - <!--comment--> - </params> - <!--comment--> - <interfaces> - <!--comment--> - <eth label="tnet" id="testiface"> - <!--comment--> - <addresses> - <!--comment--> - <address value="192.168.100.11/24"/> - <!--comment--> - </addresses> - <!--comment--> - </eth> - <!--comment--> - </interfaces> - <!--comment--> - </host> - <!--comment--> - </network> - <!--comment--> - - <task> - <!--comment--> - <run module="IcmpPing" host="1" timeout="30"> - <!--comment--> - <options> - <!--comment--> - <option name="addr" value="{ip(2,testiface)}"/> - <!--comment--> - <option name="count" value="40"/> - <!--comment--> - <option name="interval" value="0.2"/> - <!--comment--> - <option name="limit_rate" value="95"/> - <!--comment--> - </options> - <!--comment--> - </run> - <!--comment--> - </task> - <!--comment--> -</lnstrecipe> -<!--comment--> diff --git a/regression-tests/tests/2/run.sh b/regression-tests/tests/2/run.sh deleted file mode 100755 index 45e9995..0000000 --- a/regression-tests/tests/2/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl run recipe.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/20/desc b/regression-tests/tests/20/desc deleted file mode 100644 index c695ab0..0000000 --- a/regression-tests/tests/20/desc +++ /dev/null @@ -1,3 +0,0 @@ -recipe cannot be run after config_only run of recipe with team/bonding - -https://github.com/jpirko/lnst/issues/59 diff --git a/regression-tests/tests/20/recipe1.xml b/regression-tests/tests/20/recipe1.xml deleted file mode 100644 index 54346e9..0000000 --- a/regression-tests/tests/20/recipe1.xml +++ /dev/null @@ -1,47 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"/> - <bond id="bond"> - <slaves> - <slave id="nic1"/> - </slaves> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </bond> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"/> - <team id="team"> - <options> - <option name="teamd_config"> - { - "runner": {"name": "activebackup"}, - "link_watch": {"name": "ethtool"} - } - </option> - </options> - <slaves> - <slave id="nic1"/> - </slaves> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </team> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" module="IcmpPing"> - <options> - <option name="addr" value="{ip(tm2,team)}"/> - <option name="count" value="3"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/20/recipe2.xml b/regression-tests/tests/20/recipe2.xml deleted file mode 100644 index 327c0f3..0000000 --- a/regression-tests/tests/20/recipe2.xml +++ /dev/null @@ -1,31 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" module="IcmpPing"> - <options> - <option name="addr" value="{ip(tm2,nic1)}"/> - <option name="count" value="3"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/20/run.sh b/regression-tests/tests/20/run.sh deleted file mode 100755 index 8a720f0..0000000 --- a/regression-tests/tests/20/run.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d config_only recipe1.xml | tee test.log -rv1=${PIPESTATUS[0]} - -lnst-ctl -d run recipe2.xml | tee test.log -rv2=${PIPESTATUS[0]} - - -print_separator -assert_status "pass" "$rv1" -assert_status "pass" "$rv2" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/21/desc b/regression-tests/tests/21/desc deleted file mode 100644 index e4f5cbc..0000000 --- a/regression-tests/tests/21/desc +++ /dev/null @@ -1,3 +0,0 @@ -broken tool-module dependency during synchronization - -https://github.com/jpirko/lnst/issues/71 diff --git a/regression-tests/tests/21/lnst-ctl.conf b/regression-tests/tests/21/lnst-ctl.conf deleted file mode 100644 index 9f43732..0000000 --- a/regression-tests/tests/21/lnst-ctl.conf +++ /dev/null @@ -1,3 +0,0 @@ -[environment] -test_tool_dirs = ./test_tools -test_module_dirs = ./test_modules diff --git a/regression-tests/tests/21/recipe.xml b/regression-tests/tests/21/recipe.xml deleted file mode 100644 index ee61de1..0000000 --- a/regression-tests/tests/21/recipe.xml +++ /dev/null @@ -1,55 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <define> - <alias name="my_range" value="10000-10050" /> - </define> - - <define> - <alias name="debug" value="no"/> - </define> - - <run module="TCPConnection" host="tm2" bg_id="server"> - <options> - <option name="mode" value="server"/> - <option name="address" value="{ip(tm2,nic1)}"/> - <option name="portrange" value="{$my_range}"/> - <option name="continuous" value="yes"/> - <option name="debug" value="{$debug}"/> - </options> - </run> - <ctl_wait seconds="3"/> - <run module="TCPConnection" host="tm1" bg_id="client"> - <options> - <option name="mode" value="client"/> - <option name="address" value="{ip(tm2,nic1)}"/> - <option name="portrange" value="{$my_range}"/> - <option name="continuous" value="yes"/> - <option name="debug" value="{$debug}"/> - </options> - </run> - <ctl_wait seconds="15"/> - <intr host="tm1" bg_id="client"/> - <intr host="tm2" bg_id="server"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/21/run.sh b/regression-tests/tests/21/run.sh deleted file mode 100755 index 07bd6c0..0000000 --- a/regression-tests/tests/21/run.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -touch test_tools/* -touch test_modules/* - -lnst-ctl -c lnst-ctl.conf -d -r run recipe.xml | tee test.log -rv=${PIPESTATUS[0]} - -print_separator -assert_status "pass" "$rv" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/21/test_modules/TCPConnection.py b/regression-tests/tests/21/test_modules/TCPConnection.py deleted file mode 100644 index 43b88a9..0000000 --- a/regression-tests/tests/21/test_modules/TCPConnection.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -This module defines TCPConnection test, -a python wrapper for LNST's tcp_conn test tool -""" - -__author__ = """ -jtluka@redhat.com (Jan Tluka) -""" - -import re -import errno -import logging -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.Utils import bool_it - -class TCPConnection(TestGeneric): - def run(self): - mode = self.get_mopt("mode") - address = self.get_mopt("address") - portrange = self.get_mopt("portrange") - - continuous = self.get_opt("continuous") - debug = self.get_opt("debug") - ipv6 = self.get_opt("ipv6") - - cmd = "" - if (mode == "server"): - logging.debug("TCPConnection: running as server") - cmd += "./tcp_listen" - elif (mode == "client"): - logging.debug("TCPConnection: running as client") - cmd += "./tcp_connect" - else: - raise Exception("Invalid mode value for TCPConnection test module!") - - cmd += " -a %s -p %s" % (address, portrange) - - if continuous and bool_it(continuous): - cmd += " -c" - - if debug and bool_it(debug): - cmd += " -d" - - if ipv6 and bool_it(ipv6): - cmd += " -6" - - output = self.exec_from("tcp_conn", cmd, die_on_err=False, log_outputs=True)[0] - - logging.debug("TCPConnection done, inspecting logs ...") - - m = None - if (mode == "client"): - m = re.search("made [0-9]* connections", output) - elif (mode == "server"): - m = re.search("handled [0-9]* connections", output) - - if m is None: - return self.set_fail({'msg': "Unexpected error"}) - else: - return self.set_pass({'msg': m.group(0)}) diff --git a/regression-tests/tests/21/test_tools/tcp_conn/Makefile b/regression-tests/tests/21/test_tools/tcp_conn/Makefile deleted file mode 100644 index a570641..0000000 --- a/regression-tests/tests/21/test_tools/tcp_conn/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -CC=gcc - -all: tcp_listen tcp_connect - -tcp_listen: tcp_listen.c - $(CC) -o tcp_listen tcp_listen.c -pthread -lrt - -tcp_connect: tcp_connect.c - $(CC) -o tcp_connect tcp_connect.c -pthread -lrt - -clean: - rm -f tcp_connect tcp_listen diff --git a/regression-tests/tests/21/test_tools/tcp_conn/lnst-setup.sh b/regression-tests/tests/21/test_tools/tcp_conn/lnst-setup.sh deleted file mode 100755 index 2aad486..0000000 --- a/regression-tests/tests/21/test_tools/tcp_conn/lnst-setup.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -make diff --git a/regression-tests/tests/21/test_tools/tcp_conn/tcp_connect.c b/regression-tests/tests/21/test_tools/tcp_conn/tcp_connect.c deleted file mode 100644 index 3bb4597..0000000 --- a/regression-tests/tests/21/test_tools/tcp_conn/tcp_connect.c +++ /dev/null @@ -1,281 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <sys/wait.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <arpa/inet.h> - -#include <errno.h> -#include <signal.h> -#include <semaphore.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> - -#define IPCKEY 5678 - -int connection_handlers[1024]; -int handlers_count; -int *connection_count; - -int debug_on = 0; -int cont = 0; -int *term_flag; - -sem_t *mutex; - -int usage() -{ - printf("./tcp_connect -p [port_range] -a [ipaddr] [-d] [-c] [-6]\n"); - return 0; -} - -#define MSG_MAX 256 -char msg[MSG_MAX]; - -void debug(char* msg) -{ - if (debug_on) - { - printf("Debug: %s\n", msg); - } -} - -void terminate_connections(int p) -{ - debug("signalled"); - *term_flag = 1; -} - -int handle_connections(char* host, int port, int ipv6) -{ - int conn_sock; - struct sockaddr_in my_addr; - struct sockaddr_in6 my_addr6; - char data[] = "abcdefghijklmnopqrstuvwxyz0123456789"; - char buf[21*10*strlen(data)+1]; - int family; - - snprintf(msg, MSG_MAX, "Starting connection on %s port %i", host, port); - debug(msg); - - if (ipv6) - { - family = my_addr6.sin6_family = AF_INET6; - my_addr6.sin6_port = htons(port); - if (inet_pton(AF_INET6, host, &my_addr6.sin6_addr) != 1) { - perror("fail on inet_pton"); - return 1; - } - } - else - { - family = my_addr.sin_family = AF_INET; - my_addr.sin_port = htons(port); - if (inet_aton(host, &(my_addr.sin_addr)) == 0) - { - printf("failed on inet_aton()\n"); - return 1; - } - } - - do - { - conn_sock = socket(family, SOCK_STREAM, 0); - if (conn_sock == -1) - { - perror("fail on socket()"); - return 1; - } - - struct sockaddr* sa; - socklen_t sa_len; - if (ipv6) - { - sa = (struct sockaddr*) &my_addr6; - sa_len = sizeof(struct sockaddr_in6); - } - else - { - sa = (struct sockaddr*) &my_addr; - sa_len = sizeof(struct sockaddr_in); - } - - if (connect(conn_sock, sa, sa_len) == -1) - { - perror("fail on connect"); - return 1; - } - - sem_wait(mutex); - *connection_count += 1; - sem_post(mutex); - - int bursts = 5*(random() % 10) + 1; - int b; - int sum = 0; - - for (b=0; b < bursts; b++) - { - int parts = 20*(random() % 10) + 1; - int j; - - sum += parts*strlen(data); - for (j = 0; j < parts; j++) - { - strncpy(buf + (j*strlen(data)), data, strlen(data)); - } - - if (write(conn_sock, buf, parts * strlen(data)) == -1) - { - perror("failed to send data"); - return 1; - } - usleep(100*(random()%100)); - } - - snprintf(msg, MSG_MAX, "sent %i bytes (bursts: %i)", sum, bursts); - debug(msg); - snprintf(msg, MSG_MAX, "closing connection on port %i", port); - debug(msg); - - close(conn_sock); - } while (cont && (*term_flag) == 0); - - return 0; -} - -int main(int argc, char **argv) -{ - int rc; - int p; - char port_str[256]; - char str_port_start[128]; - char str_port_end[128]; - char host_str[16] = "\0"; - int start_port; - int end_port; - int opt; - char *delimiter; - struct sigaction sa; - int shm; - int ipv6 = 0; - - term_flag = mmap(NULL, sizeof *term_flag, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); - *term_flag = 0; - - connection_count = mmap(NULL, sizeof *connection_count, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); - *connection_count = 0; - - /* counter synchronization stuff - semaphore and shared memory */ - if ((shm = shm_open("myshm", O_RDWR | O_CREAT, S_IRWXU)) < 0) { - perror("shm_open"); - exit(1); - } - - if ( ftruncate(shm, sizeof(sem_t)) < 0 ) { - perror("ftruncate"); - exit(1); - } - - /* place shared mutex into shared memory */ - if ((mutex = (sem_t*) mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0)) == MAP_FAILED) { - perror("mmap"); - exit(1); - } - - if( sem_init(mutex,1,1) < 0) - { - perror("semaphore initilization"); - exit(0); - } - - /* signal handling */ - memset(&sa, 0, sizeof(sa)); - - sa.sa_handler = &terminate_connections; - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - - handlers_count = 0; - - /* collect program args */ - while ((opt = getopt(argc, argv, "p:a:dc6")) != -1) { - switch (opt) { - case 'p': - strncpy(port_str, optarg, 256); - port_str[256-1]='\0'; - delimiter = strchr(port_str, '-'); - if (delimiter == NULL) - { - usage(); - return 1; - } - strncpy(str_port_start, port_str, delimiter - port_str); - str_port_start[delimiter - port_str] = '\0'; - strncpy(str_port_end, delimiter+1, strlen(port_str) - (delimiter+1-port_str)); - start_port = atoi(str_port_start); - end_port = atoi(str_port_end); - break; - case 'a': - strncpy(host_str, optarg, 64); - host_str[16-1] = '\0'; - break; - case 'd': - debug_on = 1; - break; - case 'c': - cont = 1; - break; - case '6': - ipv6 = 1; - break; - } - } - - if (strlen(host_str) == 0) - { - usage(); - return 1; - } - - /* spawn process to handle every port specified */ - for (p = start_port; p < end_port; p++){ - if ((rc = fork()) > 0) - { - /* parent, add pid to the list */ - connection_handlers[handlers_count++] = rc; - } - else if (rc == 0) - { - /* child */ - sa.sa_handler = SIG_DFL; - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - handle_connections(host_str, p, ipv6); - return 0; - } - } - - /* gather children */ - int child_status; - int i; - for (i=0; i < handlers_count; i++) - { - wait(&child_status); - debug("worker finished"); - } - - debug("tcp_connect finished"); - - printf("made %i connections\n", *connection_count); - - return 0; -} diff --git a/regression-tests/tests/21/test_tools/tcp_conn/tcp_listen.c b/regression-tests/tests/21/test_tools/tcp_conn/tcp_listen.c deleted file mode 100644 index 7a292fe..0000000 --- a/regression-tests/tests/21/test_tools/tcp_conn/tcp_listen.c +++ /dev/null @@ -1,330 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <sys/wait.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <arpa/inet.h> - -#include <errno.h> -#include <signal.h> -#include <semaphore.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> - -#define IPCKEY 5678 - -int listener_count; -int listeners[1024]; -int *connection_count; - -int debug_on = 0; -int cont = 0; -int *term_flag; - -sem_t *mutex; - -int usage() -{ - printf("./tcp_listen -p [port_range] -a [ipaddr] [-d] [-c] [-6]\n"); - return 0; -} - -void debug(char* msg) -{ - if (debug_on) - { - printf("Debug: %s\n", msg); - } -} - -#define MSG_MAX 256 -char msg[MSG_MAX]; - -void terminate_connections(int p) -{ - debug("signal received, killing servers"); - *term_flag = 1; -} - -int handle_connections(char* host, int port, int ipv6) -{ - int listen_sock; - struct sockaddr_in my_addr; - struct sockaddr_in6 my_addr6; - socklen_t my_addr_size = sizeof(my_addr); - socklen_t my_addr6_size = sizeof(my_addr6); - int remote_sock; - struct sockaddr_in remote; - struct sockaddr_in6 remote6; - socklen_t remote_size = sizeof(remote); - socklen_t remote6_size = sizeof(remote6); - char data[256]; - int family; - - snprintf(msg, MSG_MAX, "Starting listener on %s port %i", host, port); - debug(msg); - - if (ipv6) - { - family = AF_INET6; - bzero(&my_addr6, my_addr6_size); - my_addr6.sin6_family = family; - my_addr6.sin6_port = htons(port); - if (inet_pton(AF_INET6, host, &(my_addr6.sin6_addr)) != 1) - { - printf("failed on inet_pton()\n"); - return 1; - } - } - else - { - family = AF_INET; - bzero(&my_addr, my_addr_size); - my_addr.sin_family = family; - my_addr.sin_port = htons(port); - if (inet_aton(host, &(my_addr.sin_addr)) == 0) - { - printf("failed on inet_aton()\n"); - return 1; - } - } - - if ((listen_sock = socket(family, SOCK_STREAM, 0)) == -1) - { - perror("fail on socket creation"); - return 1; - } - - int on = 1; - if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, (const char*) &on, - sizeof(on)) == -1) - { - perror("fail on setsockopt"); - return 1; - } - - struct sockaddr* sa; - socklen_t sa_len; - if (ipv6) - { - sa = (struct sockaddr*) &my_addr6; - sa_len = my_addr6_size; - } - else - { - sa = (struct sockaddr*) &my_addr; - sa_len = my_addr_size; - } - - if (bind(listen_sock, sa, sa_len)) - { - perror("fail on bind"); - return 1; - } - - if (listen(listen_sock, 0)) - { - perror("fail on listen"); - return 1; - } - - do - { - struct in_addr ra = remote.sin_addr; - struct in6_addr ra6 = remote6.sin6_addr; - char host_address_str[256]; - ssize_t read_rc; - struct sockaddr* r_sockaddr; - socklen_t* r_sockaddr_size; - - if (ipv6) - { - bzero(&remote6, remote6_size); - r_sockaddr = (struct sockaddr*) &remote6; - r_sockaddr_size = &remote6_size; - } - else - { - bzero(&remote, remote_size); - r_sockaddr = (struct sockaddr*) &remote; - r_sockaddr_size = &remote_size; - } - - /* handle single connection */ - remote_sock = accept(listen_sock, r_sockaddr, r_sockaddr_size); - if (remote_sock == -1) - { - perror("failure on accept"); - close(listen_sock); - return 1; - } - - sem_wait(mutex); - *connection_count += 1; - sem_post(mutex); - - if (ipv6) - inet_ntop(AF_INET6, &ra6, host_address_str, 255); - else - inet_ntop(AF_INET, &ra, host_address_str, 255); - - snprintf(msg, MSG_MAX, "accepted connection from host %s port %i", host_address_str, port); - debug(msg); - - int sum = 0; - while (read_rc = read(remote_sock, &data, 256)) - { - sum += read_rc; - } - - snprintf(msg, MSG_MAX, "connection closed, read %d bytes (%i)", sum, port); - debug(msg); - close(remote_sock); - } while (cont && (*term_flag) == 0); - - close(listen_sock); - - return 0; -} - -int main(int argc, char **argv) -{ - int rc; - int p; - char port_str[256]; - char str_port_start[128]; - char str_port_end[128]; - char host_str[16] = "\0"; - int start_port; - int end_port; - int opt; - char *delimiter; - struct sigaction sa; - struct sigaction sa2; - int shm; - int ipv6 = 0; - - term_flag = mmap(NULL, sizeof *term_flag, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); - *term_flag = 0; - - connection_count = mmap(NULL, sizeof *connection_count, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); - *connection_count = 0; - - /* counter synchronization stuff - semaphore and shared memory */ - if ((shm = shm_open("myshm", O_RDWR | O_CREAT, S_IRWXU)) < 0) { - perror("shm_open"); - exit(1); - } - - if ( ftruncate(shm, sizeof(sem_t)) < 0 ) { - perror("ftruncate"); - exit(1); - } - - /* place shared mutex into shared memory */ - if ((mutex = (sem_t*) mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0)) == MAP_FAILED) { - perror("mmap"); - exit(1); - } - - if( sem_init(mutex,1,1) < 0) - { - perror("semaphore initilization"); - exit(0); - } - - /* signal handling */ - memset(&sa, 0, sizeof(sa)); - memset(&sa2, 0, sizeof(sa2)); - - sa.sa_handler = &terminate_connections; - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - - /* collect program args */ - while ((opt = getopt(argc, argv, "p:a:dc6")) != -1) { - switch (opt) { - case 'p': - strncpy(port_str, optarg, 256); - port_str[256-1]='\0'; - delimiter = strchr(port_str, '-'); - if (delimiter == NULL) - { - usage(); - return 1; - } - strncpy(str_port_start, port_str, delimiter - port_str); - str_port_start[delimiter - port_str] = '\0'; - strncpy(str_port_end, delimiter+1, strlen(port_str) - (delimiter+1-port_str)); - start_port = atoi(str_port_start); - end_port = atoi(str_port_end); - break; - case 'a': - strncpy(host_str, optarg, 64); - host_str[16-1] = '\0'; - break; - case 'd': - debug_on = 1; - break; - case 'c': - cont = 1; - break; - case '6': - ipv6 = 1; - break; - } - } - - if (strlen(host_str) == 0) - { - usage(); - return 1; - } - - listener_count = 0; - /* spawn process to handle every port specified */ - for (p = start_port; p < end_port; p++){ - if ((rc = fork()) > 0) - { - /* parent, add pid to the list */ - listeners[listener_count++] = rc; - } - else if (rc == 0) - { - /* child */ - sa.sa_handler = SIG_DFL; - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - - /* run the main processing loop */ - handle_connections(host_str, p, ipv6); - return 0; - } - } - - /* gather children */ - int child_status; - int i; - for (i=0; i < listener_count; i++) - { - while (wait(&child_status) == -1 && errno == EINTR) - { - ; - } - debug("worker finished"); - } - - debug("tcp_listener finished"); - - printf("handled %i connections\n", *connection_count); - - return 0; -} diff --git a/regression-tests/tests/22/desc b/regression-tests/tests/22/desc deleted file mode 100644 index 0882b9c..0000000 --- a/regression-tests/tests/22/desc +++ /dev/null @@ -1,3 +0,0 @@ -Two Slave Machine configs referencing the same machine - -https://github.com/jpirko/lnst/issues/32 diff --git a/regression-tests/tests/22/lnst-ctl.conf b/regression-tests/tests/22/lnst-ctl.conf deleted file mode 100644 index 9dff9d0..0000000 --- a/regression-tests/tests/22/lnst-ctl.conf +++ /dev/null @@ -1,2 +0,0 @@ -[pools] -lnst = ./pool diff --git a/regression-tests/tests/22/pool/slave1.xml b/regression-tests/tests/22/pool/slave1.xml deleted file mode 100644 index f739d2b..0000000 --- a/regression-tests/tests/22/pool/slave1.xml +++ /dev/null @@ -1,6 +0,0 @@ -<slavemachine> - <params> - <param name="hostname" value="example.com"/> - <param name="libvirt_domain" value="example"/> - </params> -</slavemachine> diff --git a/regression-tests/tests/22/pool/slave2.xml b/regression-tests/tests/22/pool/slave2.xml deleted file mode 100644 index f739d2b..0000000 --- a/regression-tests/tests/22/pool/slave2.xml +++ /dev/null @@ -1,6 +0,0 @@ -<slavemachine> - <params> - <param name="hostname" value="example.com"/> - <param name="libvirt_domain" value="example"/> - </params> -</slavemachine> diff --git a/regression-tests/tests/22/recipe.xml b/regression-tests/tests/22/recipe.xml deleted file mode 100644 index 7565af0..0000000 --- a/regression-tests/tests/22/recipe.xml +++ /dev/null @@ -1,26 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" command="ip a"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/22/run.sh b/regression-tests/tests/22/run.sh deleted file mode 100755 index 14442b2..0000000 --- a/regression-tests/tests/22/run.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -c lnst-ctl.conf -d run recipe.xml | tee test.log -rv=${PIPESTATUS[0]} - -log=`cat test.log` - -print_separator -assert_status "error" "$rv" -assert_log "error" "You have the same machine listed twice in your pool" "$log" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/23/desc b/regression-tests/tests/23/desc deleted file mode 100644 index a75ee4d..0000000 --- a/regression-tests/tests/23/desc +++ /dev/null @@ -1,3 +0,0 @@ -synced resources not visible in network namespaces - -https://github.com/jpirko/lnst/issues/93 diff --git a/regression-tests/tests/23/lnst-ctl.conf b/regression-tests/tests/23/lnst-ctl.conf deleted file mode 100644 index a4d654d..0000000 --- a/regression-tests/tests/23/lnst-ctl.conf +++ /dev/null @@ -1,2 +0,0 @@ -[environment] -test_module_dirs = ./test_modules diff --git a/regression-tests/tests/23/recipe.xml b/regression-tests/tests/23/recipe.xml deleted file mode 100644 index 1866430..0000000 --- a/regression-tests/tests/23/recipe.xml +++ /dev/null @@ -1,42 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"/> - <veth_pair> - <veth id="veth1"/> - <veth id="veth2" netns="test_ns"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </veth> - </veth_pair> - <bridge id="br"> - <slaves> - <slave id="nic1"/> - <slave id="veth1"/> - </slaves> - </bridge> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" module="IcmpPing" netns="test_ns"> - <options> - <option name="addr" value="{ip(tm2, nic1)}"/> - <option name="count" value="40"/> - <option name="interval" value="0"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/23/run.sh b/regression-tests/tests/23/run.sh deleted file mode 100755 index a972660..0000000 --- a/regression-tests/tests/23/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -touch test_modules/* - -lnst-ctl -c lnst-ctl.conf -d run recipe.xml | tee test.log -rv=${PIPESTATUS[0]} - -log=`cat test.log` - -print_separator -assert_status "pass" "$rv" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/23/test_modules/IcmpPing.py b/regression-tests/tests/23/test_modules/IcmpPing.py deleted file mode 100644 index 5b9d888..0000000 --- a/regression-tests/tests/23/test_modules/IcmpPing.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -This module defines icmp ping test - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import re -from lnst.Common.TestsCommon import TestGeneric -from lnst.Common.ExecCmd import exec_cmd - -class IcmpPing(TestGeneric): - def _compose_cmd(self): - addr = self.get_mopt("addr", opt_type="addr") - cmd = "ping %s" % addr - count = self.get_opt("count") - if count: - cmd += " -c %s" % count - interval = self.get_opt("interval") - if interval: - cmd += " -i %s" % interval - iface = self.get_opt("iface") - if iface: - cmd += " -I %s" % iface - size = self.get_opt("size") - if size: - cmd += " -s %s" % size - return cmd - - def run(self): - cmd = self._compose_cmd() - limit_rate = self.get_opt("limit_rate", default=80) - - data_stdout = exec_cmd(cmd, die_on_err=False)[0] - stat_pttr1 = r'(\d+) packets transmitted, (\d+) received' - stat_pttr2 = r'rtt min/avg/max/mdev = (\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+) ms' - - match = re.search(stat_pttr1, data_stdout) - if not match: - res_data = {"msg": "expected pattern not found"} - return self.set_fail(res_data) - - trans_pkts, recv_pkts = match.groups() - rate = int(round((float(recv_pkts) / float(trans_pkts)) * 100)) - logging.debug("Transmitted "%s", received "%s", " - "rate "%d%%", limit_rate "%d%%"" - % (trans_pkts, recv_pkts, rate, limit_rate)) - - res_data = {"rate": rate, - "limit_rate": limit_rate} - - match = re.search(stat_pttr2, data_stdout) - if match: - tmin, tavg, tmax, tmdev = [float(x) for x in match.groups()] - logging.debug("rtt min "%.3f", avg "%.3f", max "%.3f", " - "mdev "%.3f"" % (tmin, tavg, tmax, tmdev)) - - res_data["rtt_min"] = tmin - res_data["rtt_max"] = tmax - - if rate < limit_rate: - res_data["msg"] = "rate is lower than limit" - return self.set_fail(res_data) - - return self.set_pass(res_data) diff --git a/regression-tests/tests/24/desc b/regression-tests/tests/24/desc deleted file mode 100644 index 5669380..0000000 --- a/regression-tests/tests/24/desc +++ /dev/null @@ -1,6 +0,0 @@ -timeout attribute is ignored - -This is tested by setting different timeouts to background commands and parsing -logs to see if the test failed because of a timeout or finished succesfully. - -https://github.com/jpirko/lnst/issues/67 diff --git a/regression-tests/tests/24/recipe_fail.xml b/regression-tests/tests/24/recipe_fail.xml deleted file mode 100644 index 39bfe3d..0000000 --- a/regression-tests/tests/24/recipe_fail.xml +++ /dev/null @@ -1,33 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" module="IcmpPing" bg_id="test" timeout="10"> - <options> - <option name="addr" value="{ip(tm2, nic1)}"/> - <option name="count" value="70"/> - <option name="interval" value="1"/> - </options> - </run> - <wait host="tm1" bg_id="test"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/24/recipe_pass.xml b/regression-tests/tests/24/recipe_pass.xml deleted file mode 100644 index 5896c33..0000000 --- a/regression-tests/tests/24/recipe_pass.xml +++ /dev/null @@ -1,33 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.201/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="nic1" label="testnet"> - <addresses> - <address value="192.168.131.202/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run host="tm1" module="IcmpPing" bg_id="test" timeout="30"> - <options> - <option name="addr" value="{ip(tm2, nic1)}"/> - <option name="count" value="10"/> - <option name="interval" value="1"/> - </options> - </run> - <wait host="tm1" bg_id="test"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/24/run.sh b/regression-tests/tests/24/run.sh deleted file mode 100755 index 1aff4a3..0000000 --- a/regression-tests/tests/24/run.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe_fail.xml | tee test.log -rv1=${PIPESTATUS[0]} -log1=`cat test.log` - -lnst-ctl -d run recipe_pass.xml | tee test.log -rv2=${PIPESTATUS[0]} -log2=`cat test.log` - -print_separator -assert_status "fail" "$rv1" -assert_log "INFO" "RPC connection to machine \w* timed out" "$log1" -assert_status "pass" "$rv2" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/25/desc b/regression-tests/tests/25/desc deleted file mode 100644 index fd7c6b2..0000000 --- a/regression-tests/tests/25/desc +++ /dev/null @@ -1,12 +0,0 @@ -proper signal handling for bg processes in net namespaces - -When running a background process in a new network namespace signal handlers -were inherited from the namespace process lnst-slave which caused issues when -calling the interrupt command on the background process. - -This test uses two recipes - one for run command and one for run test module. -It also uses a custom IcmpPing test module that runs the ping twice this way we -can test that the whole background process is interrupted, not just the -currently running ping process. - -https://github.com/jpirko/lnst/issues/99 diff --git a/regression-tests/tests/25/recipe1.xml b/regression-tests/tests/25/recipe1.xml deleted file mode 100644 index 276061c..0000000 --- a/regression-tests/tests/25/recipe1.xml +++ /dev/null @@ -1,44 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="phy1" label="net1"/> - <veth_pair> - <veth id="in" netns="in"> - <addresses> - <address value="192.168.0.3/24"/> - </addresses> - </veth> - <veth id="out"/> - </veth_pair> - <bridge id="br"> - <slaves> - <slave id="out"/> - <slave id="phy1"/> - </slaves> - <addresses> - <address value="192.168.0.1/24"/> - </addresses> - </bridge> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="phy1" label="net1"> - <addresses> - <address value="192.168.0.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - <task> - <run command="ping -c 4 {ip(tm2,phy1)}" host="tm1" netns="in"/> - <run command="ping {ip(tm2,phy1)}" host="tm1" netns="in" bg_id="on_bg"/> - <ctl_wait seconds="2"/> - <run command="ps aux" host="tm1" netns="in"/> - <ctl_wait seconds="2"/> - <intr host="tm1" bg_id="on_bg"/> - </task> -</lnstrecipe> - diff --git a/regression-tests/tests/25/recipe2.xml b/regression-tests/tests/25/recipe2.xml deleted file mode 100644 index 30452aa..0000000 --- a/regression-tests/tests/25/recipe2.xml +++ /dev/null @@ -1,53 +0,0 @@ -<lnstrecipe> - <network> - <host id="tm1"> - <interfaces> - <eth id="phy1" label="net1"/> - <veth_pair> - <veth id="in" netns="in"> - <addresses> - <address value="192.168.0.3/24"/> - </addresses> - </veth> - <veth id="out"/> - </veth_pair> - <bridge id="br"> - <slaves> - <slave id="out"/> - <slave id="phy1"/> - </slaves> - <addresses> - <address value="192.168.0.1/24"/> - </addresses> - </bridge> - </interfaces> - </host> - <host id="tm2"> - <interfaces> - <eth id="phy1" label="net1"> - <addresses> - <address value="192.168.0.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - <task> - <run module="PktCounter" host="tm1" netns="in" bg_id="ctr"> - <options> - <option name="input_netdev_name" value="{devname(tm1,in)}"/> - </options> - </run> - <run module="PktgenTx" host="tm2"> - <options> - <option name="netdev_name" value="{devname(tm2,phy1)}"/> - <option name="pktgen_option" value="dst {ip(tm1, in)}"/> - <option name="pktgen_option" value="dst_mac {hwaddr(tm1,in)}"/> - <option name="pktgen_option" value="count 1000"/> - </options> - </run> - <ctl_wait seconds="5"/> - <intr host="tm1" bg_id="ctr"/> - </task> -</lnstrecipe> - diff --git a/regression-tests/tests/25/recipe3.xml b/regression-tests/tests/25/recipe3.xml deleted file mode 100644 index 4cdb6f4..0000000 --- a/regression-tests/tests/25/recipe3.xml +++ /dev/null @@ -1,28 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <interfaces> - <eth id="test_if" label="tnet"> - <addresses> - <address value="192.168.0.1/24" /> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <interfaces> - <eth id="test_if" label="tnet"> - <addresses> - <address value="192.168.0.2/24" /> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 120" host="testmachine1" bg_id="1" timeout="125"/> - <ctl_wait seconds="5"/> - <intr host="testmachine1" bg_id="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/25/run.sh b/regression-tests/tests/25/run.sh deleted file mode 100755 index 745a06b..0000000 --- a/regression-tests/tests/25/run.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe1.xml | tee test.log -rv1=${PIPESTATUS[0]} -log1=`cat test.log` - -lnst-ctl -d run recipe2.xml | tee test.log -rv2=${PIPESTATUS[0]} -log2=`cat test.log` - -lnst-ctl -d run recipe3.xml | tee test.log -rv3=${PIPESTATUS[0]} -log3=`cat test.log` - -print_separator -assert_status "pass" "$rv1" -assert_status "pass" "$rv2" -assert_status "pass" "$rv3" -assert_log "ERROR" "Command execution failed (exited with -2)" "$log3" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/26/desc b/regression-tests/tests/26/desc deleted file mode 100644 index b4d1721..0000000 --- a/regression-tests/tests/26/desc +++ /dev/null @@ -1,7 +0,0 @@ -always call interface deconfiguration if configuration was called - -Interface deconfiguration should always be called if configuration was called, -even if the configuration itself failed. This ensures that all internal data -structures are cleaned up. - -https://github.com/jpirko/lnst/issues/106 diff --git a/regression-tests/tests/26/recipe1.xml b/regression-tests/tests/26/recipe1.xml deleted file mode 100644 index 6f71463..0000000 --- a/regression-tests/tests/26/recipe1.xml +++ /dev/null @@ -1,46 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"/> - <eth id="phy2" label="testnet"/> - <bond id="nic1"> - <options> - <option name="mode" value="alance-rr"/> - </options> - <slaves> - <slave id="phy1"/> - <slave id="phy2"/> - </slaves> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </bond> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"/> - <eth id="phy2" label="testnet"/> - <bond id="nic1"> - <options> - <option name="mode" value="balance-rr"/> - </options> - <slaves> - <slave id="phy1"/> - <slave id="phy2"/> - </slaves> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </bond> - </interfaces> - </host> - </network> - - <task python="gre.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/26/recipe2.xml b/regression-tests/tests/26/recipe2.xml deleted file mode 100644 index 7b4cbce..0000000 --- a/regression-tests/tests/26/recipe2.xml +++ /dev/null @@ -1,46 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"/> - <eth id="phy2" label="testnet"/> - <bond id="nic1"> - <options> - <option name="mode" value="balance-rr"/> - </options> - <slaves> - <slave id="phy1"/> - <slave id="phy2"/> - </slaves> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </bond> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"/> - <eth id="phy2" label="testnet"/> - <bond id="nic1"> - <options> - <option name="mode" value="balance-rr"/> - </options> - <slaves> - <slave id="phy1"/> - <slave id="phy2"/> - </slaves> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </bond> - </interfaces> - </host> - </network> - - <task python="gre.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/26/run.sh b/regression-tests/tests/26/run.sh deleted file mode 100755 index a961ba5..0000000 --- a/regression-tests/tests/26/run.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d config_only recipe1.xml | tee test.log -rv1=${PIPESTATUS[0]} -log1=`cat test.log` - -lnst-ctl -d config_only recipe2.xml | tee test.log -rv2=${PIPESTATUS[0]} -log2=`cat test.log` - -lnst-ctl -d deconfigure - -print_separator -assert_status "error" "$rv1" -assert_log "ERROR" "CommandException: Slave testmachine1" "$log1" -assert_status "pass" "$rv2" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/27/desc b/regression-tests/tests/27/desc deleted file mode 100644 index fb66011..0000000 --- a/regression-tests/tests/27/desc +++ /dev/null @@ -1,10 +0,0 @@ -Check timeout handling for commands run in background and foreground. - -1. put a command on bg and intr() it before desired timeout -2. put a command on bg and intr() it after desired timeout -3. put a command on bg and immediately wait for it's completion before timeout -4. put a command on bg and immediately wait for it's completion after timeout -5. put a command on bg and wait for it not earlier after it's completed -6. put a command on fg and set timeout longer than expected completion -7. put a command on fg and set timeout shorter than expected completion - diff --git a/regression-tests/tests/27/recipe1.xml b/regression-tests/tests/27/recipe1.xml deleted file mode 100644 index 56b1ff6..0000000 --- a/regression-tests/tests/27/recipe1.xml +++ /dev/null @@ -1,32 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 10" host="testmachine1" bg_id="1" timeout="15"/> - <ctl_wait seconds="2"/> - <intr host="testmachine1" bg_id="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe2.xml b/regression-tests/tests/27/recipe2.xml deleted file mode 100644 index c7a60dc..0000000 --- a/regression-tests/tests/27/recipe2.xml +++ /dev/null @@ -1,32 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 5" host="testmachine1" bg_id="2" timeout="5"/> - <ctl_wait seconds="7"/> - <intr host="testmachine1" bg_id="2"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe3.xml b/regression-tests/tests/27/recipe3.xml deleted file mode 100644 index 83510a1..0000000 --- a/regression-tests/tests/27/recipe3.xml +++ /dev/null @@ -1,31 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 5" host="testmachine1" bg_id="3" timeout="3"/> - <wait host="testmachine1" bg_id="3"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe4.xml b/regression-tests/tests/27/recipe4.xml deleted file mode 100644 index b9f1fe2..0000000 --- a/regression-tests/tests/27/recipe4.xml +++ /dev/null @@ -1,31 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 5" host="testmachine1" bg_id="4" timeout="7"/> - <wait host="testmachine1" bg_id="4"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe5.xml b/regression-tests/tests/27/recipe5.xml deleted file mode 100644 index f7ac10c..0000000 --- a/regression-tests/tests/27/recipe5.xml +++ /dev/null @@ -1,32 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 10" host="testmachine1" bg_id="1"/> - <ctl_wait seconds="15"/> - <wait host="testmachine1" bg_id="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe6.xml b/regression-tests/tests/27/recipe6.xml deleted file mode 100644 index 0dac603..0000000 --- a/regression-tests/tests/27/recipe6.xml +++ /dev/null @@ -1,30 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 5" host="testmachine1" timeout="10"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe7.xml b/regression-tests/tests/27/recipe7.xml deleted file mode 100644 index bcc8c2c..0000000 --- a/regression-tests/tests/27/recipe7.xml +++ /dev/null @@ -1,30 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 5" host="testmachine1" timeout="3"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/recipe8.xml b/regression-tests/tests/27/recipe8.xml deleted file mode 100644 index 9809b17..0000000 --- a/regression-tests/tests/27/recipe8.xml +++ /dev/null @@ -1,32 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - <address>fe01::1/64</address> - </addresses> - </eth> - </interfaces> - </host> - <host id="testmachine2"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.3/24</address> - <address>fe01::2/64</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="sleep 10" host="testmachine1" bg_id="1"/> - <ctl_wait seconds="2"/> - <intr host="testmachine1" bg_id="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/27/run.sh b/regression-tests/tests/27/run.sh deleted file mode 100755 index e61da3f..0000000 --- a/regression-tests/tests/27/run.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe1.xml | tee test.log -rv1=${PIPESTATUS[0]} -log1=`cat test.log` - -lnst-ctl -d run recipe2.xml | tee test.log -rv2=${PIPESTATUS[0]} -log2=`cat test.log` - -lnst-ctl -d run recipe3.xml | tee test.log -rv3=${PIPESTATUS[0]} -log3=`cat test.log` - -lnst-ctl -d run recipe4.xml | tee test.log -rv4=${PIPESTATUS[0]} -log4=`cat test.log` - -lnst-ctl -d run recipe5.xml | tee test.log -rv5=${PIPESTATUS[0]} -log5=`cat test.log` - -lnst-ctl -d run recipe6.xml | tee test.log -rv6=${PIPESTATUS[0]} -log6=`cat test.log` - -lnst-ctl -d run recipe7.xml | tee test.log -rv7=${PIPESTATUS[0]} -log7=`cat test.log` - -print_separator -assert_status "pass" "$rv1" -assert_status "pass" "$rv2" -assert_status "fail" "$rv3" -assert_log "INFO" "RPC connection to machine testmachine1 timed out" "$log3" -assert_status "pass" "$rv4" -assert_status "pass" "$rv5" -assert_status "pass" "$rv6" -assert_status "fail" "$rv7" -assert_log "INFO" "RPC connection to machine testmachine1 timed out" "$log7" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/28/desc b/regression-tests/tests/28/desc deleted file mode 100644 index 8d4477b..0000000 --- a/regression-tests/tests/28/desc +++ /dev/null @@ -1,6 +0,0 @@ -Check if a user can get result data especially stdout of a background process. - -1. by calling intr() -2. by calling wait() -3. by calling kill() -4. when process is not run on background diff --git a/regression-tests/tests/28/recipe1.py b/regression-tests/tests/28/recipe1.py deleted file mode 100644 index ed19f23..0000000 --- a/regression-tests/tests/28/recipe1.py +++ /dev/null @@ -1,20 +0,0 @@ -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("testmachine1") - -m1.sync_resources(modules=["Custom"], tools=[]) - -test = m1.run("while true; do echo test; sleep 1; done", bg=True) - -ctl.wait(5) - -test.intr() - -output = test.get_result()["res_data"]["stdout"] - -custom = ctl.get_module("Custom", options={ "fail": True }) - -if output.find("test") != -1: - custom.update_options({ "fail": False}) - -m1.run(custom) diff --git a/regression-tests/tests/28/recipe1.xml b/regression-tests/tests/28/recipe1.xml deleted file mode 100644 index cf6bee0..0000000 --- a/regression-tests/tests/28/recipe1.xml +++ /dev/null @@ -1,16 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task python="recipe1.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/28/recipe2.py b/regression-tests/tests/28/recipe2.py deleted file mode 100644 index 7b739bb..0000000 --- a/regression-tests/tests/28/recipe2.py +++ /dev/null @@ -1,18 +0,0 @@ -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("testmachine1") - -m1.sync_resources(modules=["Custom"], tools=[]) - -test = m1.run("for i in `seq 5`; do echo test; sleep 1; done", bg=True) - -test.wait() - -output = test.get_result()["res_data"]["stdout"] - -custom = ctl.get_module("Custom", options={ "fail": True }) - -if output.find("test") != -1: - custom.update_options({ "fail": False}) - -m1.run(custom) diff --git a/regression-tests/tests/28/recipe2.xml b/regression-tests/tests/28/recipe2.xml deleted file mode 100644 index 1cd8070..0000000 --- a/regression-tests/tests/28/recipe2.xml +++ /dev/null @@ -1,16 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task python="recipe2.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/28/recipe3.py b/regression-tests/tests/28/recipe3.py deleted file mode 100644 index 9d9fd9b..0000000 --- a/regression-tests/tests/28/recipe3.py +++ /dev/null @@ -1,11 +0,0 @@ -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("testmachine1") - -m1.sync_resources(modules=["Custom"], tools=[]) - -test = m1.run("while true; do echo test; sleep 1; done", bg=True) - -ctl.wait(5) - -test.kill() diff --git a/regression-tests/tests/28/recipe3.xml b/regression-tests/tests/28/recipe3.xml deleted file mode 100644 index 2602c68..0000000 --- a/regression-tests/tests/28/recipe3.xml +++ /dev/null @@ -1,16 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task python="recipe3.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/28/recipe4.py b/regression-tests/tests/28/recipe4.py deleted file mode 100644 index ae36c37..0000000 --- a/regression-tests/tests/28/recipe4.py +++ /dev/null @@ -1,15 +0,0 @@ -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("testmachine1") - -m1.sync_resources(modules=["Custom"], tools=[]) - -test = m1.run("echo test") -output = test.get_result()["res_data"]["stdout"] - -custom = ctl.get_module("Custom", options={ "fail": True }) - -if output.find("test") != -1: - custom.update_options({ "fail": False}) - -m1.run(custom) diff --git a/regression-tests/tests/28/recipe4.xml b/regression-tests/tests/28/recipe4.xml deleted file mode 100644 index fd2452c..0000000 --- a/regression-tests/tests/28/recipe4.xml +++ /dev/null @@ -1,16 +0,0 @@ -<lnstrecipe> - <network> - <host id="testmachine1"> - <params/> - <interfaces> - <eth id="phy1" label="testnet"> - <addresses> - <address>192.168.100.2/24</address> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task python="recipe4.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/28/run.sh b/regression-tests/tests/28/run.sh deleted file mode 100755 index 9901282..0000000 --- a/regression-tests/tests/28/run.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe1.xml | tee test.log -rv1=${PIPESTATUS[0]} -log1=`cat test.log` - -lnst-ctl -d run recipe2.xml | tee test.log -rv2=${PIPESTATUS[0]} -log2=`cat test.log` - -lnst-ctl -d run recipe3.xml | tee test.log -rv3=${PIPESTATUS[0]} -log3=`cat test.log` - -lnst-ctl -d run recipe4.xml | tee test.log -rv4=${PIPESTATUS[0]} -log4=`cat test.log` - -print_separator -assert_status "pass" "$rv1" -assert_status "pass" "$rv2" -assert_status "pass" "$rv3" -assert_status "pass" "$rv4" -assert_log "INFO" "stdout:.*test" "$log1" -assert_log "INFO" "stdout:.*test" "$log2" -assert_log "INFO" "stdout:.*test" "$log4" - -rm -f test.log - -end_test diff --git a/regression-tests/tests/3/desc b/regression-tests/tests/3/desc deleted file mode 100644 index 8669094..0000000 --- a/regression-tests/tests/3/desc +++ /dev/null @@ -1,8 +0,0 @@ -Check corner case in matching algorithm - -This test checks that controller fails if it runs a recipe with just one -machine specified. The controller should fail. - -UPDATE: -This is now supported in new lnst versions, the controller therefore shoudln't -fail. Changing the recipe.xml and run.sh to reflect this. diff --git a/regression-tests/tests/3/recipe.xml b/regression-tests/tests/3/recipe.xml deleted file mode 100644 index 1e7845d..0000000 --- a/regression-tests/tests/3/recipe.xml +++ /dev/null @@ -1,21 +0,0 @@ -<lnstrecipe> - <network> - <host id="client"> - <interfaces> - <eth id="nic1" label="inet"> - <addresses> - <address value="192.168.200.3/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - <task> - <run module="IcmpPing" host="client"> - <options> - <option name="addr" value="{ip(client,nic1)}"/> - <option name="count" value="40"/> - </options> - </run> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/3/run.sh b/regression-tests/tests/3/run.sh deleted file mode 100755 index 50ab9ce..0000000 --- a/regression-tests/tests/3/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/4/desc b/regression-tests/tests/4/desc deleted file mode 100644 index ad44b34..0000000 --- a/regression-tests/tests/4/desc +++ /dev/null @@ -1,3 +0,0 @@ -Aliases resolving - -This test aims to verify the correctness of aliases resloving. diff --git a/regression-tests/tests/4/recipe.xml b/regression-tests/tests/4/recipe.xml deleted file mode 100644 index bc0c4b4..0000000 --- a/regression-tests/tests/4/recipe.xml +++ /dev/null @@ -1,43 +0,0 @@ -<lnstrecipe> - <define> - <alias name="one" value="192.168.100.10/24"/> - <alias name="two" value="192.168.100.11/24"/> - </define> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="{$one}"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="{$two}"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <define> - <alias name="one" value="one"/> - <alias name="two" value="two"/> - </define> - - <task> - <run command="echo 1_{$one}_{$two}" host="1"/> - <define> - <alias name="one" value="eno"/> - <alias name="two" value="owt"/> - </define> - <run command="echo 2_{$one}_{$two}" host="1"/> - </task> - <task> - <run command="echo 3_{$one}_{$two}" host="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/4/run.sh b/regression-tests/tests/4/run.sh deleted file mode 100755 index f3d8ee2..0000000 --- a/regression-tests/tests/4/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -log="`lnst-ctl -d run recipe.xml`" -rv=$? - -echo "$log" -print_separator - -assert_log "DEBUG" "echo 1_one_two" "$log" -assert_log "DEBUG" "echo 2_eno_owt" "$log" -assert_log "DEBUG" "echo 3_one_two" "$log" - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/5/desc b/regression-tests/tests/5/desc deleted file mode 100644 index 7f3448f..0000000 --- a/regression-tests/tests/5/desc +++ /dev/null @@ -1,3 +0,0 @@ -Template functions resolving - -This test aims to verify the correctness of template functions resloving. diff --git a/regression-tests/tests/5/recipe.xml b/regression-tests/tests/5/recipe.xml deleted file mode 100644 index 1bc9137..0000000 --- a/regression-tests/tests/5/recipe.xml +++ /dev/null @@ -1,29 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="echo ip1_{ip(1,testiface)}_" host="1"/> - <run command="echo ip2_{ip(1,testiface,0)}_" host="1"/> - <run command="echo devname_{devname(1,testiface)}_" host="1"/> - <run command="echo hwaddr_{hwaddr(1,testiface)}_" host="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/5/run.sh b/regression-tests/tests/5/run.sh deleted file mode 100755 index f19786e..0000000 --- a/regression-tests/tests/5/run.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -log="`lnst-ctl -d run recipe.xml`" -rv=$? - -echo "$log" -print_separator - -assert_log "DEBUG" "echo ip1_192.168.100.10_" "$log" -assert_log "DEBUG" "echo ip2_192.168.100.10_" "$log" -assert_log "DEBUG" "echo hwaddr_([a-fA-F0-9]{2}:?){6}_" "$log" -assert_log "DEBUG" "echo devname_[a-zA-Z0-9]+_" "$log" - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/6/desc b/regression-tests/tests/6/desc deleted file mode 100644 index f75fb3d..0000000 --- a/regression-tests/tests/6/desc +++ /dev/null @@ -1,4 +0,0 @@ -Dynamic hwaddr updates - -This test case can verify whether the dynamic configuration updates are -propagated to the controller properly. diff --git a/regression-tests/tests/6/recipe.xml b/regression-tests/tests/6/recipe.xml deleted file mode 100644 index 1f084d0..0000000 --- a/regression-tests/tests/6/recipe.xml +++ /dev/null @@ -1,35 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="echo `ip link show {devname(1,testiface)} | grep -o ' link/ether \([0-9a-fA-F]\{2\}:\?\)\{6\}' | cut -c 16-` >/tmp/lnst-hwaddr" host="1"/> - <run command="echo 1_{hwaddr(1, testiface)}_" host="1"/> - <run command="ip l set {devname(1, testiface)} address 52:54:00:12:34:56" host="1"/> - <ctl_wait seconds="2"/> - <run command="echo 2_{hwaddr(1, testiface)}_" host="1"/> - <run command="ip l set {devname(1, testiface)} address `cat /tmp/lnst-hwaddr`" host="1"/> - <ctl_wait seconds="2"/> - <run command="echo 3_{hwaddr(1, testiface)}_`cat /tmp/lnst-hwaddr | tr '[:lower:]' '[:upper:]'`_" host="1"/> - <run command="rm -f /tmp/lnst-hwaddr" host="1"/> - </task> -</lnstrecipe> - diff --git a/regression-tests/tests/6/run.sh b/regression-tests/tests/6/run.sh deleted file mode 100755 index 02534e0..0000000 --- a/regression-tests/tests/6/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -log=`lnst-ctl -d run recipe.xml` -rv=$? - -echo "$log" -print_separator - -assert_log ".*" "1_([a-fA-F0-9]{2}:?){6}_" "$log" -assert_log ".*" "2_52:54:00:12:34:56_" "$log" -assert_log ".*" "3_(([a-fA-F0-9]{2}:?){6})_\1_" "$log" - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/7/desc b/regression-tests/tests/7/desc deleted file mode 100644 index 4a68dd6..0000000 --- a/regression-tests/tests/7/desc +++ /dev/null @@ -1,4 +0,0 @@ -Configuration updates (hwaddr) in python tasks - -The purpose of this test is to verify that the configuration updates -propagate correctly from the slaves back to controller. diff --git a/regression-tests/tests/7/recipe.xml b/regression-tests/tests/7/recipe.xml deleted file mode 100644 index 88f26f8..0000000 --- a/regression-tests/tests/7/recipe.xml +++ /dev/null @@ -1,24 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task python="task.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/7/run.sh b/regression-tests/tests/7/run.sh deleted file mode 100755 index 02534e0..0000000 --- a/regression-tests/tests/7/run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -log=`lnst-ctl -d run recipe.xml` -rv=$? - -echo "$log" -print_separator - -assert_log ".*" "1_([a-fA-F0-9]{2}:?){6}_" "$log" -assert_log ".*" "2_52:54:00:12:34:56_" "$log" -assert_log ".*" "3_(([a-fA-F0-9]{2}:?){6})_\1_" "$log" - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/7/task.py b/regression-tests/tests/7/task.py deleted file mode 100644 index 640061e..0000000 --- a/regression-tests/tests/7/task.py +++ /dev/null @@ -1,23 +0,0 @@ -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("1") -m2 = ctl.get_host("2") - -devname = m1.get_devname("testiface") -hwaddr = m1.get_hwaddr("testiface") - -m1.run("echo 1_%s_" % hwaddr) - -m1.run("echo `ip link show %s | grep -o ' link/ether ([0-9a-fA-F]{2}:?){6}' | cut -c 16-` >/tmp/lnst-hwaddr" % devname) -m1.run("ip l set %s address 52:54:00:12:34:56" % devname) -ctl.wait(2) - -m1.run("echo 2_%s_" % hwaddr) -m1.run("ip l set %s address `cat /tmp/lnst-hwaddr`" % devname) - -ctl.wait(2) - -m1.run("echo 3_%s_`cat /tmp/lnst-hwaddr | tr '[:lower:]' '[:upper:]'`_" % hwaddr) - -m1.run("rm -f /tmp/lnst-hwaddr") - diff --git a/regression-tests/tests/8/desc b/regression-tests/tests/8/desc deleted file mode 100644 index 41c2ca2..0000000 --- a/regression-tests/tests/8/desc +++ /dev/null @@ -1,3 +0,0 @@ -Recipe Summary Crashing when Exec fails - -Regression test for a bug diff --git a/regression-tests/tests/8/recipe.xml b/regression-tests/tests/8/recipe.xml deleted file mode 100644 index dc3a692..0000000 --- a/regression-tests/tests/8/recipe.xml +++ /dev/null @@ -1,26 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task> - <run command="eecho weeee" host="1"/> - </task> -</lnstrecipe> diff --git a/regression-tests/tests/8/run.sh b/regression-tests/tests/8/run.sh deleted file mode 100755 index 1eefc21..0000000 --- a/regression-tests/tests/8/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl -d run recipe.xml -rv=$? - -assert_status "fail" "$rv" - -end_test diff --git a/regression-tests/tests/9/desc b/regression-tests/tests/9/desc deleted file mode 100644 index 2e71f6a..0000000 --- a/regression-tests/tests/9/desc +++ /dev/null @@ -1,3 +0,0 @@ -Python Tasks - -Basic sanity of python tasks implementation (a simple ping test). diff --git a/regression-tests/tests/9/recipe.xml b/regression-tests/tests/9/recipe.xml deleted file mode 100644 index 88f26f8..0000000 --- a/regression-tests/tests/9/recipe.xml +++ /dev/null @@ -1,24 +0,0 @@ -<lnstrecipe> - <network> - <host id="1"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.10/24"/> - </addresses> - </eth> - </interfaces> - </host> - <host id="2"> - <interfaces> - <eth label="tnet" id="testiface"> - <addresses> - <address value="192.168.100.11/24"/> - </addresses> - </eth> - </interfaces> - </host> - </network> - - <task python="task.py"/> -</lnstrecipe> diff --git a/regression-tests/tests/9/run.sh b/regression-tests/tests/9/run.sh deleted file mode 100755 index 45e9995..0000000 --- a/regression-tests/tests/9/run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. ../lib.sh - -init_test - -lnst-ctl run recipe.xml -rv=$? - -assert_status "pass" "$rv" - -end_test diff --git a/regression-tests/tests/9/task.py b/regression-tests/tests/9/task.py deleted file mode 100644 index e718537..0000000 --- a/regression-tests/tests/9/task.py +++ /dev/null @@ -1,9 +0,0 @@ -from lnst.Controller.Task import ctl - -m1 = ctl.get_host("1") -m2 = ctl.get_host("2") - -ping_mod = ctl.get_module("IcmpPing", options={"addr": m2.get_ip("testiface", 0), - "count":40, "interval": 0.2, "limit_rate": 95}) - -ping_test = m1.run(ping_mod, timeout=30) diff --git a/regression-tests/tests/lib.sh b/regression-tests/tests/lib.sh deleted file mode 100644 index 5286534..0000000 --- a/regression-tests/tests/lib.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -function init_test -{ - # test status 0 means everything went fine, 1 means there were - # one or more problems. - test_status=0 -} - -function end_test -{ - exit "$test_status" -} - -function assert_log -{ - local level="$1" - local message_regexp="$2" - local log="$3" - - if [ -z "`echo "$log" | grep "$level" | grep "$message_regexp"`" ]; then - echo "assert_log FAILED ($level, $message_regexp)" - test_status=1 - else - echo "assert_log PASSED ($level, $message_regexp)" - fi -} - -function assert_status -{ - local expect="$1" - local retval="$2" - - case $expect in - "pass") - local value=0 ;; - "fail") - local value=1 ;; - "error") - local value=2 ;; - *) - echo "Unknown exit status '$expect'!" - exit 128 - ;; - esac - - if [ $value -ne $retval ]; then - test_status=1 - echo "assert_status FAILED (expected: $value, real: $retval)" - else - echo "assert_status PASSED (expected: $value, real: $retval)" - fi -} - -function print_separator -{ - echo "--------------------------------------------------------------------------------" -} - -function lnst-ctl -{ - if [ "$use_user_conf" = "true" ]; then - command lnst-ctl $@ - else - command lnst-ctl -c $repo/lnst-ctl.conf $@ - fi -}
The NetTestCommand module is deprecated and will be removed.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Controller/Job.py | 3 ++- lnst/Controller/Namespace.py | 2 +- lnst/Controller/NetNamespace.py | 1 - 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/Job.py b/lnst/Controller/Job.py index 3e5b3e6..1ec85e3 100644 --- a/lnst/Controller/Job.py +++ b/lnst/Controller/Job.py @@ -14,10 +14,11 @@ olichtne@redhat.com (Ondrej Lichtner) import logging import signal from lnst.Common.JobError import JobError -from lnst.Common.NetTestCommand import DEFAULT_TIMEOUT from lnst.Tests.BaseTestModule import BaseTestModule from lnst.Controller.RecipeResults import ResultLevel
+DEFAULT_TIMEOUT = 60 + class Job(object): """Tester facing Job API
diff --git a/lnst/Controller/Namespace.py b/lnst/Controller/Namespace.py index 6d96e7d..49d25dc 100644 --- a/lnst/Controller/Namespace.py +++ b/lnst/Controller/Namespace.py @@ -16,7 +16,7 @@ olichtne@redhat.com (Ondrej Lichtner)
import logging from abc import ABCMeta -from lnst.Common.NetTestCommand import DEFAULT_TIMEOUT +from lnst.Controller.Job import DEFAULT_TIMEOUT from lnst.Devices.Device import Device from lnst.Devices.VirtualDevice import VirtualDevice from lnst.Devices.RemoteDevice import RemoteDevice diff --git a/lnst/Controller/NetNamespace.py b/lnst/Controller/NetNamespace.py index aa5b777..cb04b25 100644 --- a/lnst/Controller/NetNamespace.py +++ b/lnst/Controller/NetNamespace.py @@ -12,7 +12,6 @@ olichtne@redhat.com (Ondrej Lichtner) """
import logging -from lnst.Common.NetTestCommand import DEFAULT_TIMEOUT from lnst.Devices.VirtualDevice import VirtualDevice from lnst.Devices.RemoteDevice import RemoteDevice from lnst.Controller.Namespace import Namespace
This has been deprecated by lnst/Tests/BaseTestModule.py
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Common/TestsCommon.py | 147 ------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 lnst/Common/TestsCommon.py
diff --git a/lnst/Common/TestsCommon.py b/lnst/Common/TestsCommon.py deleted file mode 100644 index 471d720..0000000 --- a/lnst/Common/TestsCommon.py +++ /dev/null @@ -1,147 +0,0 @@ -""" -This module defines common test stuff - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import re -import logging -import os -import signal -import time -from lnst.Common.NetTestCommand import NetTestCommandGeneric -from lnst.Common.LnstError import LnstError - -class testLogger(logging.Logger): - def __init__(self, name, level=logging.NOTSET): - logging.Logger.__init__(self, name, level) - - def findCaller(self): - """ - Find the stack frame of the caller so that we can note the source - file name, line number and function name. - """ - f = logging.currentframe() - #On some versions of IronPython, currentframe() returns None if - #IronPython isn't run with -X:Frames. - if f is not None: - f = f.f_back.f_back - rv = "(unknown file)", 0, "(unknown function)" - while hasattr(f, "f_code"): - co = f.f_code - filename = os.path.normcase(co.co_filename) - if filename == logging._srcfile: - f = f.f_back.f_back - continue - rv = (filename, f.f_lineno, co.co_name) - break - return rv - -logging._acquireLock() -try: - logging.setLoggerClass(testLogger) - logging.getLogger("root.testLogger") - logging.setLoggerClass(logging.Logger) -finally: - logging._releaseLock() - -class TestOptionMissing(LnstError): - pass - -class TestGeneric(NetTestCommandGeneric): - def __init__(self, command): - self._testLogger = logging.getLogger("root.testLogger") - NetTestCommandGeneric.__init__(self, command) - - def wait_on_interrupt(self): - ''' - Should be used by test implementation for waiting on SIGINT - ''' - try: - handler = signal.getsignal(signal.SIGINT) - signal.signal(signal.SIGINT, signal.default_int_handler) - while True: - time.sleep(1) - except KeyboardInterrupt: - pass - finally: - signal.signal(signal.SIGINT, handler) - - def _get_val(self, value, opt_type, default): - if opt_type == "addr": - ''' - If address type is specified do "slashcut" - ''' - return re.sub(r'/.*', r'', value) - - if default != None: - ''' - In case a default value is passed, retype value - by the default value type. - ''' - return (type(default))(value) - - return value - - def get_opt(self, name, multi=False, mandatory=False, opt_type="", default=None): - try: - option = self._command["options"][name] - except KeyError: - if mandatory: - raise TestOptionMissing("Missing option '%s'!" % name) - if multi: - return [default] - else: - return default - - if multi: - value = [] - for op in option: - value.append(self._get_val(op["value"], opt_type, default)) - else: - value = self._get_val(option[0]["value"], opt_type, default) - - return value - - def get_mopt(self, name, opt_type=""): - ''' - This should be used to get mandatory options - ''' - return self.get_opt(name, mandatory=True, opt_type=opt_type) - - def get_multi_opt(self, name, mandatory=False, opt_type="", default=None): - ''' - This should be used to get multi options (array of values) - ''' - return self.get_opt(name, multi=True, mandatory=mandatory, - opt_type=opt_type, default=default) - - def get_multi_mopt(self, name, opt_type=""): - ''' - This should be used to get mandatory multi options (array of values) - ''' - return self.get_multi_opt(name, mandatory=True, opt_type=opt_type) - - def get_single_opts(self): - opts = {} - for key in self._command["options"]: - item = self._command["options"][key] - if len(item) == 1: - opts[key] = item[0]["value"] - return opts - - def _format_cmd_res_header(self): - cmd_val = self._command["module"] - cmd_type = self._command["type"] - if "bg_id" in self._command: - bg_id = " bg_id: %s" % self._command["bg_id"] - else: - bg_id = "" - cmd = "%-9s%s%s" %(cmd_type, cmd_val, bg_id) - return cmd
This has been deprecated by lnst/Controller/Job.py
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Common/NetTestCommand.py | 571 ---------------------------------- 1 file changed, 571 deletions(-) delete mode 100644 lnst/Common/NetTestCommand.py
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py deleted file mode 100644 index 2a39611..0000000 --- a/lnst/Common/NetTestCommand.py +++ /dev/null @@ -1,571 +0,0 @@ -""" -This module defines classes of test commands - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import os -import sys -import signal -import imp -import multiprocessing -import re -from time import time -from lnst.Common.ExecCmd import exec_cmd, ExecCmdFail -from lnst.Common.ConnectionHandler import send_data -from lnst.Common.Logs import log_exc_traceback -from lnst.Common.LnstError import LnstError - -DEFAULT_TIMEOUT = 60 - -def str_command(command): - attrs = ["type(%s)" % command["type"]] - if command["type"] == "test": - attrs.append("module(%s)" % command["module"]) - attrs.append("host(%s)" % command["host"]) - - if "bg_id" in command: - attrs.append("bg_id(%s)" % command["bg_id"]) - if "timeout" in command: - attrs.append("timeout(%s)" % command["timeout"]) - elif command["type"] == "exec": - attrs.append("command(%s)" % command["command"]) - attrs.append("host(%s)" % command["host"]) - - if "from" in command: - attrs.append("from(%s)" % command["from"]) - if "bg_id" in command: - attrs.append("bg_id(%s)" % command["bg_id"]) - if "timeout" in command: - attrs.append("timeout(%s)" % command["timeout"]) - elif command["type"] in ["wait", "intr", "kill"]: - attrs.append("host(%s)" % command["host"]) - attrs.append("bg_id(%s)" % command["proc_id"]) - elif command["type"] == "config": - attrs.append("host(%s)" % command["host"]) - - if "option" in command: - attrs.append("option(%s)" % command["option"]) - if "value" in command: - attrs.append("value(%s)" % command["value"]) - elif command["type"] == "ctl_wait": - attrs.append("seconds(%s)" % command["seconds"]) - else: - raise RuntimeError("Unknown command type '%s'" % command["type"]) - - if "netns" in command: - attrs.append("netns(%s)" % command["netns"]) - - return ", ".join(attrs) - -class CommandException(LnstError): - """Base class for client errors.""" - def __init__(self, command): - self.command = command - - def __str__(self): - return "CommandException: " + str(self.command) - -class BgCommandException(CommandException): - """Base class for background command errors.""" - def __init__(self, str): - self._str = str - - def __str__(self): - return "BgCommandError: " + self._str - - -class NetTestCommand: - def __init__(self, command_context, command, resource_table, log_ctl): - self._cmd_cls = get_command_class(command_context, command, - resource_table) - self._command_context = command_context - self._command = command - - self._process = None - self._id = None - self._read_pipe = None - self._write_pipe = None - self._connection_pipe = None - self._killed = False - self._finished = False - self._control_cmd= None - self._result = None - self._log_ctl = log_ctl - self._start_time = None - self._result_sent = False - - if "bg_id" not in self._command: - self._id = None - else: - self._id = self._command["bg_id"] - - def get_id(self): - return self._id - - def forked(self): - return self._process != None - - def set_result_sent(self, value=True): - self._result_sent = value - - def get_result_sent(self): - return self._result_sent - - def finished(self): - return self._finished - - def run(self): - self._start_time = time() - if isinstance(self._cmd_cls, NetTestCommandControl) or \ - isinstance(self._cmd_cls, NetTestCommandConfig): - return self._cmd_cls.run() - - self._read_pipe, self._write_pipe = multiprocessing.Pipe() - self._process = multiprocessing.Process(target=self._run) - - self._process.daemon = False - self._process.start() - self._pid = self._process.pid - - self._connection_pipe = self._read_pipe - - if not self._id: - logging.debug("Running command with" - " pid "%d"" % (self._pid)) - return None - else: - logging.debug("Running in background with" - " bg_id "%s" pid "%d"" % (self._id, self._pid)) - return {"passed": True, - "res_header": self._cmd_cls._format_cmd_res_header(), - "msg": "Running in background."} - - def _sig_ign(self, signum, frame): - pass - - def _run(self): - os.setpgrp() - signal.signal(signal.SIGHUP, self._sig_ign) - signal.signal(signal.SIGINT, self._sig_ign) - signal.signal(signal.SIGTERM, self._sig_ign) - - self._connection_pipe = self._write_pipe - - self._log_ctl.disable_logging() - self._log_ctl.set_connection(self._connection_pipe) - - result = {} - try: - self._cmd_cls.run() - except (KeyboardInterrupt, SystemExit): - pass - except: - log_exc_traceback() - type, value, tb = sys.exc_info() - data = {"Exception": "%s" % value} - self._cmd_cls.set_fail(data) - finally: - res_data = self._cmd_cls.get_result() - result["type"] = "result" - result["cmd_id"] = self._id - result["result"] = res_data - - send_data(self._write_pipe, result) - self._write_pipe.close() - - def join(self): - self._process.join() - - def wait_for(self, cmd): - logging.debug("Waiting for background command with id "%s", pid "%d"" % (self._id, self._pid)) - self._finished = True - self._control_cmd = cmd - - def interrupt(self, cmd): - self._finished = True - if os.path.exists("/proc/%d" % self._pid): - logging.debug("Interrupting background command with id "%s", pid "%d"" % (self._id, self._pid)) - os.killpg(os.getpgid(self._pid), signal.SIGINT) - self._control_cmd = cmd - - def kill(self, cmd): - if os.path.exists("/proc/%d" % self._pid): - if self._id: - logging.debug("Killing background command with id "%s", pid "%d"" % (self._id, self._pid)) - else: - logging.debug("Killing command with pid "%d"" % self._pid) - self._killed = True - os.killpg(os.getpgid(self._pid), signal.SIGKILL) - self._process.join() - self._control_cmd = cmd - - def get_result(self): - if self._killed: - self._cmd_cls.set_pass() - result = self._cmd_cls.get_result() - result["passed"] = True - result["msg"] = "Command killed." - result["killed"] = True - self._result = result - - return self._result - - def set_result(self, result): - if self._control_cmd != None: - result["res_header"] = self._control_cmd._format_cmd_res_header() - self._result = result - - def get_connection_pipe(self): - return self._connection_pipe - - def get_type(self): - return self._command["type"] - -class NetTestCommandContext: - def __init__(self): - self._dict = {} - - def add_cmd(self, cmd): - self._dict[cmd.get_id()] = cmd - - def del_cmd(self, cmd): - del self._dict[cmd.get_id()] - - def get_cmd(self, id): - if id in self._dict: - return self._dict[id] - else: - return None - - def _kill_all_cmds(self): - for id in self._dict: - self._dict[id].kill(None) - - def cleanup(self): - logging.debug("Cleaning up leftover processes.") - self._kill_all_cmds() - self._dict = {} - - def get_read_pipes(self): - pipes = {} - for key in self._dict: - pipe = self._dict[key].get_connection_pipe() - if pipe != None: - pipes[key] = pipe - return pipes - -def NetTestCommandTest(command, resource_table): - test_name = command["module"] - if not test_name in resource_table["module"]: - msg = "Test module '%s' not found" % test_name - raise Exception(msg) - - module_path = resource_table["module"][test_name] - module_name = test_name - - module = imp.load_source(module_name, module_path) - test_class = getattr(module, module_name) - return test_class(command) - -class NetTestCommandGeneric(object): - def __init__(self, command): - self._command = command - self._result = None - self._resource_table = None - - def run(self): - pass - - def get_result(self): - if not self._result: - ''' - In case result is not set yet, it most likely means that - command was killed. So set pass in this case - ''' - self.set_pass() - return self._result - - def set_fail(self, res_data=None): - res = False - msg = "" - if "expect" in self._command and self._command["expect"] == False: - res = True - msg = "Command failed, as was specified in the recipe." - result = {"passed": res, - "res_data": res_data, - "msg": msg, - "report": self.format_res_data(res_data), - "res_header": self._format_cmd_res_header()} - self._result = result - return result - - def set_pass(self, res_data=None): - res = True - msg = "" - if "expect" in self._command and self._command["expect"] == False: - res = False - msg = "Command expected to fail, but passed!" - result = {"passed": res, - "res_data": res_data, - "msg": msg, - "report": self.format_res_data(res_data), - "res_header": self._format_cmd_res_header()} - self._result = result - return result - - def format_res_data(self, res_data, level=0): - self._check_res_data(res_data) - formatted_data = "" - if res_data: - max_key_len = 0 - for key in list(res_data.keys()): - if len(key) > max_key_len: - max_key_len = len(key) - for key, value in list(res_data.items()): - if type(value) == dict: - formatted_data += level*4*" " + str(key) + ":\n" - formatted_data += self.format_res_data(value, level+1) - if type(value) == list: - formatted_data += level*4*" " + str(key) + ":\n" - for i in range(0, len(value)): - formatted_data += (level+1)*4*" " +\ - "item %d:" % (i+1) + "\n" - formatted_data += self.format_res_data(value[i], - level+2) - else: - formatted_data += level*4*" " + str(key) + ":" + \ - (max_key_len-len(key))*" " + \ - "\t" + str(value) + "\n" - - return formatted_data - - def _check_res_data(self, res_data): - name_start_char = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF"\ - "\u0370-\u037D\u037F-\u1FFF\u200C-\u200D"\ - "\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF"\ - "\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF" - name_char = name_start_char + "-.0-9\xB7\u0300-\u036F\u203F-\u2040" - name = "[%s]([%s])*$" % (name_start_char, name_char) - char_data = "[^<&]*" - if isinstance(res_data, dict): - for key in res_data: - if not re.match(name, key, re.UNICODE): - msg = "'%s' can't be used as an xml element name!" % key - raise CommandException(msg) - else: - self._check_res_data(res_data[key]) - elif isinstance(res_data, list): - for i in res_data: - self._check_res_data(i) - else: - try: - string = str(res_data) - except: - msg = "res_data can only contain dictionaries, lists or "\ - "stringable objects!" - raise CommandException(msg) - if not re.match(char_data, string, re.UNICODE): - msg = "'%s' can't be used as character data in xml!" % string - raise CommandException(msg) - - def _format_cmd_res_header(self): - if "netns" in self._command and self._command["netns"] != None: - netns = "(%s) " % self._command["netns"] - else: - netns = "" - - return "%-9s" % (self._command["type"] + netns) - - def set_resource_table(self, res_table): - self._resource_table = res_table - - def exec_cmd(self, cmd, *args, **kwargs): - return exec_cmd(cmd, *args, **kwargs) - - def exec_from(self, tools_name, cmd, *args, **kwargs): - if not tools_name in self._resource_table["tools"]: - msg = "Tools '%s' not found" % tools_name - raise CommandException(msg) - - tools_path = self._resource_table["tools"][tools_name] - return exec_cmd("cd "%s" && %s" % (tools_path, cmd), *args, **kwargs) - -class NetTestCommandExec(NetTestCommandGeneric): - def __init__(self, command): - super(NetTestCommandExec, self).__init__(command) - - def run(self): - try: - if "from" in self._command: - stdout, stderr = self.exec_from(self._command["from"], - self._command["command"]) - else: - json = True if "json" in self._command else False - stdout, stderr = self.exec_cmd(self._command["command"], json=json) - res_data = {"stdout": stdout, "stderr": stderr} - self.set_pass(res_data) - except ExecCmdFail as e: - res_data = {"stdout": e.get_stdout(), "stderr": e.get_stderr()} - if "bg_id" in self._command: - logging.info("Command probably intentionally killed. Passing.") - self.set_pass(res_data) - else: - self.set_fail(res_data) - - def format_res_data(self, res_data, level=0): - return "" - - def _format_cmd_res_header(self): - cmd_type = self._command["type"] - cmd_val = self._command["command"] - - if "bg_id" in self._command: - bg_id = "bg_id: %s " % self._command["bg_id"] - else: - bg_id = "" - - if "netns" in self._command and self._command["netns"] != None: - netns = "(%s) " % self._command["netns"] - else: - netns = "" - - cmd = "%-9s%scmd: "%s"" %(cmd_type + netns, bg_id, cmd_val) - return cmd - -class NetTestCommandConfig(NetTestCommandGeneric): - def _retrive_option(self, option): - cmd_str = "cat %s" % option - (stdout, stderr) = exec_cmd(cmd_str) - return stdout.strip() - - def _set_option(self, option, value): - cmd_str = "echo "%s" >%s" % (value, option) - (stdout, stderr) = exec_cmd(cmd_str) - - def run(self): - res_data = {"options": [], "persistent": False} - - for opt in self._command["options"]: - option = opt["name"] - value = opt["value"] - option_abspath = os.path.abspath(option) - if option_abspath[0:5] != "/sys/" and \ - option_abspath[0:6] != "/proc/": - err = "Wrong config option %s. Only /proc or /sys paths are " \ - "allowed." % option - res_data["err_msg"] = err - return self.set_fail(res_data) - - try: - prev_val = self._retrive_option(option) - self._set_option(option, value) - except ExecCmdFail: - err = "Unable to set %s config option!" % option - res_data["err_msg"] = err - return self.set_fail(res_data) - - if "persistent" in self._command: - res_data["persistent"] = self._command["persistent"] - - res_data["options"].append({"name": option, - "current_val": value, - "previous_val": prev_val}) - - self.set_pass(res_data) - return self.get_result() - - def format_res_data(self, res_data, level=0): - formatted_data = "" - max_name_len = 0 - for option in res_data["options"]: - if len(option["name"]) > max_name_len: - max_name_len = len(option["name"]) - for option in res_data["options"]: - vals = "previous: %s current: %s" % (option["previous_val"], - option["current_val"]) - formatted_data += 4*level*" " + option["name"] + \ - (max_name_len - len(option["name"]))*" " + \ - "\t" + vals + "\n" - return formatted_data - -class NetTestCommandControl(NetTestCommandGeneric): - def __init__(self, command_context, command): - self._command_context = command_context - NetTestCommandGeneric.__init__(self, command) - - def _format_cmd_res_header(self): - cmd_type = self._command["type"] - cmd_val = self._command["proc_id"] - - if "netns" in self._command and self._command["netns"] != None: - netns = "(%s) " % self._command["netns"] - else: - netns = "" - - cmd = "%-9s id: %s" % (cmd_type + netns, cmd_val) - return cmd - -class NetTestCommandWait(NetTestCommandControl): - def run(self): - bg_id = self._command["proc_id"] - bg_cmd = self._command_context.get_cmd(bg_id) - bg_cmd.wait_for(self) - result = bg_cmd.get_result() - if result != None: - bg_cmd.join() - self._command_context.del_cmd(bg_cmd) - result["res_header"] = self._format_cmd_res_header() - return result - -class NetTestCommandIntr(NetTestCommandControl): - def run(self): - bg_id = self._command["proc_id"] - bg_cmd = self._command_context.get_cmd(bg_id) - bg_cmd.interrupt(self) - result = bg_cmd.get_result() - if result != None: - bg_cmd.join() - self._command_context.del_cmd(bg_cmd) - result["res_header"] = self._format_cmd_res_header() - return result - -class NetTestCommandKill(NetTestCommandControl): - def run(self): - bg_id = self._command["proc_id"] - bg_cmd = self._command_context.get_cmd(bg_id) - bg_cmd.kill(self) - result = bg_cmd.get_result() - if result != None: - bg_cmd.join() - self._command_context.del_cmd(bg_cmd) - result["res_header"] = self._format_cmd_res_header() - return result - -def get_command_class(command_context, command, resource_table): - cmd_type = command["type"] - if cmd_type == "exec": - cmd_cls = NetTestCommandExec(command) - elif cmd_type == "test": - cmd_cls = NetTestCommandTest(command, resource_table) - elif cmd_type == "wait": - cmd_cls = NetTestCommandWait(command_context, command) - elif cmd_type == "intr": - cmd_cls = NetTestCommandIntr(command_context, command) - elif cmd_type == "kill": - cmd_cls = NetTestCommandKill(command_context, command) - elif cmd_type == "config": - cmd_cls = NetTestCommandConfig(command) - else: - logging.error("Unknown comamnd type "%s"" % cmd_type) - raise Exception("Unknown command type "%s"" % cmd_type) - - cmd_cls.set_resource_table(resource_table) - return cmd_cls
These recipes were based on the initial version of LNST-next API but are no more relevant because the API changed.
Signed-off-by: Jan Tluka jtluka@redhat.com --- pyrecipes/3_vlans.py | 34 ----------------------------- pyrecipes/example.py | 33 ---------------------------- pyrecipes/ping_flood.py | 48 ----------------------------------------- 3 files changed, 115 deletions(-) delete mode 100644 pyrecipes/3_vlans.py delete mode 100644 pyrecipes/example.py delete mode 100644 pyrecipes/ping_flood.py
diff --git a/pyrecipes/3_vlans.py b/pyrecipes/3_vlans.py deleted file mode 100644 index 067fd33..0000000 --- a/pyrecipes/3_vlans.py +++ /dev/null @@ -1,34 +0,0 @@ -import lnst - -def ping_mod_init(if1, if2): - ping_mod = lnst.get_module("IcmpPing", - options={ - "addr": if2.get_ip(0), - "count": 10, - "interval": 1, - "iface" : if1.get_devname()}) - return ping_mod - -m1 = lnst.add_host() -m2 = lnst.add_host() - -m1_eth1 = m1.add_interface(label="tnet") -m2_eth1 = m2.add_interface(label="tnet") - -while lnst.match(): - m1.sync_resources(modules=["IcmpPing"]) - m2.sync_resources(modules=["IcmpPing"]) - - m1_vlan10 = m1.create_vlan(realdev_iface=m1_eth1, vlan_tci="10", ip="192.168.10.1/24") - m1_vlan20 = m1.create_vlan(realdev_iface=m1_eth1, vlan_tci="20", ip="192.168.20.1/24") - m1_vlan30 = m1.create_vlan(realdev_iface=m1_eth1, vlan_tci="30", ip="192.168.30.1/24") - - m2_vlan10 = m2.create_vlan(realdev_iface=m2_eth1, vlan_tci="10", ip="192.168.10.2/24") - m2_vlan20 = m2.create_vlan(realdev_iface=m2_eth1, vlan_tci="20", ip="192.168.20.2/24") - m2_vlan30 = m2.create_vlan(realdev_iface=m2_eth1, vlan_tci="30", ip="192.168.30.2/24") - - ping_mod = ping_mod_init(m1_vlan10, m2_vlan10) - ping_mod_bad = ping_mod_init(m1_vlan10, m2_vlan20) - - m1.run(ping_mod) - #m1.run(ping_mod_bad) diff --git a/pyrecipes/example.py b/pyrecipes/example.py deleted file mode 100644 index 32c1b08..0000000 --- a/pyrecipes/example.py +++ /dev/null @@ -1,33 +0,0 @@ -import lnst - -# if1 ... src -# if2 ... dst -def ping_mod_init(if1, if2): - ping_mod = lnst.get_module("IcmpPing", - options={ - "addr": if2.get_ip(0), - "count": 10, - "interval": 1, - "iface" : if1.get_devname()}) - return ping_mod - -m1 = lnst.add_host() -m2 = lnst.add_host() - -m1_eth1 = m1.add_interface(label="tnet") -m1_eth2 = m1.add_interface(label="tnet") -m2_eth1 = m2.add_interface(label="tnet") - -while lnst.match(): - m1.sync_resources(modules=["IcmpPing"]) - m2.sync_resources(modules=["IcmpPing"]) - m2_eth1.reset(ip="192.168.0.2/24") - ping = ping_mod_init(m1_eth1, m2_eth1) - #lnst.breakpoint() - team_if = m1.create_team(slaves=[m1_eth1, m1_eth2]) - #lnst.breakpoint() - team_if.reset(ip="192.168.0.1/24") - #lnst.breakpoint() - ping = ping_mod_init(team_if, m2_eth1) - #lnst.breakpoint() - m1.run(ping) diff --git a/pyrecipes/ping_flood.py b/pyrecipes/ping_flood.py deleted file mode 100644 index 257f7eb..0000000 --- a/pyrecipes/ping_flood.py +++ /dev/null @@ -1,48 +0,0 @@ -import lnst - -m1 = lnst.add_host() -m2 = lnst.add_host() - -m1_eth1 = m1.add_interface(label="tnet") -m2_eth1 = m2.add_interface(label="tnet") - -while lnst.match(): - m1.sync_resources(modules=["Icmp6Ping", "IcmpPing"]) - m2.sync_resources(modules=["Icmp6Ping", "IcmpPing"]) - - lnst.wait(15) - - ipv = lnst.get_alias("ipv", default="ipv4") - print("ipv") - print(ipv) - mtu = lnst.get_alias("mtu", default="1500") - print("mtu") - print(mtu) - - m1_eth1.reset(ip=["192.168.101.10/24", "fc00:0:0:0::1/64"]) - m2_eth1.reset(ip=["192.168.101.11/24", "fc00:0:0:0::2/64"]) - - ping_mod = lnst.get_module("IcmpPing", - options={ - "addr": m2_eth1.get_ip(0), - "count": 10, - "interval": 0.1, - "iface" : m1_eth1.get_devname(), - "limit_rate": 90}) - - ping_mod6 = lnst.get_module("Icmp6Ping", - options={ - "addr": m2_eth1.get_ip(1), - "count": 10, - "interval": 0.1, - "iface" : m1_eth1.get_devname(), - "limit_rate": 90}) - - m1_eth1.set_mtu(mtu) - m2_eth1.set_mtu(mtu) - - if ipv in [ 'ipv6', 'both' ]: - m1.run(ping_mod6) - - if ipv in ['ipv4', 'both' ]: - m1.run(ping_mod)
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Common/Parameters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lnst/Common/Parameters.py b/lnst/Common/Parameters.py index b0a84e0..b8d85cd 100644 --- a/lnst/Common/Parameters.py +++ b/lnst/Common/Parameters.py @@ -134,8 +134,8 @@ class ListParam(Param): try: self._type.type_check(item) except ParamError as e: - raise ParamError("Value {} failed type check:\n{}" - .format(str(e))) + raise ParamError("Value '{}' failed type check:\n{}" + .format(item, str(e))) return value
class Parameters(object):
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/TestRecipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/RecipeCommon/TestRecipe.py b/lnst/RecipeCommon/TestRecipe.py index 9c77f55..a92fa56 100755 --- a/lnst/RecipeCommon/TestRecipe.py +++ b/lnst/RecipeCommon/TestRecipe.py @@ -65,7 +65,7 @@ class TestRecipe(BaseRecipe): self.nperf_opts6 += " -6"
if "nperf_cpupin" in self.params and self.params.netperf_mode != "multi": - self.nperf_popts6 += " -T%s,%s" % (self.params.netperf_cpupin, + self.nperf_opts6 += " -T%s,%s" % (self.params.netperf_cpupin, self.params.netperf_cpupin)
time.sleep(15)
This method had been deprecated since Python 2.0 and is no longer used in Python 3. Item access was unified under __setitem__.
The __setitem__ method has been udpated to work with list values in slice assignments.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Perf/Results.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lnst/RecipeCommon/Perf/Results.py b/lnst/RecipeCommon/Perf/Results.py index 4519fb8..2d4c9f5 100644 --- a/lnst/RecipeCommon/Perf/Results.py +++ b/lnst/RecipeCommon/Perf/Results.py @@ -106,15 +106,17 @@ class PerfList(list): super(PerfList, self).__iadd__(iterable)
def __setitem__(self, i, item): - self._validate_item(item) - - super(PerfList, self).__setitem__(i, item) + if isinstance(item, list): + if not isinstance(i, slice): + raise LnstError("{} accepts list values in slice assignment " + "only".format(self.__class__.__name__))
- def __setslice__(self, i, j, iterable): - for i in iterable: - self._validate_item(i) + for j in item: + self._validate_item(j) + else: + self._validate_item(item)
- super(PerfList, self).__setslice__(i, j, iterable) + super(PerfList, self).__setitem__(i, item)
class SequentialPerfResult(PerfResult, PerfList): @property
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Perf/Evaluators/BaselineEvaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/RecipeCommon/Perf/Evaluators/BaselineEvaluator.py b/lnst/RecipeCommon/Perf/Evaluators/BaselineEvaluator.py index 72a19e9..74fb6d3 100644 --- a/lnst/RecipeCommon/Perf/Evaluators/BaselineEvaluator.py +++ b/lnst/RecipeCommon/Perf/Evaluators/BaselineEvaluator.py @@ -29,7 +29,7 @@ class BaselineEvaluator(BaseEvaluator):
recipe.add_result(comparison_result, "\n".join(result_text))
- def describe_group_results(recipe, results): + def describe_group_results(self, recipe, results): return []
def get_baselines(self, recipe, results):
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Slave/NetConfigDevice.py | 741 ---------------------------------- obsolete/netconfig.py | 206 ---------- 2 files changed, 947 deletions(-) delete mode 100644 lnst/Slave/NetConfigDevice.py delete mode 100755 obsolete/netconfig.py
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py deleted file mode 100644 index 7617767..0000000 --- a/lnst/Slave/NetConfigDevice.py +++ /dev/null @@ -1,741 +0,0 @@ -""" -This module defines multiple classes useful for configuring -multiple types of net devices - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import re -from lnst.Common.ExecCmd import exec_cmd -from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option -from lnst.Slave.NetConfigCommon import parse_netem, get_slave_options -from lnst.Common.Utils import bool_it -from lnst.Slave.NmConfigDevice import type_class_mapping as nm_type_class_mapping -from lnst.Slave.NmConfigDevice import is_nm_managed - - -class NetConfigDeviceGeneric(object): - ''' - Generic class for device manipulation all type classes should - extend this one. - ''' - _modulename = "" - _moduleload = True - _moduleparams = "" - _cleanupcmd = "" - - def __init__(self, dev_config, if_manager): - self._dev_config = dev_config - self._if_manager = if_manager - self.type_init() - - def configure(self): - pass - - def deconfigure(self): - pass - - def slave_add(self, slave_id): - pass - - def slave_del(self, slave_id): - pass - - def create(self): - pass - - def destroy(self): - pass - - def up(self): - config = self._dev_config - if "addresses" in config: - for address in config["addresses"]: - exec_cmd("ip addr add %s dev %s" % (address, config["name"])) - exec_cmd("ip link set %s up" % config["name"]) - - def down(self): - config = self._dev_config - if "addresses" in config: - for address in config["addresses"]: - exec_cmd("ip addr del %s dev %s" % (address, config["name"]), - die_on_err=False) - exec_cmd("ip link set %s down" % config["name"]) - - def set_addresses(self, ips): - self._dev_config["addresses"] = ips - - @classmethod - def type_init(self): - if self._modulename and self._moduleload: - exec_cmd("modprobe %s %s" % (self._modulename, self._moduleparams)) - - @classmethod - def type_cleanup(self): - if self._cleanupcmd: - exec_cmd(self._cleanupcmd, die_on_err=False) - -class NetConfigDeviceEth(NetConfigDeviceGeneric): - def configure(self): - config = self._dev_config - exec_cmd("ip addr flush %s" % config["name"]) - exec_cmd("ethtool -A %s rx off tx off" % config["name"], die_on_err=False, log_outputs=False) - if config["netem"] is not None: - cmd = "tc qdisc add dev %s root netem %s" % (config["name"], parse_netem(config["netem"])) - exec_cmd(cmd) - config["netem_cmd"] = cmd - - def deconfigure(self): - config = self._dev_config - exec_cmd("ethtool -s %s autoneg on" % config["name"]) - if "netem_cmd" in config: - exec_cmd(config["netem_cmd"].replace("add", "del")) - -class NetConfigDeviceLoopback(NetConfigDeviceGeneric): - def configure(self): - config = self._dev_config - - def down(self): - # We do not want to bring loopback device down in root namespace as - # this might have an unpredictable impact on further testing. - # In case of non-root namespace leaving loopback device up is not - # a problem since the namespace will get destroyed after recipe is - # finished. So, we will remove the configured addresses only - config = self._dev_config - if "addresses" in config: - for address in config["addresses"]: - exec_cmd("ip addr del %s dev %s" % (address, config["name"]), - die_on_err=False) - -class NetConfigDeviceBond(NetConfigDeviceGeneric): - _modulename = "bonding" - _moduleparams = "max_bonds=0" - - def _add_rm_bond(self, mark): - bond_masters = "/sys/class/net/bonding_masters" - exec_cmd('echo "%s%s" > %s' % (mark, self._dev_config["name"], - bond_masters)) - - def _get_bond_dir(self): - return "/sys/class/net/%s/bonding" % self._dev_config["name"] - - def _setup_options(self): - if not "options" in self._dev_config: - return - options = self._dev_config["options"] - - #Make sure that the device is down before configuring options - #this is a temporary workaround for NM setting the device IFF_UP on - #creation, which means that there is still a race condition here. - #Related to RH bgz #1114685 - exec_cmd('ip link set %s down' % self._dev_config["name"]) - - for option, value in options: - if option == "primary": - ''' - "primary" option is not direct value but it's - index of netdevice. So take the appropriate name from config - ''' - slave_dev = self._if_manager.get_mapped_device(value) - value = slave_dev.get_name() - exec_cmd('echo "%s" > %s/%s' % (value, - self._get_bond_dir(), - option)) - - def _add_rm_slaves(self, mark): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_conf = slave_dev.get_conf_dict() - slave_name = slave_dev.get_name() - if mark == "+": - slave_dev.down() - - exec_cmd('echo "%s%s" > %s/slaves' % (mark, slave_name, - self._get_bond_dir())) - - def create(self): - self._add_rm_bond("+") - - def destroy(self): - self._add_rm_bond("-") - - def configure(self): - self._setup_options() - self._add_rm_slaves("+") - - def deconfigure(self): - self._add_rm_slaves("-") - -class NetConfigDeviceBridge(NetConfigDeviceGeneric): - _modulename = "bridge" - - def _add_rm_bridge(self, prefix): - exec_cmd("brctl %sbr %s " % (prefix, self._dev_config["name"])) - - def _get_bridge_dir(self): - return "/sys/class/net/%s/bridge" % self._dev_config["name"] - - def _setup_options(self): - if not "options" in self._dev_config: - return - options = self._dev_config["options"] - - for option, value in options: - exec_cmd('echo "%s" > %s/%s' % (value, - self._get_bridge_dir(), - option)) - - def _add_rm_port(self, prefix, slave_id): - port_name = self._if_manager.get_mapped_device(slave_id).get_name() - exec_cmd("brctl %sif %s %s" % (prefix, self._dev_config["name"], - port_name)) - - def _add_rm_ports(self, prefix): - for slave_id in get_slaves(self._dev_config): - self._add_rm_port(prefix, slave_id) - - def create(self): - self._add_rm_bridge("add") - - def destroy(self): - self._add_rm_bridge("del") - - def configure(self): - self._setup_options() - self._add_rm_ports("add") - - def deconfigure(self): - self._add_rm_ports("del") - - def slave_add(self, slave_id): - self._add_rm_port("add", slave_id) - self._dev_config["slaves"].append(slave_id) - - def slave_del(self, slave_id): - self._dev_config["slaves"].remove(slave_id) - self._add_rm_port("del", slave_id) - -class NetConfigDeviceMacvlan(NetConfigDeviceGeneric): - _modulename = "macvlan" - - def create(self): - config = self._dev_config - realdev_id = config["slaves"][0] - realdev_name = self._if_manager.get_mapped_device(realdev_id).get_name() - dev_name = config["name"] - - hwaddr = "" - for opt, value in config["options"]: - if opt == "hwaddr": - hwaddr = " address %s" % value - - exec_cmd("ip link add link %s %s%s type macvlan" - % (realdev_name, dev_name, hwaddr)) - - def destroy(self): - dev_name = self._dev_config["name"] - exec_cmd("ip link del %s" % dev_name) - -class NetConfigDeviceVlan(NetConfigDeviceGeneric): - _modulename = "8021q" - - def _check_ip_link_add(self): - output = exec_cmd("ip link help", die_on_err=False, - log_outputs=False)[1] - for line in output.split("\n"): - if re.match(r'^.*ip link add [[]{0,1}link.*$', line): - return True - return False - - def _get_vlan_info(self): - config = self._dev_config - realdev_id = get_slaves(config)[0] - realdev_name = self._if_manager.get_mapped_device(realdev_id).get_name() - dev_name = config["name"] - vlan_tci = int(get_option(config, "vlan_tci")) - return dev_name, realdev_name, vlan_tci - - def create(self): - dev_name, realdev_name, vlan_tci = self._get_vlan_info() - if self._check_ip_link_add(): - exec_cmd("ip link add link %s %s type vlan id %d" - % (realdev_name, dev_name, vlan_tci)) - else: - if not re.match(r'^%s.%d$' % (realdev_name, vlan_tci), dev_name): - logging.error("Since using old vlan manipulation interface, " - "devname "%s" cannot be used" % dev_name) - raise Exception("Bad vlan device name") - exec_cmd("vconfig add %s %d" % (realdev_name, vlan_tci)) - - def destroy(self): - dev_name = self._get_vlan_info()[0] - if self._check_ip_link_add(): - exec_cmd("ip link del %s" % dev_name) - else: - exec_cmd("vconfig rem %s" % dev_name) - - def up(self): - parent_id = get_slaves(self._dev_config)[0] - parent_dev = self._if_manager.get_mapped_device(parent_id) - parent_dev.link_up() - - super(NetConfigDeviceVlan, self).up() - -class NetConfigDeviceVxlan(NetConfigDeviceGeneric): - _modulename = "" - - def create(self): - config = self._dev_config - - slaves = get_slaves(config) - if len(slaves) == 1: - realdev_id = slaves[0] - name = self._if_manager.get_mapped_device(realdev_id).get_name() - dev_param = "dev %s" % name - else: - dev_param = "" - - dev_name = config["name"] - vxlan_id = int(get_option(config, "id")) - group_ip = get_option(config, "group_ip") - remote_ip = get_option(config, "remote_ip") - - if group_ip: - group_or_remote = "group %s" % group_ip - elif remote_ip: - group_or_remote = "remote %s" % remote_ip - else: - raise Exception("group or remote must be specified for vxlan") - - dstport = get_option(config, "dstport") - if not dstport: - dstport = 0 - else: - dstport = int(dstport) - - exec_cmd("ip link add %s type vxlan id %d %s %s dstport %d" - % (dev_name, - vxlan_id, - dev_param, - group_or_remote, - dstport)) - - def destroy(self): - dev_name = self._dev_config["name"] - exec_cmd("ip link del %s" % dev_name) - - def up(self): - slaves = get_slaves(self._dev_config) - if len(slaves) == 1: - parent_id = get_slaves(self._dev_config)[0] - parent_dev = self._if_manager.get_mapped_device(parent_id) - parent_dev.link_up() - - super(NetConfigDeviceVxlan, self).up() - -def prepare_json_str(json_str): - if not json_str: - return "{}" - json_str = json_str.replace('"', '\"') - json_str = re.sub('\s+', ' ', json_str) - return json_str - -class NetConfigDeviceTeam(NetConfigDeviceGeneric): - _modulename = "team_mode_roundrobin team_mode_activebackup team_mode_broadcast team_mode_loadbalance team" - _moduleload = False - _cleanupcmd = "killall -q teamd" - - def _should_enable_dbus(self): - dbus_disabled = get_option(self._dev_config, "dbus_disabled") - if not dbus_disabled or bool_it(dbus_disabled): - return True - return False - - def _ports_down(self): - for slave_id in get_slaves(self._dev_config): - port_dev = self._if_manager.get_mapped_device(slave_id) - port_dev.down() - - def _ports_up(self): - for slave_id in get_slaves(self._dev_config): - port_dev = self._if_manager.get_mapped_device(slave_id) - port_dev.up() - - def create(self): - teamd_config = get_option(self._dev_config, "teamd_config") - teamd_config = prepare_json_str(teamd_config) - - dev_name = self._dev_config["name"] - - dbus_option = " -D" if self._should_enable_dbus() else "" - exec_cmd("teamd -r -d -c "%s" -t %s %s" % (teamd_config, dev_name, dbus_option)) - - def destroy(self): - dev_name = self._dev_config["name"] - exec_cmd("teamd -k -t %s" % dev_name) - - def configure(self): - self._ports_down() - - for slave_id in get_slaves(self._dev_config): - self._slave_add(slave_id) - self._ports_up() - - def deconfigure(self): - for slave_id in get_slaves(self._dev_config): - self._slave_del(slave_id) - - def _slave_add(self, slave_id): - dev_name = self._dev_config["name"] - port_dev = self._if_manager.get_mapped_device(slave_id) - port_name = port_dev.get_name() - teamd_port_config = get_slave_option(self._dev_config, - slave_id, - "teamd_port_config") - dbus_option = "-D" if self._should_enable_dbus() else "" - if teamd_port_config: - teamd_port_config = prepare_json_str(teamd_port_config) - exec_cmd("teamdctl %s %s port config update %s "%s"" % (dbus_option, dev_name, port_name, teamd_port_config)) - port_dev.down() - exec_cmd("teamdctl %s %s port add %s" % (dbus_option, dev_name, port_name)) - - def slave_add(self, slave_id): - self._slave_add(slave_id) - self._dev_config["slaves"].append(slave_id) - - def _slave_del(self, slave_id): - dev_name = self._dev_config["name"] - port_dev = self._if_manager.get_mapped_device(slave_id) - port_name = port_dev.get_name() - dbus_option = "-D" if self._should_enable_dbus() else "" - exec_cmd("teamdctl %s %s port remove %s" % (dbus_option, dev_name, port_name)) - - def slave_del(self, slave_id): - self._dev_config["slaves"].remove(slave_id) - self._slave_del(slave_id) - -class NetConfigDeviceOvsBridge(NetConfigDeviceGeneric): - _modulename = "openvswitch" - _moduleload = True - - def up(self): - super(NetConfigDeviceOvsBridge, self).up() - - int_ports = self._dev_config["ovs_conf"]["internals"] - br_name = self._dev_config["name"] - for iport in int_ports: - if "addresses" in iport: - for address in iport["addresses"]: - exec_cmd("ip addr add %s dev %s" % (address, iport["name"])) - exec_cmd("ip link set %s up" % iport["name"]) - - def down(self): - int_ports = self._dev_config["ovs_conf"]["internals"] - br_name = self._dev_config["name"] - for iport in int_ports: - if "addresses" in iport: - for address in iport["addresses"]: - exec_cmd("ip addr del %s dev %s" % (address, iport["name"])) - exec_cmd("ip link set %s down" % iport["name"]) - - super(NetConfigDeviceOvsBridge, self).down() - - @classmethod - def type_init(self): - super(NetConfigDeviceOvsBridge, self).type_init() - exec_cmd("mkdir -p /var/run/openvswitch/") - exec_cmd("ovsdb-server --detach --pidfile "\ - "--remote=punix:/var/run/openvswitch/db.sock", - die_on_err=False) - exec_cmd("ovs-vswitchd --detach --pidfile", die_on_err=False) - - def _add_ports(self): - slaves = self._dev_config["slaves"] - vlans = self._dev_config["ovs_conf"]["vlans"] - - br_name = self._dev_config["name"] - - bond_ports = [] - for bond in self._dev_config["ovs_conf"]["bonds"].values(): - for slave_id in bond["slaves"]: - bond_ports.append(slave_id) - - for slave_id in slaves: - if slave_id in bond_ports: - continue - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_name = slave_dev.get_name() - - options = "" - for opt in get_slave_options(self._dev_config, slave_id): - options += " %s=%s" % (opt[0], opt[1]) - - vlan_tags = [] - for tag, vlan in vlans.items(): - if slave_id in vlan["slaves"]: - vlan_tags.append(tag) - if len(vlan_tags) == 0: - tags = "" - elif len(vlan_tags) == 1: - tags = " tag=%s" % vlan_tags[0] - elif len(vlan_tags) > 1: - tags = " trunks=" + ",".join(vlan_tags) - exec_cmd("ovs-vsctl add-port %s %s%s" % (br_name, slave_name, tags)) - - if options != "": - exec_cmd("ovs-vsctl set Interface %s%s" % (slave_name, options)) - - def _del_ports(self): - slaves = self._dev_config["slaves"] - - br_name = self._dev_config["name"] - - bond_ports = [] - for bond in self._dev_config["ovs_conf"]["bonds"].values(): - for slave_id in bond["slaves"]: - bond_ports.append(slave_id) - - for slave_id in slaves: - if slave_id in bond_ports: - continue - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_name = slave_dev.get_name() - - exec_cmd("ovs-vsctl del-port %s %s" % (br_name, slave_name)) - - def _add_internal_ports(self): - int_ports = self._dev_config["ovs_conf"]["internals"] - br_name = self._dev_config["name"] - - for i in int_ports: - i["name"] = self._if_manager.assign_name_generic(prefix="int") - - options = "" - if "options" in i: - for opt in i["options"]: - options += " %s=%s" % (opt["name"], opt["value"]) - - if opt["name"] == "name": - i["name"] = opt["value"] - - exec_cmd("ovs-vsctl add-port %s %s -- set Interface %s "\ - "type=internal %s" % (br_name, i["name"], - i["name"], options)) - - def _del_internal_ports(self): - int_ports = self._dev_config["ovs_conf"]["internals"] - br_name = self._dev_config["name"] - - for i in int_ports: - exec_cmd("ovs-vsctl del-port %s %s" % (br_name, i["name"])) - - def _add_tunnels(self): - tunnels = self._dev_config["ovs_conf"]["tunnels"] - br_name = self._dev_config["name"] - - for i in tunnels: - i["name"] = self._if_manager.assign_name_generic(prefix=i["type"]) - - options = "" - for opt in i["options"]: - options += " %s=%s" % (opt["name"], opt["value"]) - - if opt["name"] == "name": - i["name"] = opt["value"] - - exec_cmd("ovs-vsctl add-port %s %s -- set Interface %s "\ - "type=%s %s" % (br_name, i["name"], i["name"], - i["type"], options)) - - def _del_tunnels(self): - tunnels = self._dev_config["ovs_conf"]["tunnels"] - br_name = self._dev_config["name"] - - for i in tunnels: - exec_cmd("ovs-vsctl del-port %s %s" % (br_name, i["name"])) - - def _add_bonds(self): - br_name = self._dev_config["name"] - - bonds = self._dev_config["ovs_conf"]["bonds"] - for bond_id, bond in bonds.items(): - ifaces = "" - for slave_id in bond["slaves"]: - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_name = slave_dev.get_name() - ifaces += " %s" % slave_name - opts = "" - for option in bond["options"]: - opts += " %s=%s" % (option["name"], option["value"]) - exec_cmd("ovs-vsctl add-bond %s %s %s %s" % (br_name, bond_id, - ifaces, opts)) - - def _del_bonds(self): - br_name = self._dev_config["name"] - - bonds = self._dev_config["ovs_conf"]["bonds"] - for bond_id, bond in bonds.items(): - exec_cmd("ovs-vsctl del-port %s %s" % (br_name, bond_id)) - - def _add_flow_entries(self): - br_name = self._dev_config["name"] - entries = self._dev_config["ovs_conf"]["flow_entries"] - - for entry in entries: - exec_cmd("ovs-ofctl add-flow %s '%s'" % (br_name, entry)) - - def _del_flow_entries(self): - br_name = self._dev_config["name"] - exec_cmd("ovs-ofctl del-flows %s" % (br_name)) - - def create(self): - dev_cfg = self._dev_config - br_name = dev_cfg["name"] - exec_cmd("ovs-vsctl add-br %s" % br_name) - - self._add_internal_ports() - self._add_tunnels() - - def destroy(self): - self._del_tunnels() - self._del_internal_ports() - - dev_cfg = self._dev_config - br_name = dev_cfg["name"] - exec_cmd("ovs-vsctl del-br %s" % br_name) - - def configure(self): - self._add_ports() - self._add_bonds() - self._add_flow_entries() - - def deconfigure(self): - self._del_flow_entries() - self._del_bonds() - self._del_ports() - -class NetConfigDeviceVEth(NetConfigDeviceGeneric): - _modulename = "" - _moduleload = False - - def create(self): - conf = self._dev_config - exec_cmd("ip link add %s type veth peer name %s" % (conf["name"], - conf["peer_name"])) - - def destroy(self): - conf = self._dev_config - exec_cmd("ip link del %s" % conf["name"]) - - def configure(self): - #no configuration options supported at the moment - return True - - def deconfigure(self): - return True - -class NetConfigDeviceVti(NetConfigDeviceGeneric): - _modulename = "" - _moduleload = False - - def create(self): - conf = self._dev_config - local = '' - remote = '' - key = None - for opt, val in conf['options']: - if opt == 'local': - local = 'local ' + val - elif opt == 'remote': - remote = 'remote ' + val - elif opt == 'key': - key = val - else: - pass - - if key == None: - raise Exception("Option 'key' not set for a vti device") - - exec_cmd("ip link add %s type vti %s %s key %s" % - (conf["name"], local, remote, key)) - - def destroy(self): - conf = self._dev_config - exec_cmd("ip link del %s" % conf["name"]) - - def configure(self): - #no configuration options supported at the moment - return True - - def deconfigure(self): - return True - -class NetConfigDeviceVti6(NetConfigDeviceGeneric): - _modulename = "" - _moduleload = False - - def create(self): - conf = self._dev_config - local = '' - remote = '' - key = None - device = '' - for opt, val in conf['options']: - if opt == 'local': - local = 'local ' + val - elif opt == 'remote': - remote = 'remote ' + val - elif opt == 'key': - key = val - elif opt == 'dev': - device = 'dev ' + val - else: - pass - - if key == None: - raise Exception("Option 'key' not set for a vti6 device") - - exec_cmd("ip link add %s type vti6 %s %s key %s %s" % - (conf["name"], local, remote, key, device)) - - def destroy(self): - conf = self._dev_config - exec_cmd("ip link del %s" % conf["name"]) - - def configure(self): - #no configuration options supported at the moment - return True - - def deconfigure(self): - return True - -type_class_mapping = { - "eth": NetConfigDeviceEth, - "bond": NetConfigDeviceBond, - "bridge": NetConfigDeviceBridge, - "macvlan": NetConfigDeviceMacvlan, - "vlan": NetConfigDeviceVlan, - "team": NetConfigDeviceTeam, - "ovs_bridge": NetConfigDeviceOvsBridge, - "veth": NetConfigDeviceVEth, - "vti": NetConfigDeviceVti, - "vti6": NetConfigDeviceVti6, - "lo": NetConfigDeviceLoopback, - "vxlan": NetConfigDeviceVxlan -} - -def NetConfigDevice(dev_config, if_manager): - ''' - Class dispatcher - ''' - if is_nm_managed(dev_config, if_manager): - return nm_type_class_mapping[dev_config["type"]](dev_config, if_manager) - else: - return type_class_mapping[dev_config["type"]](dev_config, if_manager) diff --git a/obsolete/netconfig.py b/obsolete/netconfig.py deleted file mode 100755 index 6012667..0000000 --- a/obsolete/netconfig.py +++ /dev/null @@ -1,206 +0,0 @@ -#! /usr/bin/env python -""" -Netconfig tool - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import getopt -import sys -import logging -import re -import os -from pprint import pprint -from NetConfig.NetConfig import NetConfig -from NetConfig.NetConfigDevice import NetConfigDeviceAllCleanup -from NetConfig.NetConfigDevNames import NetConfigDevNames -from NetTest.NetTestParse import NetConfigParse -from NetTest.NetTestParse import NetMachineConfigParse -from Common.XmlProcessing import XmlDomTreeInit -from Common.Logs import Logs - -def usage(): - """ - Print usage of this app - """ - print "Usage: netconfig.py [OPTION...] ACTION" - print "" - print "ACTION = [up | down | dump | cleanup | test]" - print "" - print " -d, --debug emit debugging messages" - print " -h, --help print this message" - print " -c, --config=FILE use this net configuration file" - print " -m, --machine-config=FILE use this machine configuration file" - sys.exit() - -def prepare_machine_config(machine_file): - tree_init = XmlDomTreeInit() - dom = tree_init.parse_file(machine_file) - machine_dom = dom.getElementsByTagName("netmachineconfig")[0] - - data = {"info":{}, "netdevices": {}, "netconfig": {}} - - machine_parse = NetMachineConfigParse() - machine_parse.disable_events() - machine_parse.set_recipe(data) - machine_parse.set_machine(0, data) - machine_parse.parse(machine_dom) - - return data - -def prepare_netconfig(machine_file, config_file): - tree_init = XmlDomTreeInit() - data = prepare_machine_config(machine_file) - - dom = tree_init.parse_file(config_file) - config_dom = dom.getElementsByTagName("netconfig")[0] - - config_parse = NetConfigParse() - config_parse.disable_events() - config_parse.set_recipe(data) - config_parse.set_machine(0, data) - config_parse.parse(config_dom) - - netconfig = NetConfig() - for key, entry in data["netconfig"].iteritems(): - netconfig.add_interface_config(key, entry) - - return netconfig - -def netmachineconfig_to_xml(machine_data): - info = machine_data["info"] - - hostname = "" - rootpass = "" - rpcport = "" - - if "hostname" in info: - hostname = "hostname="%s" " % info["hostname"] - if "rootpass" in info: - rootpass = "rootpass="%s" " % info["rootpass"] - if "rpcport" in info: - rpcport = "rpcport="%s" " % info["rpcport"] - - info_tag = " <info %s%s%s/>\n" % (hostname, rootpass, rpcport) - - devices = "" - for phys_id, netdev in machine_data["netdevices"].iteritems(): - pid = "phys_id="%s" " % phys_id - dev_type = "" - name = "" - hwaddr = "" - - if "type" in netdev: - dev_type = "type="%s" " % netdev["type"] - if "name" in netdev: - name = "name="%s" " % netdev["name"] - if "hwaddr" in netdev: - hwaddr = "hwaddr="%s" " % netdev["hwaddr"] - - device_tag = " <netdevice %s%s%s%s/>\n" % (pid, dev_type, - name, hwaddr) - devices += device_tag - - return "<netmachineconfig>\n" + info_tag + devices + "</netmachineconfig>" - -def main(): - """ - Main function - """ - - try: - opts, args = getopt.getopt( - sys.argv[1:], - "dhc:m:a:", - ["debug", "help", "config=", "machine-config=", "action="] - ) - except getopt.GetoptError as err: - print str(err) - usage() - sys.exit() - - debug = False - config_path = None - machine_config_path = None - for opt, arg in opts: - if opt in ("-d", "--debug"): - debug = True - elif opt in ("-h", "--help"): - usage() - elif opt in ("-c", "--config"): - config_path = arg - elif opt in ("-m", "--machine-config"): - machine_config_path = arg - - Logs(debug) - logging.info("Started") - - if not args: - logging.error("No action command passed") - usage(); - - action = args[0] - if action == "cleanup": - NetConfigDeviceAllCleanup() - return - - if not machine_config_path: - logging.error("No machine config xml file passed") - usage(); - machine_config_path = os.path.expanduser(machine_config_path) - - if action == "refresh": - logging.info("Refreshing machine config") - machine_data = prepare_machine_config(machine_config_path) - dev_names = NetConfigDevNames() - for dev_id, netdev in machine_data["netdevices"].iteritems(): - if "name" in netdev: - del netdev["name"] - dev_names.assign_name_by_scan(dev_id, netdev) - - output = netmachineconfig_to_xml(machine_data) - handle = open(machine_config_path, "w") - handle.write(output) - handle.close() - return - - if not config_path: - logging.error("No net config file/dir passed") - usage(); - config_path = os.path.expanduser(config_path) - - if action == "test": - ''' - Go through specified directory and use all xmls and configs - ''' - - for root, dirs, files in os.walk(config_path): - for file_name in files: - config_file = os.path.join(config_path, file_name) - if not re.match(r'^.*.xml$', config_file): - continue - logging.info("Processing config file "%s"", config_file) - net_config = prepare_netconfig(machine_config_path, - config_file) - net_config.configure_all() - net_config.deconfigure_all() - return - - net_config = prepare_netconfig(machine_config_path, config_path) - if action == "up": - net_config.configure_all() - elif action == "down": - net_config.deconfigure_all() - elif action == "dump": - pprint(net_config.dump_config()) - else: - logging.error("unknown action "%s"" % action) - -if __name__ == "__main__": - main()
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Slave/NmConfigDevice.py | 888 ----------------------------------- 1 file changed, 888 deletions(-) delete mode 100644 lnst/Slave/NmConfigDevice.py
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py deleted file mode 100644 index a9e0c1f..0000000 --- a/lnst/Slave/NmConfigDevice.py +++ /dev/null @@ -1,888 +0,0 @@ -""" -This module defines multiple classes useful for configuring -multiple types of net devices, using NetworkManager - -Copyright 2013 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -olicthne@redhat.com (Ondrej Lichtner) -""" - -import logging -import re -import dbus -import uuid -import socket, struct -import time -from dbus.exceptions import DBusException -from lnst.Common.ExecCmd import exec_cmd -from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option, parse_netem -from lnst.Common.NetUtils import scan_netdevs -from lnst.Common.Utils import check_process_running -from lnst.Common.Config import lnst_config - -NM_BUS = "org.freedesktop.NetworkManager" -OBJ_PRE = "/org/freedesktop/NetworkManager" -IF_PRE = NM_BUS -POLL_LOOP_TIMEOUT = 10 - -#NetworkManager constants for state values -_ACON_ACTIVATED = 2 -_DEV_UNAVAILABLE = 20 -_DEV_DISCONNECTED = 30 - -def is_nm_managed_by_name(dev_name): - if not check_process_running("NetworkManager") or\ - not lnst_config.get_option("environment", "use_nm"): - return False - - bus = dbus.SystemBus() - nm_obj = bus.get_object(NM_BUS, OBJ_PRE) - nm_if = dbus.Interface(nm_obj, IF_PRE) - try: - device_obj_path = nm_if.GetDeviceByIpIface(dev_name) - except: - #There is a higher possibility that if the interface doesn't exist - #it's a software interface that can be created by NM so we say that it's - #managed and check existance of physical interfaces sepparately - return True - - dev = bus.get_object(NM_BUS, device_obj_path) - dev_props = dbus.Interface(dev, "org.freedesktop.DBus.Properties") - return dev_props.Get(IF_PRE + ".Device", "Managed") - -def _dev_exists(hwaddr): - devnames = scan_netdevs() - for dev in devnames: - if dev["hwaddr"] == hwaddr: - return True - -def get_nm_version(): - if not check_process_running("NetworkManager") or\ - not lnst_config.get_option("environment", "use_nm"): - return "" - - bus = dbus.SystemBus() - nm_obj = bus.get_object(NM_BUS, OBJ_PRE) - nm_if = dbus.Interface(nm_obj, IF_PRE) - - props = dbus.Interface(nm_obj, "org.freedesktop.DBus.Properties") - return props.Get(IF_PRE, "Version") - -class NmConfigDeviceGeneric(object): - ''' - Generic class for device manipulation all type classes should - extend this one. - ''' - _modulename = "" - _moduleload = True - _moduleparams = "" - _cleanupcmd = "" - - _device_state = None - _loop = None - _wait_for = None - - - def __init__(self, dev_config, if_manager): - self._dev_config = dev_config - self._if_manager = if_manager - self._bus = dbus.SystemBus() - self._nm_obj = self._bus.get_object(NM_BUS, OBJ_PRE) - self._nm_if = dbus.Interface(self._nm_obj, IF_PRE) - - self._connection = None - self._connection_added = False - self._con_obj_path = None - self._acon_obj_path = None - - def configure(self): - pass - - def deconfigure(self): - pass - - def create(self): - pass - - def destroy(self): - pass - - def slave_add(self, slave_id): - pass - - def slave_del(self, slave_id): - pass - - def up(self): - if not self._connection_added: - self._nm_add_connection() - if self._connection_added: - #NM would automatically activate the master connection, however - #we want to have the record of which active connection that is - if self._dev_config["master"] != None: - master_id = self._dev_config["master"] - master_dev = self._if_manager.get_mapped_device(master_id) - master_dev.up() - self._nm_activate_connection() - - def down(self): - if self._connection_added: - self._nm_deactivate_connection() - - @classmethod - def type_init(self): - pass - - @classmethod - def type_cleanup(self): - pass - - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - if dev_config["netns"] != None: - return False - return is_nm_managed_by_name(dev_config["name"]) - - def _wait_for_state(self, new_state, old_state, reason): - self._device_state = new_state - if self._device_state == self._wait_for: - self._loop.quit() - - def _poll_loop(self, func, expected_val, timeout, *args): - timer = 0 - while timer < timeout: - if func(*args) == expected_val: - return - time.sleep(1) - timer += 1 - msg = "Timed out during NetworkManager polling." - raise Exception(msg) - - def _convert_hwaddr(self, dev_config): - if "hwaddr" in dev_config: - hwaddr = dev_config["hwaddr"] - else: - return None - - hw_nums = hwaddr.split(':') - - addr_bytes = [] - for i in hw_nums: - addr_bytes.append(int(i, base=16)) - return dbus.Array(addr_bytes, 'y') - - def _nm_make_ip_settings(self, addrs): - ipv4s = [] - ipv6s = [] - for addr in addrs: - match = re.match("([^/]*)(/(\d*))?", addr) - ip, mask = match.group(1,3) - if not mask: - mask = 0 - try: - #IPv4 conversion into a 32bit number - ip = struct.unpack("=I", socket.inet_pton(socket.AF_INET, ip))[0] - ipv4s.append(dbus.Array([ip, mask, 0], signature='u')) - except: - #IPv6 conversion into a 16 byte array - tmp = socket.inet_pton(socket.AF_INET6, ip) - ip = [] - for i in tmp: - ip.append(ord(i)) - ip = dbus.Array(ip, signature='y') - def_gateway = dbus.Array([0]*16, signature='y') - ipv6s.append(tuple([ip, - dbus.UInt32(mask), - def_gateway])) - - if len(ipv4s)>0: - s_ipv4 = dbus.Dictionary({ - 'addresses': ipv4s, - 'method': 'manual'}, signature='sv') - else: - s_ipv4 = dbus.Dictionary({ - 'method': 'disabled'}, signature='sv') - if len(ipv6s)>0: - s_ipv6 = dbus.Dictionary({ - 'addresses': ipv6s, - 'method': 'manual'}, signature='sv') - else: - s_ipv6 = dbus.Dictionary({ - 'method': 'ignore'}, signature='sv') - - return (s_ipv4, s_ipv6) - - def _nm_add_connection(self): - #NM will succesfully add this connection but is unable to activate it... - if self._connection["ipv4"]["method"] == "disabled" and\ - self._connection["ipv6"]["method"] == "ignore" and\ - "master" not in self._connection["connection"] and\ - self._connection["connection"]["type"] == "802-3-ethernet": - return - - if not self._connection_added: - bus = self._bus - settings_obj = bus.get_object(NM_BUS, OBJ_PRE + "/Settings") - settings_if = dbus.Interface(settings_obj, IF_PRE + ".Settings") - self._con_obj_path = settings_if.AddConnection(self._connection) - self._connection_added = True - logging.debug("Added NM connection: %s" % self._con_obj_path) - - def _nm_rm_connection(self): - if self._connection_added: - bus = self._bus - con_obj = bus.get_object(NM_BUS, self._con_obj_path) - con_if = dbus.Interface(con_obj, IF_PRE + ".Settings.Connection") - con_if.Delete() - logging.debug("Removed NM connection: %s" % self._con_obj_path) - self._connection_added = False - self._con_obj_path = None - - def _nm_update_connection(self): - if self._connection_added: - bus = self._bus - con_obj = bus.get_object(NM_BUS, self._con_obj_path) - con_if = dbus.Interface(con_obj, IF_PRE + ".Settings.Connection") - con_if.Update(self._connection) - logging.debug("Updated NM connection: %s" % self._con_obj_path) - - def _nm_activate_connection(self): - config = self._dev_config - if self._acon_obj_path != None or\ - self._con_obj_path == None: - return - else: - logging.info("Activating connection on interface %s" - % config["name"]) - bus = self._bus - nm_if = self._nm_if - - try: - device_obj_path = nm_if.GetDeviceByIpIface(config["name"]) - except: - device_obj_path = "/" - - self._acon_obj_path = nm_if.ActivateConnection( - self._con_obj_path, - device_obj_path, "/") - - logging.debug("Device object path: %s" % device_obj_path) - logging.debug("Connection object path: %s" % self._con_obj_path) - logging.debug("Active connection object path: %s" - % self._acon_obj_path) - - act_con = bus.get_object(NM_BUS, self._acon_obj_path) - act_con_props = dbus.Interface(act_con, - "org.freedesktop.DBus.Properties") - self._poll_loop(act_con_props.Get, - _ACON_ACTIVATED, - POLL_LOOP_TIMEOUT, - IF_PRE + ".Connection.Active", "State") - - def _nm_deactivate_connection(self): - config = self._dev_config - if self._acon_obj_path == None: - return - else: - logging.info("Deactivating connection on device %s" - % config["name"]) - logging.debug("Active connection object path: %s" - % self._acon_obj_path) - try: - self._nm_if.DeactivateConnection(self._acon_obj_path) - except DBusException as e: - if e.get_dbus_name() == "org.freedesktop.NetworkManager."\ - "ConnectionNotActive": - pass - else: - raise e - self._acon_obj_path = None - - def nm_enslave(self, slave_type, master_uuid, slave_conf): - if get_nm_version() < "1.0.0": - self._connection["connection"]["slave_type"] = slave_type - else: - self._connection["connection"]["slave-type"] = slave_type - self._connection["connection"]["master"] = master_uuid - self._connection.update(slave_conf) - - self._nm_update_connection() - - def nm_free(self): - if get_nm_version() < "1.0.0": - if "slave_type" in self._connection["connection"]: - del self._connection["connection"]["slave_type"] - else: - if "slave-type" in self._connection["connection"]: - del self._connection["connection"]["slave-type"] - if "master" in self._connection["connection"]: - del self._connection["connection"]["master"] - - self._nm_update_connection() - -class NmConfigDeviceEth(NmConfigDeviceGeneric): - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - managed = super(NmConfigDeviceEth, cls).is_nm_managed(dev_config, - if_manager) - if _dev_exists(dev_config["hwaddr"]): - return managed - else: - return False - - def up(self): - config = self._dev_config - - bus = self._bus - nm_if = self._nm_if - - device_obj_path = nm_if.GetDeviceByIpIface(config["name"]) - - dev = bus.get_object(NM_BUS, device_obj_path) - dev_props = dbus.Interface(dev, "org.freedesktop.DBus.Properties") - - state = dev_props.Get(IF_PRE + ".Device", "State") - if state == _DEV_UNAVAILABLE: - logging.info("Resetting interface so NM manages it.") - exec_cmd("ip link set %s down" % config["name"]) - exec_cmd("ip link set %s up" % config["name"]) - - self._poll_loop(dev_props.Get, - _DEV_DISCONNECTED, - POLL_LOOP_TIMEOUT, - IF_PRE + ".Device", "State") - else: - exec_cmd("ip link set %s up" % config["name"]) - - super(NmConfigDeviceEth, self).up() - - def configure(self): - config = self._dev_config - exec_cmd("ethtool -A %s rx off tx off" % config["name"], - die_on_err=False, log_outputs=False) - - hw_addr = self._convert_hwaddr(config) - - s_ipv4, s_ipv6 = self._nm_make_ip_settings(config["addresses"]) - - s_eth = dbus.Dictionary({'mac-address': hw_addr}, signature='sv') - s_con = dbus.Dictionary({ - 'type': '802-3-ethernet', - 'autoconnect': dbus.Boolean(False), - 'uuid': str(uuid.uuid4()), - 'id': 'lnst_ethcon'}, signature='sv') - - connection = dbus.Dictionary({ - '802-3-ethernet': s_eth, - 'connection': s_con, - 'ipv4': s_ipv4, - 'ipv6': s_ipv6}, signature='sa{sv}') - - self._connection = connection - self._nm_add_connection() - if config["netem"] is not None: - cmd = "tc qdisc add dev %s root netem %s" % (config["name"], parse_netem(config["netem"])) - exec_cmd(cmd) - config["netem_cmd"] = cmd - - def deconfigure(self): - config = self._dev_config - if "netem_cmd" in config: - exec_cmd(config["netem_cmd"].replace("add", "del")) - if self._con_obj_path != None: - self._nm_rm_connection() - -class NmConfigDeviceBond(NmConfigDeviceGeneric): - _modulename = "bonding" - _moduleparams = "max_bonds=0" - - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - if _dev_exists(dev_config["hwaddr"]): - managed = super(NmConfigDeviceBond, cls).is_nm_managed(dev_config, - if_manager) - else: - slave_dev = if_manager.get_mapped_device(get_slaves(dev_config)[0]) - slave_config = slave_dev.get_conf_dict() - managed = is_nm_managed(slave_config, if_manager) - - for slave_id in get_slaves(dev_config): - slave_dev = if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_conf_dict() - if is_nm_managed(slave_config, if_manager) != managed: - msg = "Mixing NM managed and not managed devices in a "\ - "master-slave relationship is not allowed!" - raise Exception(msg) - - return managed - - def up(self): - super(NmConfigDeviceBond, self).up() - - def down(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_dev.down() - - super(NmConfigDeviceBond, self).down() - - def _setup_options(self): - if not "options" in self._dev_config: - return dbus.Dictionary({}, signature="ss") - options = {} - for option, value in self._dev_config["options"]: - if option == "primary": - ''' - "primary" option is not direct value but it's - index of netdevice. So take the appropriate name from config - ''' - slave_dev = self._if_manager.get_mapped_device(int(value)) - value = slave_dev.get_name() - options[option] = value - if options: - return dbus.Dictionary(options, signature="ss") - else: - return None - - def _add_bond(self): - config = self._dev_config - config["master_uuid"] = str(uuid.uuid4()) - - s_bond_con = dbus.Dictionary({ - 'type': 'bond', - 'autoconnect': dbus.Boolean(False), - 'uuid': config["master_uuid"], - 'id': config["name"]+"_con"}) - - options = self._setup_options() - - if options: - s_bond = dbus.Dictionary({ - 'interface-name': config["name"], - 'options': options}) - else: - s_bond = dbus.Dictionary({ - 'interface-name': config["name"]}) - - s_ipv4, s_ipv6 = self._nm_make_ip_settings(config["addresses"]) - - connection = dbus.Dictionary({ - 'bond': s_bond, - 'ipv4': s_ipv4, - 'ipv6': s_ipv6, - 'connection': s_bond_con}) - - self._connection = connection - self._nm_add_connection() - - def _rm_bond(self): - config = self._dev_config - if self._con_obj_path != None: - self._nm_rm_connection() - - #older versions of NM don't know how to remove soft devices... - if get_nm_version() < "0.9.9": - try: - bond_masters = "/sys/class/net/bonding_masters" - exec_cmd('echo "-%s" > %s' % (config["name"], bond_masters)) - except: - pass - - def _add_slaves(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_configuration() - slave_config.nm_enslave("bond", self._dev_config["master_uuid"], {}) - - def _rm_slaves(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_configuration() - slave_config.nm_free() - - def configure(self): - self._add_bond() - self._add_slaves() - - def deconfigure(self): - self._rm_slaves() - self._rm_bond() - -class NmConfigDeviceBridge(NmConfigDeviceGeneric): - _modulename = "bridge" - - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - if _dev_exists(dev_config["hwaddr"]): - managed = super(NmConfigDeviceBridge, cls).is_nm_managed(dev_config, - if_manager) - else: - slave_dev = if_manager.get_mapped_device(get_slaves(dev_config)[0]) - slave_config = slave_dev.get_conf_dict() - managed = is_nm_managed(slave_config, if_manager) - - for slave_id in get_slaves(dev_config): - slave_dev = if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_conf_dict() - if is_nm_managed(slave_config, if_manager) != managed: - msg = "Mixing NM managed and not managed devices in a "\ - "master-slave relationship is not allowed!" - raise Exception(msg) - - return managed - - def up(self): - super(NmConfigDeviceBridge, self).up() - - def down(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_dev.down() - - super(NmConfigDeviceBridge, self).down() - - def _add_bridge(self): - config = self._dev_config - config["master_uuid"] = str(uuid.uuid4()) - - s_bridge_con = dbus.Dictionary({ - 'type': 'bridge', - 'autoconnect': dbus.Boolean(False), - 'uuid': config["master_uuid"], - 'id': config["name"]+"_con"}) - - s_bridge = dbus.Dictionary({ - 'interface-name': config["name"], - 'stp': dbus.Boolean(False)}) - - s_ipv4, s_ipv6 = self._nm_make_ip_settings(config["addresses"]) - - connection = dbus.Dictionary({ - 'bridge': s_bridge, - 'ipv4': s_ipv4, - 'ipv6': s_ipv6, - 'connection': s_bridge_con}) - - self._connection = connection - self._nm_add_connection() - - def _rm_bridge(self): - config = self._dev_config - if self._con_obj_path != None: - self._nm_rm_connection() - - #older versions of NM don't know how to remove soft devices... - if get_nm_version() < "0.9.9": - try: - exec_cmd("ip link set %s down" % config["name"]) - exec_cmd("brctl delbr %s " % config["name"]) - except: - pass - - def _add_slave(self, slave_id): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_configuration() - slave_config.nm_enslave("bridge", self._dev_config["master_uuid"], {}) - - def _rm_slave(self, slave_id): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_configuration() - slave_config.nm_free() - - def _add_slaves(self): - for slave_id in get_slaves(self._dev_config): - self._add_slave(slave_id) - - def _rm_slaves(self): - for slave_id in get_slaves(self._dev_config): - self._rm_slave(slave_id) - - def configure(self): - self._add_bridge() - self._add_slaves() - - def deconfigure(self): - self._rm_slaves() - self._rm_bridge() - - def slave_add(self, slave_id): - self._add_slave(slave_id) - - def slave_del(self, slave_id): - self._rm_slave(slave_id) - -class NmConfigDeviceMacvlan(NmConfigDeviceGeneric): - #Not supported by NetworkManager yet - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - managed = False - - for slave_id in get_slaves(dev_config): - slave_dev = if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_conf_dict() - if is_nm_managed(slave_config, if_manager) != managed: - msg = "Mixing NM managed and not managed devices in a "\ - "master-slave relationship is not allowed!" - raise Exception(msg) - - return managed - -class NmConfigDeviceVlan(NmConfigDeviceGeneric): - _modulename = "8021q" - - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - if _dev_exists(dev_config["hwaddr"]): - managed = super(NmConfigDeviceVlan, cls).is_nm_managed(dev_config, - if_manager) - else: - slave_dev = if_manager.get_mapped_device(get_slaves(dev_config)[0]) - slave_config = slave_dev.get_conf_dict() - managed = is_nm_managed(slave_config, if_manager) - - for slave_id in get_slaves(dev_config): - slave_dev = if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_conf_dict() - if is_nm_managed(slave_config, if_manager) != managed: - msg = "Mixing NM managed and not managed devices in a "\ - "master-slave relationship is not allowed!" - raise Exception(msg) - - return managed - - def _check_ip_link_add(self): - output = exec_cmd("ip link help", die_on_err=False, - log_outputs=False)[1] - for line in output.split("\n"): - if re.match(r'^.*ip link add [[]{0,1}link.*$', line): - return True - return False - - def _get_vlan_info(self): - config = self._dev_config; - realdev = self._if_manager.get_mapped_device(get_slaves(config)[0]) - realdev_name = realdev.get_name() - dev_name = config["name"] - vlan_tci = int(get_option(config, "vlan_tci")) - return dev_name, realdev_name, vlan_tci - - def configure(self): - config = self._dev_config - - dev_name, realdev, vlan_tci = self._get_vlan_info() - - s_vlan_con = dbus.Dictionary({ - 'type': 'vlan', - 'autoconnect': dbus.Boolean(False), - 'uuid': str(uuid.uuid4()), - 'id': dev_name+"_con"}) - - s_vlan = dbus.Dictionary({ - 'interface-name': dev_name, - 'parent': realdev, - 'id': dbus.UInt32(vlan_tci)}, signature="sv") - - s_ipv4, s_ipv6 = self._nm_make_ip_settings(config["addresses"]) - - connection = dbus.Dictionary({ - 'vlan': s_vlan, - 'ipv4': s_ipv4, - 'ipv6': s_ipv6, - 'connection': s_vlan_con}) - - self._connection = connection - self._nm_add_connection() - - def deconfigure(self): - if self._con_obj_path != None: - self._nm_rm_connection() - - #older versions of NM don't know how to remove soft devices... - #and lnst will break when multiple devices with the same mac exist - if get_nm_version() < "0.9.9": - try: - dev_name = self._get_vlan_info()[0] - if self._check_ip_link_add(): - exec_cmd("ip link del %s" % dev_name) - else: - exec_cmd("vconfig rem %s" % dev_name) - except: - pass - - def up(self): - realdev_id = get_slaves(self._dev_config)[0] - realdev = self._if_manager.get_mapped_device(realdev_id) - realdev.up() - - super(NmConfigDeviceVlan, self).up() - -class NmConfigDeviceTeam(NmConfigDeviceGeneric): - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - if _dev_exists(dev_config["hwaddr"]): - managed = super(NmConfigDeviceTeam, cls).is_nm_managed(dev_config, - if_manager) - else: - if get_nm_version() < "0.9.9": - managed = False - else: - slave_dev = if_manager.get_mapped_device(get_slaves(dev_config)[0]) - slave_config = slave_dev.get_conf_dict() - managed = is_nm_managed(slave_config, if_manager) - - for slave_id in get_slaves(dev_config): - slave_dev = if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_conf_dict() - if is_nm_managed(slave_config, if_manager) != managed: - msg = "Mixing NM managed and not managed devices in a "\ - "master-slave relationship is not allowed!" - raise Exception(msg) - - return managed - - def up(self): - super(NmConfigDeviceTeam, self).up() - - def down(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_dev.down() - - super(NmConfigDeviceTeam, self).down() - - def _add_team(self): - config = self._dev_config - config["master_uuid"] = str(uuid.uuid4()) - - s_team_con = dbus.Dictionary({ - 'type': 'team', - 'autoconnect': dbus.Boolean(False), - 'uuid': config["master_uuid"], - 'id': config["name"]+"_con"}) - - teamd_config = get_option(config, "teamd_config") - - s_team = dbus.Dictionary({ - 'interface-name': config["name"], - 'config': teamd_config}) - - s_ipv4, s_ipv6 = self._nm_make_ip_settings(config["addresses"]) - - connection = dbus.Dictionary({ - 'team': s_team, - 'ipv4': s_ipv4, - 'ipv6': s_ipv6, - 'connection': s_team_con}) - - self._connection = connection - self._nm_add_connection() - - def _rm_team(self): - if self._con_obj_path != None: - self._nm_rm_connection() - - def _add_slaves(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_configuration() - - teamd_port_config = get_slave_option(self._dev_config, - slave_id, - "teamd_port_config") - - slave_con = dbus.Dictionary() - - if teamd_port_config != None: - s_port_cfg = dbus.Dictionary({ - 'config': teamd_port_config}) - slave_con['team-port'] = s_port_cfg - - slave_config.nm_enslave("team", self._dev_config["master_uuid"], - slave_con) - - def _rm_slaves(self): - for slave_id in get_slaves(self._dev_config): - slave_dev = self._if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_configuration() - slave_config.nm_free() - - def configure(self): - self._add_team() - self._add_slaves() - - def deconfigure(self): - self._rm_slaves() - self._rm_team() - -class NmConfigDeviceOvsBridge(NmConfigDeviceGeneric): - #Not supported by NetworkManager - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - managed = False - - for slave_id in get_slaves(dev_config): - slave_dev = if_manager.get_mapped_device(slave_id) - slave_config = slave_dev.get_conf_dict() - if is_nm_managed(slave_config, if_manager) != managed: - msg = "Mixing NM managed and not managed devices in a "\ - "master-slave relationship is not allowed!" - raise Exception(msg) - - return managed - -class NmConfigDeviceVEth(NmConfigDeviceGeneric): - #Not supported by NetworkManager - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - return False - -class NmConfigDeviceVti(NmConfigDeviceGeneric): - #Not supported by NetworkManager - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - return False - -class NmConfigDeviceVti6(NmConfigDeviceGeneric): - #Not supported by NetworkManager - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - return False - -class NmConfigDeviceLoopback(NmConfigDeviceGeneric): - #Not supported by NetworkManager - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - return False - -class NmConfigDeviceVxlan(NmConfigDeviceGeneric): - #Not supported by NetworkManager - @classmethod - def is_nm_managed(cls, dev_config, if_manager): - return False - -type_class_mapping = { - "eth": NmConfigDeviceEth, - "bond": NmConfigDeviceBond, - "bridge": NmConfigDeviceBridge, - "macvlan": NmConfigDeviceMacvlan, - "vlan": NmConfigDeviceVlan, - "team": NmConfigDeviceTeam, - "ovs_bridge": NmConfigDeviceOvsBridge, - "veth": NmConfigDeviceVEth, - "vti": NmConfigDeviceVti, - "vti6": NmConfigDeviceVti6, - "lo": NmConfigDeviceLoopback, - "vxlan": NmConfigDeviceVxlan -} - -def is_nm_managed(dev_config, if_manager): - if lnst_config.get_option("environment", "use_nm") and\ - check_process_running("NetworkManager"): - return type_class_mapping[dev_config["type"]].is_nm_managed(dev_config, - if_manager) - else: - return False
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Slave/InterfaceManager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py index cc9f2d5..858c32f 100644 --- a/lnst/Slave/InterfaceManager.py +++ b/lnst/Slave/InterfaceManager.py @@ -21,7 +21,8 @@ from lnst.Slave.NetConfigCommon import get_option from lnst.Common.NetUtils import normalize_hwaddr from lnst.Common.ExecCmd import exec_cmd from lnst.Common.ConnectionHandler import recv_data -from lnst.Common.DeviceError import DeviceNotFound, DeviceConfigError, DeviceDeleted +from lnst.Common.DeviceError import (DeviceNotFound, DeviceConfigError, + DeviceDeleted, DeviceError) from lnst.Common.InterfaceManagerError import InterfaceManagerError from lnst.Slave.DevlinkManager import DevlinkManager from pyroute2 import IPRSocket
The directory contains an ancient code that has never been used.
Signed-off-by: Jan Tluka jtluka@redhat.com --- obsolete/SwSwitch/SwSwitch.py | 387 ------------------------- obsolete/SwSwitch/__init__.py | 0 obsolete/Switch/Drivers/SwSwitch.py | 49 ---- obsolete/Switch/Drivers/__init__.py | 0 obsolete/Switch/SwitchConfigParse.py | 73 ----- obsolete/Switch/SwitchCtl.py | 42 --- obsolete/Switch/SwitchDriversCommon.py | 51 ---- obsolete/Switch/__init__.py | 0 obsolete/switchconfig.py | 87 ------ obsolete/swswitch.py | 90 ------ 10 files changed, 779 deletions(-) delete mode 100644 obsolete/SwSwitch/SwSwitch.py delete mode 100644 obsolete/SwSwitch/__init__.py delete mode 100644 obsolete/Switch/Drivers/SwSwitch.py delete mode 100644 obsolete/Switch/Drivers/__init__.py delete mode 100644 obsolete/Switch/SwitchConfigParse.py delete mode 100644 obsolete/Switch/SwitchCtl.py delete mode 100644 obsolete/Switch/SwitchDriversCommon.py delete mode 100644 obsolete/Switch/__init__.py delete mode 100755 obsolete/switchconfig.py delete mode 100755 obsolete/swswitch.py
diff --git a/obsolete/SwSwitch/SwSwitch.py b/obsolete/SwSwitch/SwSwitch.py deleted file mode 100644 index 319c12b..0000000 --- a/obsolete/SwSwitch/SwSwitch.py +++ /dev/null @@ -1,387 +0,0 @@ -""" -This module defines SwSwitch class which operates software switch -and makes it configurable over xmlrpc - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import signal -import select, logging -from Common.Logs import Logs -from Common.XmlRpc import Server -from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler -from NetConfig.NetConfig import NetConfig -from Common.Utils import die_when_parent_die -from NetConfig.NetConfigCommon import get_option - -DefaultRPCPort = 9998 - -NOTE_EXTID = "external_id" -NOTE_VLANNAME = "vlan_name" -NOTE_VLANID = "vlan_id" -DEFAULT_VLAN = 1 - -class SwSwitchCtl: - ''' - This class allows software switch control. Uses NetConfig to do - the hard work of manipulating physical devices. Switch specific - info is stored in "notes" - ''' - - def __init__(self, machine_config_xml): - self._machine_config_xml = machine_config_xml - self._nc = None - self._reinit() - - def _reinit(self): - if self._nc: - self._nc.deconfigure_all() - net_config = NetConfig(self._machine_config_xml) - net_config.configure_all() - - self._nc = net_config - self.vlan_add("default", DEFAULT_VLAN) - - dump = net_config.dump_config() - for dev_id in dump: - netdev = dump[dev_id] - if netdev["type"] != "eth": - continue - net_config.set_notes(dev_id, {NOTE_EXTID: dev_id}) - self.port_vlan_add(dev_id, DEFAULT_VLAN, False) - return True - - def __del__(self): - self._nc.deconfigure_all() - - def _get_dev_id(self, dev_type, external_id=None, vlan_id=None, - vlan_name=None): - ''' - Gets netdev id using one or many parameters - ''' - dump = self._nc.dump_config() - for dev_id in dump: - netdev = dump[dev_id] - if netdev["type"] == dev_type: - if external_id: - if netdev["notes"][NOTE_EXTID] == external_id: - return dev_id - if vlan_id: - if netdev["notes"][NOTE_VLANID] == vlan_id: - return dev_id - if vlan_name: - if netdev["notes"][NOTE_VLANNAME] == vlan_name: - return dev_id - return 0 - - def _get_dev_tagged_vlans(self, dev_id): - ''' - Gets vlan ids of all vlan the netdevice is part of - ''' - vlans = [] - dump = self._nc.dump_config() - for key in dump: - netdev = dump[key] - if (netdev["type"] == "vlan" and - netdev["slaves"][0] == dev_id): - vlans.append(int(get_option(netdev, "vlan_tci"))) - return vlans - - def _get_vlan_dev_id(self, real_dev_id, vlan_id): - ''' - Gets vlan netdev id by given real netdev id and vlan id - ''' - dump = self._nc.dump_config() - for key in dump: - netdev = dump[key] - if (netdev["type"] == "vlan" and - netdev["slaves"][0] == real_dev_id and - int(get_option(netdev, "vlan_tci")) == vlan_id): - return key - - def _get_vlan_real_dev_id(self, vlan_dev_id, vlan_id): - ''' - Gets real netdev id by given vlan netdev id and vlan id - ''' - dump = self._nc.dump_config() - netdev = dump[vlan_dev_id] - if (netdev["type"] == "vlan" and - int(get_option(netdev, "vlan_tci")) == vlan_id): - return netdev["slaves"][0] - - def list_ports(self): - ports = [] - dump = self._nc.dump_config() - for dev_id in dump: - netdev = dump[dev_id] - if netdev["type"] != "eth": - continue - notes = netdev["notes"] - port = {"port": notes[NOTE_EXTID]} - vlans = [] - if NOTE_VLANID in notes: - vlans.append({"vlanid": notes[NOTE_VLANID], "tagged": False}) - tvlans = self._get_dev_tagged_vlans(dev_id) - for tvlan in tvlans: - vlans.append({"vlanid": tvlan, "tagged": True}) - port["vlans"] = vlans - ports.append(port) - return ports - - def _get_extid(self, dump, dev_id): - return dump[dev_id]["notes"][NOTE_EXTID] - - def _get_vlan_ports(self, vlan_id): - ports = [] - dump = self._nc.dump_config() - for dev_id in dump: - netdev = dump[dev_id] - if (netdev["type"] == "eth" and - NOTE_VLANID in netdev["notes"] and - netdev["notes"][NOTE_VLANID] == vlan_id): - port_id = self._get_extid(dump, dev_id) - ports.append({"port": port_id, "tagged": False}) - elif netdev["type"] == "vlan": - real_dev_id = self._get_vlan_real_dev_id(dev_id, vlan_id) - if real_dev_id: - port_id = self._get_extid(dump, real_dev_id) - ports.append({"port": port_id, "tagged": True}) - return ports - - def list_vlans(self): - vlans = [] - dump = self._nc.dump_config() - for dev_id in dump: - netdev = dump[dev_id] - if netdev["type"] != "bridge": - continue - vlan_id = netdev["notes"][NOTE_VLANID] - vlan = {"vlanid": vlan_id, "ports": self._get_vlan_ports(vlan_id)} - vlans.append(vlan) - return vlans - - def vlan_add(self, name, vlan_id): - logging.debug("Adding vlan id "%d"" % vlan_id) - if self._get_dev_id("bridge", vlan_id=vlan_id): - logging.error("Vlan id "%d" already exists" % vlan_id) - return False - br_dev_id = self._nc.netdev_add("bridge") - self._nc.set_notes(br_dev_id, {NOTE_VLANID: vlan_id}) - self._nc.configure(br_dev_id) - return True - - def vlan_del(self, vlan_id): - logging.debug("Deleting vlan id "%d"" % vlan_id) - if vlan_id == DEFAULT_VLAN: - logging.error("cannot delete default vlan id "%d"" % DEFAULT_VLAN) - return False - br_dev_id = self._get_dev_id("bridge", vlan_id=vlan_id) - if not br_dev_id: - logging.error("Vlan id "%d" does not exist" % vlan_id) - return False - - ''' - Remove ports in this vlan first - ''' - ports = self._get_vlan_ports(vlan_id) - for port in ports: - self.port_vlan_del(port["port"], vlan_id, port["tagged"]) - - self._nc.deconfigure(br_dev_id) - self._nc.netdev_del(br_dev_id) - return True - - class DevIdNotFound(Exception): - pass - - def _get_dev_ids(self, port_id, vlan_id): - br_dev_id = self._get_dev_id("bridge", vlan_id=vlan_id) - if not br_dev_id: - logging.error("Vlan id "%d" does not exist" % vlan_id) - raise self.DevIdNotFound - dev_id = self._get_dev_id("eth", external_id=port_id) - if not br_dev_id: - logging.error("Port "%d" does not exist" % vlan_id) - raise self.DevIdNotFound - return br_dev_id, dev_id - - def port_vlan_add(self, port_id, vlan_id, tagged): - logging.debug("Adding port "%d", tagged "%d" to vlan id "%d"" - % (port_id, tagged, vlan_id)) - try: - br_dev_id, dev_id = self._get_dev_ids(port_id, vlan_id) - except self.DevIdNotFound: - return False - - if tagged: - if vlan_id in self._get_dev_tagged_vlans(dev_id): - logging.error("Port "%d", is already tagged part of " - "vlan id "%d"" % (port_id, vlan_id)) - return False - - params = {"options": [("vlan_tci", vlan_id)], - "slaves": set([dev_id])} - vlan_dev_id = self._nc.netdev_add("vlan", params=params) - self._nc.set_notes(vlan_dev_id, {NOTE_VLANID: vlan_id}) - self._nc.configure(vlan_dev_id) - self._nc.slave_add(br_dev_id, vlan_dev_id) - else: - notes = self._nc.get_notes(dev_id) - if NOTE_VLANID in notes: - ''' - In case when the port is already part of untagged vlan, remove - it from this vlan first. - ''' - self.port_vlan_del(port_id, notes[NOTE_VLANID], False) - - self._nc.slave_add(br_dev_id, dev_id) - notes[NOTE_VLANID] = vlan_id - - return True - - def port_vlan_del(self, port_id, vlan_id, tagged): - logging.debug("Removing port "%d", tagged "%d" from vlan id "%d"" - % (port_id, tagged, vlan_id)) - try: - br_dev_id, dev_id = self._get_dev_ids(port_id, vlan_id) - except self.DevIdNotFound: - return False - - if tagged: - if not vlan_id in self._get_dev_tagged_vlans(dev_id): - logging.error("Port "%d", is not tagged part of " - "vlan id "%d"" % (port_id, vlan_id)) - return False - - vlan_dev_id = self._get_vlan_dev_id(dev_id, vlan_id) - self._nc.slave_del(br_dev_id, vlan_dev_id) - self._nc.deconfigure(vlan_dev_id) - self._nc.netdev_del(vlan_dev_id) - else: - notes = self._nc.get_notes(dev_id) - if not NOTE_VLANID in notes: - logging.error("Port "%d" is not untagged part of " - "vlan id "%d"" % (port_id, vlan_id)) - return False - - self._nc.slave_del(br_dev_id, dev_id) - del notes[NOTE_VLANID] - - return True - - def cleanup(self): - logging.debug("Reinitializing") - return self._reinit() - -def int_it(val): - try: - num = int(val) - except ValueError: - num = 0 - return num - -def bool_it(val): - if isinstance(val, str): - if re.match("^\s*(?i)(true)", val): - return True - elif re.match("^\s*(?i)(false)", val): - return False - return True if int_it(val) else False - -class SwSwitchXMLRPC: - ''' - Exported xmlrpc methods. Servers as a wrapper for SwSwitchCtl - ''' - def __init__(self, sw_ctl): - self._sw_ctl = sw_ctl - - def hello(self): - return "hello" - - def set_logging(self, logger_address, port): - """ - Server side setup logging to server side. - - @param logger_address: Address of running logger. - """ - Logs.append_network_hadler(logger_address, port) - return True - - def list_ports(self): - return self._sw_ctl.list_ports() - - def list_vlans(self): - return self._sw_ctl.list_vlans() - - def vlan_add(self, name, vlan_id): - name = str(name) - vlan_id = int_it(vlan_id) - return self._sw_ctl.vlan_add(name, vlan_id) - - def vlan_del(self, vlan_id): - vlan_id = int_it(vlan_id) - return self._sw_ctl.vlan_del(vlan_id) - - def port_vlan_add(self, port_id, vlan_id, tagged): - port_id = int_it(port_id) - vlan_id = int_it(vlan_id) - tagged = bool_it(tagged) - return self._sw_ctl.port_vlan_add(port_id, vlan_id, tagged) - - def port_vlan_del(self, port_id, vlan_id, tagged): - port_id = int_it(port_id) - vlan_id = int_it(vlan_id) - tagged = bool_it(tagged) - return self._sw_ctl.port_vlan_del(port_id, vlan_id, tagged) - - def cleanup(self): - return self._sw_ctl.cleanup() - -class MySimpleXMLRPCServer(Server): - def __init__(self, *args, **kwargs): - self._finished = False - Server.__init__(self, *args, **kwargs) - - def register_die_signal(self, signum): - signal.signal(signum, self._signal_die_handler) - - def _signal_die_handler(self, signum, frame): - logging.info("Caught signal %d -> dying" % signum) - self._finished = True - - def serve_forever_with_signal_check(self): - while True: - try: - if self._finished: - import sys - sys.exit() - return - self.handle_request() - except select.error: - pass - -class SwSwitch: - def __init__(self, machine_config_xml, port = None): - if not port: - port = DefaultRPCPort - - sw_ctl = SwSwitchCtl(machine_config_xml) - - die_when_parent_die() - - server = MySimpleXMLRPCServer(("", port), SimpleXMLRPCRequestHandler, - logRequests = False) - server.register_die_signal(signal.SIGHUP) - server.register_die_signal(signal.SIGINT) - server.register_die_signal(signal.SIGTERM) - server.register_instance(SwSwitchXMLRPC(sw_ctl)) - self._server = server - - def run(self): - self._server.serve_forever_with_signal_check() diff --git a/obsolete/SwSwitch/__init__.py b/obsolete/SwSwitch/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/obsolete/Switch/Drivers/SwSwitch.py b/obsolete/Switch/Drivers/SwSwitch.py deleted file mode 100644 index 810f76c..0000000 --- a/obsolete/Switch/Drivers/SwSwitch.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -This module defines software switch driver - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -from Switch.SwitchDriversCommon import SwitchDriverGeneric -from Common.XmlRpc import ServerProxy - -DefaultRPCPort = 9998 - -class SwSwitch(SwitchDriverGeneric): - def init(self): - info = self._config["info"] - if "port" in info: - port = info["port"] - else: - port = DefaultRPCPort - hostname = info["hostname"] - url = "http://%s:%d" % (hostname, port) - self._rpc = ServerProxy(url) - - def list_ports(self): - return self._rpc.list_ports() - - def list_vlans(self): - return self._rpc.list_vlans() - - def vlan_add(self, name, vlan_id): - return self._rpc.vlan_add(name, vlan_id) - - def vlan_del(self, vlan_id): - return self._rpc.vlan_del(vlan_id) - - def port_vlan_add(self, port_id, vlan_id, tagged): - return self._rpc.port_vlan_add(port_id, vlan_id, tagged) - - def port_vlan_del(self, port_id, vlan_id, tagged): - return self._rpc.port_vlan_del(port_id, vlan_id, tagged) - - def cleanup(self): - return self._rpc.cleanup() diff --git a/obsolete/Switch/Drivers/__init__.py b/obsolete/Switch/Drivers/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/obsolete/Switch/SwitchConfigParse.py b/obsolete/Switch/SwitchConfigParse.py deleted file mode 100644 index eb1ad1d..0000000 --- a/obsolete/Switch/SwitchConfigParse.py +++ /dev/null @@ -1,73 +0,0 @@ -""" -This module defines SwitchConfigParse class useful to parse switch xml configs - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -from xml.dom.minidom import parseString -import logging - -class SwitchConfigParse: - def __init__(self): - pass - - def get_switch_info(self): - return self._machine_info - - def _parse_list(self, result, dom_element, itemname, groupname, - handler, container): - dom_list1 = dom_element.getElementsByTagName(groupname) - if dom_list1: - result[groupname] = container - for dom_item1 in dom_list1: - dom_list2 = dom_item1.getElementsByTagName(itemname) - for dom_item2 in dom_list2: - handler(result[groupname], dom_item2) - - def _parse_vlan_ports_handler(self, dct, dom_element): - port_id = int(dom_element.getAttribute("id")) - tagged = str(dom_element.getAttribute("tagged")) - if tagged == "yes": - tagged = True - elif tagged == "no": - tagged = False - else: - raise Exception - dct[port_id] = {"tagged": tagged} - - def _parse_vlan_ports(self, result, dom_element): - self._parse_list(result, dom_element, "port", "ports", - self._parse_vlan_ports_handler, {}) - - def _parse_vlans_handler(self, dct, dom_element): - name = str(dom_element.getAttribute("name")) - vlan_tci = str(dom_element.getAttribute("vlan_tci")) - vlan = {"name": name} - self._parse_vlan_ports(vlan, dom_element) - dct[vlan_tci] = vlan - - def _parse_vlans(self, result, dom_element): - self._parse_list(result, dom_element, "vlan", "vlans", - self._parse_vlans_handler, {}) - - def parse_switch_config(self, xml_string): - config = {} - dom = parseString(xml_string) - dom_switch = dom.getElementsByTagName("netswitchconfig")[0] - - dom_info = dom_switch.getElementsByTagName("info")[0] - hostname = str(dom_info.getAttribute("hostname")) - port = str(dom_info.getAttribute("port")) - driver = str(dom_info.getAttribute("driver")) - info = {"hostname": hostname, "driver": driver} - if port: - info["port"] = int(port) - config["info"] = info - self._parse_vlans(config, dom_switch) - return config diff --git a/obsolete/Switch/SwitchCtl.py b/obsolete/Switch/SwitchCtl.py deleted file mode 100644 index ea52a3d..0000000 --- a/obsolete/Switch/SwitchCtl.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -This module defines SwitchCtl class useful for switch controlling - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import logging -import copy -import imp -from SwitchConfigParse import SwitchConfigParse - -class SwitchCtl: - def __init__(self, config_xml): - parse = SwitchConfigParse() - self._config = parse.parse_switch_config(config_xml) - - def dump_config(self): - return copy.deepcopy(self._config) - - def _set_driver(self): - driver_name = self._config["info"]["driver"] - path = "Switch/Drivers/%s" % driver_name - fp, pathname, description = imp.find_module(path) - module = imp.load_module(path, fp, pathname, description) - driver_class = getattr(module, driver_name) - self._driver = driver_class(self._config) - - def init(self): - self._set_driver() - self._driver.init() - - def configure(self): - self._driver.configure() - - def cleanup(self): - self._driver.cleanup() diff --git a/obsolete/Switch/SwitchDriversCommon.py b/obsolete/Switch/SwitchDriversCommon.py deleted file mode 100644 index 211d0d4..0000000 --- a/obsolete/Switch/SwitchDriversCommon.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -This module defines common stuff for switch drivers - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -class SwitchOperations: - ''' - This class defines abstract methods which should be implemented - by individual drivers - ''' - def list_ports(self): - raise NotImplementedError() - - def list_vlans(self): - raise NotImplementedError() - - def vlan_add(self, name, vlan_id): - raise NotImplementedError() - - def vlan_del(self, vlan_id): - raise NotImplementedError() - - def port_vlan_add(self, port_id, vlan_id, tagged): - raise NotImplementedError() - - def port_vlan_del(self, port_id, vlan_id, tagged): - raise NotImplementedError() - - def cleanup(self): - raise NotImplementedError() - -class SwitchDriverGeneric(SwitchOperations): - def __init__(self, config): - self._config = config - - def configure(self): - for vlan_id in self._config["vlans"]: - vlan = self._config["vlans"][vlan_id] - vlan_name = vlan["name"] - self.vlan_add(vlan_name, vlan_id) - for port_id in vlan["ports"]: - port = vlan["ports"][port_id] - tagged = port["tagged"] - self.port_vlan_add(port_id, vlan_id, tagged) diff --git a/obsolete/Switch/__init__.py b/obsolete/Switch/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/obsolete/switchconfig.py b/obsolete/switchconfig.py deleted file mode 100755 index ed2b95e..0000000 --- a/obsolete/switchconfig.py +++ /dev/null @@ -1,87 +0,0 @@ -#! /usr/bin/env python -""" -Switchconfig tool -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import getopt -import sys -import logging -import os -from Switch.SwitchCtl import SwitchCtl -from Common.Logs import Logs - -def usage(): - """ - Print usage of this app - """ - print "Usage: switchconfig.py [OPTION...] ACTION" - print "" - print "ACTION = [config | clear | dump]" - print "" - print " -d, --debug emit debugging messages" - print " -h, --help print this message" - print " -c, --config=FILE use this net configuration file" - sys.exit() - -def main(): - """ - Main function - """ - - try: - opts, args = getopt.getopt( - sys.argv[1:], - "dhc:m:a:", - ["debug", "help", "config=", "machine-config=", "action="] - ) - except getopt.GetoptError as err: - print str(err) - usage() - sys.exit() - - debug = False - config_path = None - for opt, arg in opts: - if opt in ("-d", "--debug"): - debug = True - elif opt in ("-h", "--help"): - usage() - elif opt in ("-c", "--config"): - config_path = arg - - Logs(debug) - logging.info("Started") - - if not args: - logging.error("No action command passed") - usage(); - action = args[0] - - if not config_path: - logging.error("No switch config file passed") - usage(); - config_path = os.path.expanduser(config_path) - - handle = open(config_path, "r") - config_xml = handle.read() - handle.close() - - switchctl = SwitchCtl(config_xml) - if action == "config": - switchctl.init() - switchctl.configure() - elif action == "cleanup": - switchctl.init() - switchctl.cleanup() - elif action == "dump": - from pprint import pprint - pprint(switchctl.dump_config()) - else: - logging.error("unknown action "%s"" % action) - -if __name__ == "__main__": - main() diff --git a/obsolete/swswitch.py b/obsolete/swswitch.py deleted file mode 100755 index 42ef900..0000000 --- a/obsolete/swswitch.py +++ /dev/null @@ -1,90 +0,0 @@ -#! /usr/bin/env python -""" -Software switch - -Copyright 2011 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -jpirko@redhat.com (Jiri Pirko) -""" - -import getopt -import sys -import logging -import re -import os -from SwSwitch.SwSwitch import SwSwitch -from Common.Logs import Logs - -def usage(): - """ - Print usage of this app - """ - print "Usage: swswitch.py [OPTION...] ACTION" - print "" - print "ACTION = [run]" - print "" - print " -d, --debug emit debugging messages" - print " -h, --help print this message" - print " -m, --machine-config=FILE use this machine configuration file" - print " -p, --port xmlrpc port" - sys.exit() - -def main(): - """ - Main function - """ - - try: - opts, args = getopt.getopt( - sys.argv[1:], - "dhm:p:", - ["debug", "help", "machine-config=", "port="] - ) - except getopt.GetoptError as err: - print str(err) - usage() - sys.exit() - - debug = False - machine_config_path = None - port = None - for opt, arg in opts: - if opt in ("-d", "--debug"): - debug = True - elif opt in ("-h", "--help"): - usage() - elif opt in ("-m", "--machine-config"): - machine_config_path = arg - elif opt in ("-p", "--port"): - port = int(arg) - - Logs(debug, True) - logging.info("Started") - - if not args: - logging.error("No action command passed") - usage(); - action = args[0] - - if not machine_config_path: - logging.error("No machine config xml file passed") - usage(); - machine_config_path = os.path.expanduser(machine_config_path) - - handle = open(machine_config_path, "r") - machine_config_xml = handle.read() - handle.close() - - if action == "run": - swswitch = SwSwitch(machine_config_xml, port=port) - swswitch.run() - else: - logging.error("unknown action "%s"" % action) - usage(); - -if __name__ == "__main__": - main()
Signed-off-by: Jan Tluka jtluka@redhat.com --- misc/recipe_conv.py | 134 -------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100755 misc/recipe_conv.py
diff --git a/misc/recipe_conv.py b/misc/recipe_conv.py deleted file mode 100755 index 3e133f1..0000000 --- a/misc/recipe_conv.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env python3 -""" -Recipe converter - -This script will help you convert your old recipes with the -outdated conventions that are now unsupported in LNST. - -You can pass a list of files or dirs to it and it will -remove all recipe-evals and change netdevices in netconfig -to interfaces. - -Copyright 2012 Red Hat, Inc. -Licensed under the GNU General Public License, version 2 as -published by the Free Software Foundation; see COPYING for details. -""" - -__author__ = """ -rpazdera@redhat.com (Radek Pazdera) -""" - -import sys -import os -import re -from xml.dom.minidom import parse - -def change_netdev_to_iface(dom): - configs = dom.getElementsByTagName("netconfig") - for config in configs: - netdevs = config.getElementsByTagName("netdevice") - for dev in netdevs: - dev.tagName = "interface" - -def remove_recipe_eval(dom): - opts = dom.getElementsByTagName("option") - for opt in opts: - if opt.hasAttribute("type"): - opt_type = opt.getAttribute("type") - if opt_type == "recipe_eval": - opt.removeAttribute("type") - subscript = opt.getAttribute("value") - opt.setAttribute("value", "{$recipe%s}" % subscript) - -def _rename_attr(node, prev_name, new_name): - if node.hasAttribute(prev_name): - value = node.getAttribute(prev_name) - node.removeAttribute(prev_name) - node.setAttribute(new_name, value) - -def cmd_seqs_to_tasks(dom): - seqs = dom.getElementsByTagName("command_sequence") - - for seq in seqs: - dom.renameNode(seq, "task", "task") - - cmds = seq.getElementsByTagName("command") - for cmd in cmds: - cmd_type = cmd.getAttribute("type") - cmd.removeAttribute("type") - - dom.renameNode(cmd, cmd_type, cmd_type) - - if cmd.hasAttribute("machine_id"): - _rename_attr(cmd, "machine_id", "machine") - - # Change 'pass_result' to expect - if cmd.hasAttribute("pass_result"): - value = cmd.getAttribute("pass_result") - cmd.removeAttribute("pass_result") - - # In this case, the value must be converted as well - value = "fail" - if re.match(r"(?i)(true)", value) or \ - re.match(r"(?i)(yes)", value) or value == "1": - value = "pass" - cmd.setAttribute("expect", value) - - if cmd_type == "test": - dom.renameNode(cmd, "run", "run") - _rename_attr(cmd, "value", "module") - elif cmd_type == "exec": - dom.renameNode(cmd, "run", "run") - _rename_attr(cmd, "value", "command") - elif cmd_type == "system_config": - dom.renameNode(cmd, "config", "config") - elif cmd_type in ["wait", "intr", "kill"]: - _rename_attr(cmd, "value", "bg_id") - elif cmd_type == "ctl_wait": - _rename_attr(cmd, "value", "seconds") - -def convert_recipe(file_path): - dom = parse(file_path) - - #change_netdev_to_iface(dom) - #remove_recipe_eval(dom) - cmd_seqs_to_tasks(dom) - - output = dom.toxml() - output = re.sub(r"<?xml[^>]*?>", "", output) - - output = output.replace(""", """) - output = output.replace(">", ">") - output = output.replace("<", "<") - - writer = open(file_path, "w") - writer.write(output) - writer.close() - -def usage(): - print("Usage: %s recipe1 recipe2 dir1 ..." % sys.argv[0]) - -def main(): - if len(sys.argv) <= 1 or "-h" in sys.argv: - usage() - return 0 - - files = sys.argv[1:] - - for file_path in files: - if os.path.isdir(file_path): - for root, dirs, file_names in os.walk(file_path): - for file_name in file_names: - if re.match(r"^.*.xml$", file_name): - full_path = "%s/%s" % (root, file_name) - full_path = os.path.normpath(full_path) - print("Converting %s" % full_path) - convert_recipe(full_path) - else: - print("Converting %s" % file_path) - convert_recipe(file_path) - return 0 - -if __name__ == "__main__": - rv = main() - sys.exit(rv)
Signed-off-by: Jan Tluka jtluka@redhat.com --- schema-recipe.rng | 715 ---------------------------------------------- 1 file changed, 715 deletions(-) delete mode 100644 schema-recipe.rng
diff --git a/schema-recipe.rng b/schema-recipe.rng deleted file mode 100644 index ca06eb8..0000000 --- a/schema-recipe.rng +++ /dev/null @@ -1,715 +0,0 @@ -<grammar xmlns="http://relaxng.org/ns/structure/1.0" - datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes%22%3E - <start> - <element name="lnstrecipe"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <ref name="network"/> - - <oneOrMore> - <ref name="task"/> - </oneOrMore> - </interleave> - </element> - </start> - - <define name="define"> - <element name="define"> - <oneOrMore> - <element name="alias"> - <attribute name="name"/> - <choice> - <attribute name="value"/> - <text/> - </choice> - </element> - </oneOrMore> - </element> - </define> - - <define name="network"> - <element name="network"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <oneOrMore> - <ref name="host"/> - </oneOrMore> - </interleave> - </element> - </define> - - <define name="task"> - <choice> - <element name="task"> - <attribute name="python"/> - - <optional> - <attribute name="quit_on_fail"> - <choice> - <value>yes</value> - <value>no</value> - <value>true</value> - <value>false</value> - </choice> - </attribute> - </optional> - - <optional> - <attribute name="module_dir"/> - </optional> - - <optional> - <attribute name="tools_dir"/> - </optional> - </element> - <ref name="xml_task"/> - </choice> - </define> - - <define name="xml_task"> - <element name="task"> - <optional> - <attribute name="label"/> - </optional> - - <optional> - <attribute name="quit_on_fail"> - <choice> - <value>yes</value> - <value>no</value> - <value>true</value> - <value>false</value> - </choice> - </attribute> - </optional> - - <optional> - <attribute name="module_dir"/> - </optional> - - <optional> - <attribute name="tools_dir"/> - </optional> - - <oneOrMore> - <choice> - <ref name="run"/> - <ref name="config"/> - <ref name="wait"/> - <ref name="intr"/> - <ref name="kill"/> - <ref name="ctl_wait"/> - - <ref name="define"/> - </choice> - </oneOrMore> - </element> - </define> - - <define name="host"> - <element name="host"> - <attribute name="id"/> - - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="params"/> - </zeroOrMore> - - <element name="interfaces"> - <zeroOrMore> - <choice> - <ref name="eth"/> - <ref name="bond"/> - <ref name="bridge"/> - <ref name="vlan"/> - <ref name="macvlan"/> - <ref name="team"/> - <ref name="ovs_bridge"/> - <ref name="veth_pair"/> - <ref name="vti"/> - <ref name="vti6"/> - <ref name="lo"/> - <ref name="vxlan"/> - </choice> - </zeroOrMore> - </element> - </interleave> - </element> - </define> - - <define name="eth"> - <element name="eth"> - <attribute name="id"/> - <attribute name="label"/> - <optional> - <attribute name="netns"/> - </optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="params"/> - </zeroOrMore> - - <optional> - <ref name="addresses"/> - </optional> - - <optional> - <ref name="netem"/> - </optional> - </interleave> - </element> - </define> - - <define name="bond"> - <element name="bond"> - <attribute name="id"/> - <ref name="softdevice"/> - </element> - </define> - - <define name="bridge"> - <element name="bridge"> - <attribute name="id"/> - <ref name="softdevice"/> - </element> - </define> - - <define name="ovs_bridge"> - <element name="ovs_bridge"> - <attribute name="id"/> - <optional> - <attribute name="netns"/> - </optional> - - <interleave> - <optional> - <ref name="define"/> - </optional> - - <optional> - <element name="slaves"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <oneOrMore> - <element name="slave"> - <attribute name="id"/> - <optional> - <ref name="options"/> - </optional> - </element> - </oneOrMore> - </interleave> - </element> - </optional> - - <zeroOrMore> - <element name="bond"> - <attribute name="id"/> - - <interleave> - <optional> - <ref name="define"/> - </optional> - - <optional> - <ref name="options"/> - </optional> - - <element name="slaves"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <oneOrMore> - <element name="slave"> - <attribute name="id"/> - </element> - </oneOrMore> - </interleave> - </element> - </interleave> - </element> - </zeroOrMore> - <zeroOrMore> - <element name="vlan"> - <attribute name="tag"/> - - <interleave> - <optional> - <ref name="define"/> - </optional> - - <element name="slaves"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <oneOrMore> - <element name="slave"> - <attribute name="id"/> - </element> - </oneOrMore> - </interleave> - </element> - </interleave> - </element> - </zeroOrMore> - <zeroOrMore> - <element name="tunnel"> - <attribute name="id"/> - <attribute name="type"> - <choice> - <value>vxlan</value> - <value>gre</value> - <value>geneve</value> - </choice> - </attribute> - <interleave> - <optional> - <ref name="options"/> - </optional> - <optional> - <ref name="addresses"/> - </optional> - </interleave> - </element> - </zeroOrMore> - <zeroOrMore> - <element name="internal"> - <attribute name="id"/> - <interleave> - <optional> - <ref name="options"/> - </optional> - <optional> - <ref name="addresses"/> - </optional> - </interleave> - </element> - </zeroOrMore> - <optional> - <element name="flow_entries"> - <oneOrMore> - <element name="entry"> - <choice> - <attribute name="value"/> - <text/> - </choice> - </element> - </oneOrMore> - </element> - </optional> - </interleave> - </element> - </define> - - <define name="vlan"> - <element name="vlan"> - <attribute name="id"/> - <ref name="softdevice"/> - </element> - </define> - - <define name="macvlan"> - <element name="macvlan"> - <attribute name="id"/> - <ref name="softdevice"/> - </element> - </define> - - <define name="team"> - <element name="team"> - <attribute name="id"/> - <ref name="softdevice"/> - </element> - </define> - - <define name="vxlan"> - <element name="vxlan"> - <attribute name="id"/> - <ref name="softdevice"/> - </element> - </define> - - <define name="softdevice"> - <optional> - <attribute name="netns"/> - </optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <optional> - <ref name="options"/> - </optional> - - <optional> - <element name="slaves"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <element name="slave"> - <attribute name="id"/> - - <optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="options"/> - </zeroOrMore> - </interleave> - </optional> - - </element> - </zeroOrMore> - </interleave> - </element> - </optional> - - <optional> - <ref name="addresses"/> - </optional> - </interleave> - </define> - - <define name="veth_pair"> - <element name="veth_pair"> - <optional> - <ref name="define"/> - </optional> - <ref name="veth"/> - <optional> - <ref name="define"/> - </optional> - <ref name="veth"/> - </element> - </define> - - <define name="veth"> - <element name="veth"> - <attribute name="id"/> - <optional> - <attribute name="netns"/> - </optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="options"/> - </zeroOrMore> - - <optional> - <ref name="addresses"/> - </optional> - </interleave> - </element> - </define> - - <define name="vti"> - <element name="vti"> - <attribute name="id"/> - <optional> - <attribute name="netns"/> - </optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="options"/> - </zeroOrMore> - </interleave> - </element> - </define> - - <define name="vti6"> - <element name="vti6"> - <attribute name="id"/> - <optional> - <attribute name="netns"/> - </optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="options"/> - </zeroOrMore> - </interleave> - </element> - </define> - - <define name="lo"> - <element name="lo"> - <attribute name="id"/> - <optional> - <attribute name="netns"/> - </optional> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <ref name="options"/> - </zeroOrMore> - - <optional> - <ref name="addresses"/> - </optional> - </interleave> - </element> - </define> - - <define name="options"> - <element name="options"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <element name="option"> - <attribute name="name"/> - <choice> - <attribute name="value"/> - <text/> - </choice> - </element> - </zeroOrMore> - </interleave> - </element> - </define> - - <define name="addresses"> - <element name="addresses"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <element name="address"> - <choice> - <attribute name="value"/> - <text/> - </choice> - </element> - </zeroOrMore> - </interleave> - </element> - </define> - - <define name="netem"> - <element name="netem"> - <interleave> - <optional> - <element name="delay"> - <optional> - <ref name="options"/> - </optional> - </element> - </optional> - <optional> - <element name="loss"> - <optional> - <ref name="options"/> - </optional> - </element> - </optional> - <optional> - <element name="duplication"> - <optional> - <ref name="options"/> - </optional> - </element> - </optional> - <optional> - <element name="corrupt"> - <optional> - <ref name="options"/> - </optional> - </element> - </optional> - <optional> - <element name="reordering"> - <optional> - <ref name="options"/> - </optional> - </element> - </optional> - </interleave> - </element> - </define> - - <define name="params"> - <element name="params"> - <interleave> - <optional> - <ref name="define"/> - </optional> - - <zeroOrMore> - <element name="param"> - <attribute name="name"/> - <choice> - <attribute name="value"/> - <text/> - </choice> - </element> - </zeroOrMore> - </interleave> - </element> - </define> - - <define name="config"> - <element name="config"> - <attribute name="host"/> - - <optional> - <attribute name="netns"/> - </optional> - - <optional> - <attribute name="option"/> - <attribute name="value"/> - </optional> - - <!-- Should config have timeout? --> - <optional> - <attribute name="timeout"> - <data type="integer"/> - </attribute> - </optional> - - <optional> - <attribute name="persistent"> - <choice> - <value>true</value> - <value>false</value> - <value>yes</value> - <value>no</value> - <value>1</value> - <value>0</value> - </choice> - </attribute> - </optional> - - <optional> - <attribute name="desc"/> - </optional> - - <optional> - <ref name="options"/> - </optional> - </element> - </define> - - <define name="run"> - <element name="run"> - <attribute name="host"/> - - <optional> - <attribute name="netns"/> - </optional> - - <choice> - <attribute name="module"/> - <ref name="run_command"/> - </choice> - - <optional> - <attribute name="bg_id"/> - </optional> - - <optional> - <attribute name="expect"/> - </optional> - - <optional> - <attribute name="timeout"> - <data type="integer"/> - </attribute> - </optional> - - <optional> - <attribute name="desc"/> - </optional> - - <optional> - <ref name="options"/> - </optional> - </element> - </define> - - <define name="run_command"> - <choice> - <attribute name="command"/> - <ref name="run_tool"/> - </choice> - </define> - - <define name="run_tool"> - <attribute name="command"/> - <attribute name="from"/> - </define> - - <define name="wait"> - <element name="wait"> - <ref name="signal_command"/> - </element> - </define> - - <define name="intr"> - <element name="intr"> - <ref name="signal_command"/> - </element> - </define> - - <define name="kill"> - <element name="kill"> - <ref name="signal_command"/> - </element> - </define> - - <define name="signal_command"> - <attribute name="host"/> - <attribute name="bg_id"/> - </define> - - <define name="ctl_wait"> - <element name="ctl_wait"> - <attribute name="seconds"/> - </element> - </define> -</grammar>
On Tue, Feb 25, 2020 at 02:53:25PM +0100, Jan Tluka wrote:
This is an initial code cleanup after major redesign of LNST.
Most of it is removal of code that cannot be used anymore due to API change. I did also some pylint checks on the code where I found minor issues.
Jan Tluka (20): lnst/Slave/NetTestSlave.py: remove NetTestCommand references remove already ported IcmpPing and Icmp6Ping test modules remove legacy PacketAssert test module remove legacy Iperf test module remove legacy test_modules remove deprecated regression_tests move DEFAULT_TIMEOUT definiton from NetTestCommand to Job remove legacy TestsCommon remove legacy NetTestCommand class remove pyrecipes lnst/Common/Parameters: fix missing parameter in ListParam type_check lnst/Common/TestRecipe: fix typo lnst.RecipeCommon.Perf.Results: remove deprecated __setslice__ BaselineEvaluator: fix missing self handle in describe_group_results remove obsolete NetConfigDevice module remove obsolete NmConfigDevice module lnst.Slave.InterfaceManager: add missing import of DeviceError remove directory obsolete remove obsolete recipe_conv.py remove obsolete recipe-schema.rng
lnst/Common/NetTestCommand.py | 571 ----------- lnst/Common/Parameters.py | 4 +- lnst/Common/TestsCommon.py | 147 --- lnst/Controller/Job.py | 3 +- lnst/Controller/Namespace.py | 2 +- lnst/Controller/NetNamespace.py | 1 - .../Perf/Evaluators/BaselineEvaluator.py | 2 +- lnst/RecipeCommon/Perf/Results.py | 16 +- lnst/RecipeCommon/TestRecipe.py | 2 +- lnst/Slave/InterfaceManager.py | 3 +- lnst/Slave/NetConfigDevice.py | 741 --------------- lnst/Slave/NetTestSlave.py | 19 - lnst/Slave/NmConfigDevice.py | 888 ------------------ misc/recipe_conv.py | 134 --- obsolete/SwSwitch/SwSwitch.py | 387 -------- obsolete/SwSwitch/__init__.py | 0 obsolete/Switch/Drivers/SwSwitch.py | 49 - obsolete/Switch/Drivers/__init__.py | 0 obsolete/Switch/SwitchConfigParse.py | 73 -- obsolete/Switch/SwitchCtl.py | 42 - obsolete/Switch/SwitchDriversCommon.py | 51 - obsolete/Switch/__init__.py | 0 obsolete/netconfig.py | 206 ---- obsolete/switchconfig.py | 87 -- obsolete/swswitch.py | 90 -- pyrecipes/3_vlans.py | 34 - pyrecipes/example.py | 33 - pyrecipes/ping_flood.py | 48 - regression-tests/README.md | 112 --- regression-tests/env/lnst-ctl.conf | 16 - regression-tests/run-test.sh | 253 ----- regression-tests/tests/0/desc | 6 - regression-tests/tests/0/run.sh | 24 - regression-tests/tests/1/desc | 4 - regression-tests/tests/1/recipe.xml | 33 - regression-tests/tests/1/run.sh | 12 - regression-tests/tests/10/desc | 4 - .../tests/10/prefix-check-taskapi.xml | 33 - regression-tests/tests/10/prefix-check.py | 15 - regression-tests/tests/10/prefix-check.xml | 44 - regression-tests/tests/10/run.sh | 39 - regression-tests/tests/11/desc | 3 - regression-tests/tests/11/recipe.xml | 33 - regression-tests/tests/11/run.sh | 15 - regression-tests/tests/12/desc | 1 - regression-tests/tests/12/run.sh | 12 - regression-tests/tests/12/sm01.xml | 7 - regression-tests/tests/12/sm02.xml | 7 - regression-tests/tests/12/xinclude-check.xml | 13 - regression-tests/tests/13/desc | 1 - regression-tests/tests/13/run.sh | 22 - .../tests/13/taskapi-alias-check.py | 9 - .../tests/13/taskapi-alias-check.xml | 38 - .../tests/13/taskapi-alias-namespace-check.py | 8 - .../13/taskapi-alias-namespace-check.xml | 41 - regression-tests/tests/14/desc | 3 - regression-tests/tests/14/recipe1.xml | 68 -- regression-tests/tests/14/recipe2.xml | 79 -- regression-tests/tests/14/run.sh | 17 - regression-tests/tests/15/desc | 3 - regression-tests/tests/15/recipe.xml | 33 - regression-tests/tests/15/run.sh | 12 - regression-tests/tests/16/desc | 3 - regression-tests/tests/16/recipe.xml | 37 - regression-tests/tests/16/run.sh | 14 - regression-tests/tests/17/desc | 3 - regression-tests/tests/17/recipe.xml | 38 - regression-tests/tests/17/run.sh | 14 - regression-tests/tests/18/desc | 6 - regression-tests/tests/18/recipe.xml | 26 - regression-tests/tests/18/run.sh | 19 - regression-tests/tests/19/desc | 3 - regression-tests/tests/19/recipe.xml | 17 - regression-tests/tests/19/run.sh | 19 - regression-tests/tests/2/desc | 5 - regression-tests/tests/2/recipe.xml | 74 -- regression-tests/tests/2/run.sh | 12 - regression-tests/tests/20/desc | 3 - regression-tests/tests/20/recipe1.xml | 47 - regression-tests/tests/20/recipe2.xml | 31 - regression-tests/tests/20/run.sh | 20 - regression-tests/tests/21/desc | 3 - regression-tests/tests/21/lnst-ctl.conf | 3 - regression-tests/tests/21/recipe.xml | 55 -- regression-tests/tests/21/run.sh | 18 - .../tests/21/test_modules/TCPConnection.py | 60 -- .../tests/21/test_tools/tcp_conn/Makefile | 12 - .../21/test_tools/tcp_conn/lnst-setup.sh | 3 - .../21/test_tools/tcp_conn/tcp_connect.c | 281 ------ .../tests/21/test_tools/tcp_conn/tcp_listen.c | 330 ------- regression-tests/tests/22/desc | 3 - regression-tests/tests/22/lnst-ctl.conf | 2 - regression-tests/tests/22/pool/slave1.xml | 6 - regression-tests/tests/22/pool/slave2.xml | 6 - regression-tests/tests/22/recipe.xml | 26 - regression-tests/tests/22/run.sh | 18 - regression-tests/tests/23/desc | 3 - regression-tests/tests/23/lnst-ctl.conf | 2 - regression-tests/tests/23/recipe.xml | 42 - regression-tests/tests/23/run.sh | 19 - .../tests/23/test_modules/IcmpPing.py | 71 -- regression-tests/tests/24/desc | 6 - regression-tests/tests/24/recipe_fail.xml | 33 - regression-tests/tests/24/recipe_pass.xml | 33 - regression-tests/tests/24/run.sh | 22 - regression-tests/tests/25/desc | 12 - regression-tests/tests/25/recipe1.xml | 44 - regression-tests/tests/25/recipe2.xml | 53 -- regression-tests/tests/25/recipe3.xml | 28 - regression-tests/tests/25/run.sh | 27 - regression-tests/tests/26/desc | 7 - regression-tests/tests/26/recipe1.xml | 46 - regression-tests/tests/26/recipe2.xml | 46 - regression-tests/tests/26/run.sh | 24 - regression-tests/tests/27/desc | 10 - regression-tests/tests/27/recipe1.xml | 32 - regression-tests/tests/27/recipe2.xml | 32 - regression-tests/tests/27/recipe3.xml | 31 - regression-tests/tests/27/recipe4.xml | 31 - regression-tests/tests/27/recipe5.xml | 32 - regression-tests/tests/27/recipe6.xml | 30 - regression-tests/tests/27/recipe7.xml | 30 - regression-tests/tests/27/recipe8.xml | 32 - regression-tests/tests/27/run.sh | 48 - regression-tests/tests/28/desc | 6 - regression-tests/tests/28/recipe1.py | 20 - regression-tests/tests/28/recipe1.xml | 16 - regression-tests/tests/28/recipe2.py | 18 - regression-tests/tests/28/recipe2.xml | 16 - regression-tests/tests/28/recipe3.py | 11 - regression-tests/tests/28/recipe3.xml | 16 - regression-tests/tests/28/recipe4.py | 15 - regression-tests/tests/28/recipe4.xml | 16 - regression-tests/tests/28/run.sh | 34 - regression-tests/tests/3/desc | 8 - regression-tests/tests/3/recipe.xml | 21 - regression-tests/tests/3/run.sh | 12 - regression-tests/tests/4/desc | 3 - regression-tests/tests/4/recipe.xml | 43 - regression-tests/tests/4/run.sh | 19 - regression-tests/tests/5/desc | 3 - regression-tests/tests/5/recipe.xml | 29 - regression-tests/tests/5/run.sh | 20 - regression-tests/tests/6/desc | 4 - regression-tests/tests/6/recipe.xml | 35 - regression-tests/tests/6/run.sh | 19 - regression-tests/tests/7/desc | 4 - regression-tests/tests/7/recipe.xml | 24 - regression-tests/tests/7/run.sh | 19 - regression-tests/tests/7/task.py | 23 - regression-tests/tests/8/desc | 3 - regression-tests/tests/8/recipe.xml | 26 - regression-tests/tests/8/run.sh | 12 - regression-tests/tests/9/desc | 3 - regression-tests/tests/9/recipe.xml | 24 - regression-tests/tests/9/run.sh | 12 - regression-tests/tests/9/task.py | 9 - regression-tests/tests/lib.sh | 67 -- schema-recipe.rng | 715 -------------- test_modules/Custom.py | 31 - test_modules/DummyFailing.py | 19 - test_modules/Icmp6Ping.py | 74 -- test_modules/IcmpPing.py | 71 -- test_modules/Iperf.py | 160 ---- test_modules/LinkNeg.py | 59 -- test_modules/Multicast.py | 134 --- test_modules/NetCat.py | 69 -- test_modules/Netperf.py | 579 ------------ test_modules/PacketAssert.py | 148 --- test_modules/PktCounter.py | 89 -- test_modules/PktgenTx.py | 93 -- test_modules/TCPConnection.py | 60 -- 172 files changed, 18 insertions(+), 9589 deletions(-) delete mode 100644 lnst/Common/NetTestCommand.py delete mode 100644 lnst/Common/TestsCommon.py delete mode 100644 lnst/Slave/NetConfigDevice.py delete mode 100644 lnst/Slave/NmConfigDevice.py delete mode 100755 misc/recipe_conv.py delete mode 100644 obsolete/SwSwitch/SwSwitch.py delete mode 100644 obsolete/SwSwitch/__init__.py delete mode 100644 obsolete/Switch/Drivers/SwSwitch.py delete mode 100644 obsolete/Switch/Drivers/__init__.py delete mode 100644 obsolete/Switch/SwitchConfigParse.py delete mode 100644 obsolete/Switch/SwitchCtl.py delete mode 100644 obsolete/Switch/SwitchDriversCommon.py delete mode 100644 obsolete/Switch/__init__.py delete mode 100755 obsolete/netconfig.py delete mode 100755 obsolete/switchconfig.py delete mode 100755 obsolete/swswitch.py delete mode 100644 pyrecipes/3_vlans.py delete mode 100644 pyrecipes/example.py delete mode 100644 pyrecipes/ping_flood.py delete mode 100644 regression-tests/README.md delete mode 100644 regression-tests/env/lnst-ctl.conf delete mode 100755 regression-tests/run-test.sh delete mode 100644 regression-tests/tests/0/desc delete mode 100755 regression-tests/tests/0/run.sh delete mode 100644 regression-tests/tests/1/desc delete mode 100644 regression-tests/tests/1/recipe.xml delete mode 100755 regression-tests/tests/1/run.sh delete mode 100644 regression-tests/tests/10/desc delete mode 100644 regression-tests/tests/10/prefix-check-taskapi.xml delete mode 100644 regression-tests/tests/10/prefix-check.py delete mode 100644 regression-tests/tests/10/prefix-check.xml delete mode 100755 regression-tests/tests/10/run.sh delete mode 100644 regression-tests/tests/11/desc delete mode 100644 regression-tests/tests/11/recipe.xml delete mode 100755 regression-tests/tests/11/run.sh delete mode 100644 regression-tests/tests/12/desc delete mode 100755 regression-tests/tests/12/run.sh delete mode 100644 regression-tests/tests/12/sm01.xml delete mode 100644 regression-tests/tests/12/sm02.xml delete mode 100644 regression-tests/tests/12/xinclude-check.xml delete mode 100644 regression-tests/tests/13/desc delete mode 100755 regression-tests/tests/13/run.sh delete mode 100644 regression-tests/tests/13/taskapi-alias-check.py delete mode 100644 regression-tests/tests/13/taskapi-alias-check.xml delete mode 100644 regression-tests/tests/13/taskapi-alias-namespace-check.py delete mode 100644 regression-tests/tests/13/taskapi-alias-namespace-check.xml delete mode 100644 regression-tests/tests/14/desc delete mode 100644 regression-tests/tests/14/recipe1.xml delete mode 100644 regression-tests/tests/14/recipe2.xml delete mode 100755 regression-tests/tests/14/run.sh delete mode 100644 regression-tests/tests/15/desc delete mode 100644 regression-tests/tests/15/recipe.xml delete mode 100755 regression-tests/tests/15/run.sh delete mode 100644 regression-tests/tests/16/desc delete mode 100644 regression-tests/tests/16/recipe.xml delete mode 100755 regression-tests/tests/16/run.sh delete mode 100644 regression-tests/tests/17/desc delete mode 100644 regression-tests/tests/17/recipe.xml delete mode 100755 regression-tests/tests/17/run.sh delete mode 100644 regression-tests/tests/18/desc delete mode 100644 regression-tests/tests/18/recipe.xml delete mode 100755 regression-tests/tests/18/run.sh delete mode 100644 regression-tests/tests/19/desc delete mode 100644 regression-tests/tests/19/recipe.xml delete mode 100755 regression-tests/tests/19/run.sh delete mode 100644 regression-tests/tests/2/desc delete mode 100644 regression-tests/tests/2/recipe.xml delete mode 100755 regression-tests/tests/2/run.sh delete mode 100644 regression-tests/tests/20/desc delete mode 100644 regression-tests/tests/20/recipe1.xml delete mode 100644 regression-tests/tests/20/recipe2.xml delete mode 100755 regression-tests/tests/20/run.sh delete mode 100644 regression-tests/tests/21/desc delete mode 100644 regression-tests/tests/21/lnst-ctl.conf delete mode 100644 regression-tests/tests/21/recipe.xml delete mode 100755 regression-tests/tests/21/run.sh delete mode 100644 regression-tests/tests/21/test_modules/TCPConnection.py delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/Makefile delete mode 100755 regression-tests/tests/21/test_tools/tcp_conn/lnst-setup.sh delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/tcp_connect.c delete mode 100644 regression-tests/tests/21/test_tools/tcp_conn/tcp_listen.c delete mode 100644 regression-tests/tests/22/desc delete mode 100644 regression-tests/tests/22/lnst-ctl.conf delete mode 100644 regression-tests/tests/22/pool/slave1.xml delete mode 100644 regression-tests/tests/22/pool/slave2.xml delete mode 100644 regression-tests/tests/22/recipe.xml delete mode 100755 regression-tests/tests/22/run.sh delete mode 100644 regression-tests/tests/23/desc delete mode 100644 regression-tests/tests/23/lnst-ctl.conf delete mode 100644 regression-tests/tests/23/recipe.xml delete mode 100755 regression-tests/tests/23/run.sh delete mode 100644 regression-tests/tests/23/test_modules/IcmpPing.py delete mode 100644 regression-tests/tests/24/desc delete mode 100644 regression-tests/tests/24/recipe_fail.xml delete mode 100644 regression-tests/tests/24/recipe_pass.xml delete mode 100755 regression-tests/tests/24/run.sh delete mode 100644 regression-tests/tests/25/desc delete mode 100644 regression-tests/tests/25/recipe1.xml delete mode 100644 regression-tests/tests/25/recipe2.xml delete mode 100644 regression-tests/tests/25/recipe3.xml delete mode 100755 regression-tests/tests/25/run.sh delete mode 100644 regression-tests/tests/26/desc delete mode 100644 regression-tests/tests/26/recipe1.xml delete mode 100644 regression-tests/tests/26/recipe2.xml delete mode 100755 regression-tests/tests/26/run.sh delete mode 100644 regression-tests/tests/27/desc delete mode 100644 regression-tests/tests/27/recipe1.xml delete mode 100644 regression-tests/tests/27/recipe2.xml delete mode 100644 regression-tests/tests/27/recipe3.xml delete mode 100644 regression-tests/tests/27/recipe4.xml delete mode 100644 regression-tests/tests/27/recipe5.xml delete mode 100644 regression-tests/tests/27/recipe6.xml delete mode 100644 regression-tests/tests/27/recipe7.xml delete mode 100644 regression-tests/tests/27/recipe8.xml delete mode 100755 regression-tests/tests/27/run.sh delete mode 100644 regression-tests/tests/28/desc delete mode 100644 regression-tests/tests/28/recipe1.py delete mode 100644 regression-tests/tests/28/recipe1.xml delete mode 100644 regression-tests/tests/28/recipe2.py delete mode 100644 regression-tests/tests/28/recipe2.xml delete mode 100644 regression-tests/tests/28/recipe3.py delete mode 100644 regression-tests/tests/28/recipe3.xml delete mode 100644 regression-tests/tests/28/recipe4.py delete mode 100644 regression-tests/tests/28/recipe4.xml delete mode 100755 regression-tests/tests/28/run.sh delete mode 100644 regression-tests/tests/3/desc delete mode 100644 regression-tests/tests/3/recipe.xml delete mode 100755 regression-tests/tests/3/run.sh delete mode 100644 regression-tests/tests/4/desc delete mode 100644 regression-tests/tests/4/recipe.xml delete mode 100755 regression-tests/tests/4/run.sh delete mode 100644 regression-tests/tests/5/desc delete mode 100644 regression-tests/tests/5/recipe.xml delete mode 100755 regression-tests/tests/5/run.sh delete mode 100644 regression-tests/tests/6/desc delete mode 100644 regression-tests/tests/6/recipe.xml delete mode 100755 regression-tests/tests/6/run.sh delete mode 100644 regression-tests/tests/7/desc delete mode 100644 regression-tests/tests/7/recipe.xml delete mode 100755 regression-tests/tests/7/run.sh delete mode 100644 regression-tests/tests/7/task.py delete mode 100644 regression-tests/tests/8/desc delete mode 100644 regression-tests/tests/8/recipe.xml delete mode 100755 regression-tests/tests/8/run.sh delete mode 100644 regression-tests/tests/9/desc delete mode 100644 regression-tests/tests/9/recipe.xml delete mode 100755 regression-tests/tests/9/run.sh delete mode 100644 regression-tests/tests/9/task.py delete mode 100644 regression-tests/tests/lib.sh delete mode 100644 schema-recipe.rng delete mode 100644 test_modules/Custom.py delete mode 100644 test_modules/DummyFailing.py delete mode 100644 test_modules/Icmp6Ping.py delete mode 100644 test_modules/IcmpPing.py delete mode 100644 test_modules/Iperf.py delete mode 100644 test_modules/LinkNeg.py delete mode 100644 test_modules/Multicast.py delete mode 100644 test_modules/NetCat.py delete mode 100644 test_modules/Netperf.py delete mode 100644 test_modules/PacketAssert.py delete mode 100644 test_modules/PktCounter.py delete mode 100644 test_modules/PktgenTx.py delete mode 100644 test_modules/TCPConnection.py
-- 2.21.1 _______________________________________________ LNST-developers mailing list -- lnst-developers@lists.fedorahosted.org To unsubscribe send an email to lnst-developers-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahos...
Thanks, looks good. Pushed.
-Ondrej
lnst-developers@lists.fedorahosted.org