[PATCH 1/2] NetTestSlave: use the Common.Config.DefaultRPCPort constant
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
For some reason the DefaultRPCPort constant was defined in two places.
This commit fixes that and removes the constant definition from the
NetTestSlave module. Instead the constant is imported from the
Common.Config module.
---
lnst/Slave/NetTestSlave.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 729878b..99da97b 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -35,11 +35,10 @@ from lnst.Common.Utils import check_process_running
from lnst.Common.ConnectionHandler import recv_data, send_data
from lnst.Common.ConnectionHandler import ConnectionHandler
from lnst.Common.Config import lnst_config
+from lnst.Common.Config import DefaultRPCPort
from lnst.Common.NetTestCommand import NetTestCommandConfig
from lnst.Slave.InterfaceManager import InterfaceManager
-DefaultRPCPort = 9999
-
class SlaveMethods:
'''
Exported xmlrpc methods
--
1.8.5.3
9 years, 11 months
[lnst] ControllerAPI: adding get_alias method to ControllerAPI
by Jiří Pírko
commit 9c115c7faa6b909f981152bd4334dbfdd1ddc342
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Tue Mar 18 18:38:06 2014 +0100
ControllerAPI: adding get_alias method to ControllerAPI
ControllerAPI now provides get_alias() method to get alias defined in the
recipe XML.
Example:
my_value = ctl.get_alias("my_alias")
The code above gets the value of the alias named "my_alias" previously defined
in <lnstrecipe> namespace, e.g:
<lnstrecipe>
<define>
<alias name="my_alias" value="my_value"/>
</define>
...
</lnstrecipe>
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Task.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index b028231..10c9f02 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -78,6 +78,18 @@ class ControllerAPI(object):
cmd = {"type": "ctl_wait", "seconds": int(seconds)}
return self._ctl._run_command(cmd)
+ def get_alias(self, alias):
+ """
+ Get the value of user defined alias.
+
+ :param alias: name of user defined alias
+ :type alias: string
+
+ :return: value of a user defined alias
+ :rtype: string
+ """
+ return self._ctl._get_alias(alias)
+
class HostAPI(object):
""" An API class representing a host machine. """
10 years
[lnst] NetTestController: adding get_alias method
by Jiří Pírko
commit bc87f63f576c28d831fe675a1b70a9d45475e984
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Tue Mar 18 18:38:05 2014 +0100
NetTestController: adding get_alias method
Adding _get_alias method to the NetTestController.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/NetTestController.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 348c064..40f35b3 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -58,6 +58,7 @@ class NetTestController:
self._recipe_path = recipe_path
self._msg_dispatcher = MessageDispatcher(log_ctl)
self._reduce_sync = reduce_sync
+ self._parser = RecipeParser(recipe_path)
self.remove_saved_machine_config()
@@ -72,10 +73,9 @@ class NetTestController:
mac_pool_range = lnst_config.get_option('environment', 'mac_pool_range')
self._mac_pool = MacPool(mac_pool_range[0], mac_pool_range[1])
- parser = RecipeParser(recipe_path)
- parser.set_machines(self._machines)
- parser.set_aliases(defined_aliases, overriden_aliases)
- self._recipe = parser.parse()
+ self._parser.set_machines(self._machines)
+ self._parser.set_aliases(defined_aliases, overriden_aliases)
+ self._recipe = self._parser.parse()
modules_dirs = lnst_config.get_option('environment', 'module_dirs')
tools_dirs = lnst_config.get_option('environment', 'tool_dirs')
@@ -772,6 +772,10 @@ class NetTestController:
"hash": pkg_hash}
return packages
+ def _get_alias(self, alias):
+ templates = self._parser._template_proc
+ return templates._find_definition(alias)
+
class MessageDispatcher(ConnectionHandler):
def __init__(self, log_ctl):
super(MessageDispatcher, self).__init__()
10 years
[lnst] XmlTemplates: do not drop toplevel aliases so that python task can see them
by Jiří Pírko
commit 104fabe2fa1313dc09a3d9f1417bcb12c6a78086
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Tue Mar 18 18:38:04 2014 +0100
XmlTemplates: do not drop toplevel aliases so that python task can see them
Current implementation uses XmlTemplates to process aliases in the recipe XML
during parsing phase. This works fine for tasks written in XML itself or
xincluded. For the Python tasks this currently does not work since the task
is not being processed for aliases. This patch prevents removal of available
top-level aliases from XmlTemplates processor so that python task can access
them via ControllerAPI during the task execution.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/XmlTemplates.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/XmlTemplates.py b/lnst/Controller/XmlTemplates.py
index 1a65c8b..7572b16 100644
--- a/lnst/Controller/XmlTemplates.py
+++ b/lnst/Controller/XmlTemplates.py
@@ -336,7 +336,10 @@ class XmlTemplates:
for child in element.getchildren():
self.process_aliases(child)
- self.drop_namespace_level()
+ # do not drop alias definitions when at top-level so that python
+ # tasks are able to access them
+ if element.tag != "lnstrecipe":
+ self.drop_namespace_level()
def expand_aliases(self, string):
while True:
10 years
[PATCH 0/3] Introducing get_alias method
by Jan Tluka
Following patch set allows user to use aliases from a python task. This was
not possible before.
Example:
<lnstrecipe>
<define>
<alias name="virtual_ip" value="192.168.111.10/24"/>
</define>
<network>
<host id="m1">
<interfaces>
<eth id="nic1" label="testnet"/>
</interfaces>
</host>
<host id="m2">
<interfaces>
<eth id="nic1" label="testnet"/>
</interfaces>
</host>
</network>
<task python="my_task.py"/>
</lnstrecipe>
And the content of my_task.py:
from lnst.Controller.Task import ctl
virtual_ip = ctl.get_alias("virtual_ip")
m1 = ctl.get_host("m1")
m1.run("ip a add dev %s %s" % (m1.get_devname("nic1"), virtual_ip))
I've run regression check for the patch series without errors.
Jan Tluka (3):
XmlTemplates: do not drop toplevel aliases so that python task can see
them
NetTestController: adding get_alias method
ControllerAPI: adding get_alias method to ControllerAPI
lnst/Controller/NetTestController.py | 12 ++++++++----
lnst/Controller/Task.py | 12 ++++++++++++
lnst/Controller/XmlTemplates.py | 5 ++++-
3 files changed, 24 insertions(+), 5 deletions(-)
--
1.8.1.4
10 years
[lnst] Created tag v3
by Jiří Pírko
The lightweight tag 'v3' was created pointing to:
2afa90b... 3 release
10 years
[lnst] 3 release
by Jiří Pírko
commit 2afa90b821b2876641e791128c5be0a08545c933
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Tue Mar 18 13:18:30 2014 +0100
3 release
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
setup.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/setup.py b/setup.py
index 9421fd4..71905c1 100755
--- a/setup.py
+++ b/setup.py
@@ -163,7 +163,7 @@ DATA_FILES = CONFIG + TEST_MODULES + MULTICAST_TEST_TOOLS + MAN_PAGES + \
SCHEMAS + BASH_COMP
setup(name="lnst",
- version="2",
+ version="3",
description="Linux Network Stack Test",
author="LNST Team",
author_email="lnst-developers(a)lists.fedorahosted.org",
10 years
[lnst] ResultSerializer: update summary formatting
by Jiří Pírko
commit 17c5160c0fca436ef8aff8da971887b08d89628f
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 17 17:26:27 2014 +0100
ResultSerializer: update summary formatting
There are two updates to summary formating in this commit:
* shorten the alignment of command types to -9 from -14 the reason is
* that the longes command type is now 'ctl_wait' instead of
* 'system_config'
* add machine identification to each command in the format:
* 'machine id: cmd_type'
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 8 ++++----
lnst/Common/TestsCommon.py | 2 +-
lnst/Controller/NetTestController.py | 2 +-
lnst/Controller/NetTestResultSerializer.py | 19 ++++++++++++++++---
4 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index abfa71a..47a3e4a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -344,7 +344,7 @@ class NetTestCommandGeneric:
raise CommandException(msg)
def _format_cmd_res_header(self):
- return "%-14s" % self._command["type"]
+ return "%-9s" % self._command["type"]
def set_handle_intr(self):
pass
@@ -383,11 +383,11 @@ class NetTestCommandExec(NetTestCommandGeneric):
cmd_val = self._command["command"]
if "bg_id" in self._command:
- bg_id = " bg_id: %s" % self._command["bg_id"]
+ bg_id = "bg_id: %s " % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s cmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
+ cmd = "%-9s%scmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
return cmd
class NetTestCommandConfig(NetTestCommandGeneric):
@@ -454,7 +454,7 @@ class NetTestCommandControl(NetTestCommandGeneric):
def _format_cmd_res_header(self):
cmd_type = self._command["type"]
cmd_val = self._command["proc_id"]
- cmd = "%-14s id: %s" % (cmd_type, cmd_val)
+ cmd = "%-9sid: %s" % (cmd_type, cmd_val)
return cmd
class NetTestCommandWait(NetTestCommandControl):
diff --git a/lnst/Common/TestsCommon.py b/lnst/Common/TestsCommon.py
index 01ae678..8086121 100644
--- a/lnst/Common/TestsCommon.py
+++ b/lnst/Common/TestsCommon.py
@@ -146,5 +146,5 @@ class TestGeneric(NetTestCommandGeneric):
bg_id = " bg_id: %s" % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s%s" %(cmd_type, cmd_val, bg_id)
+ cmd = "%-9s%s%s" %(cmd_type, cmd_val, bg_id)
return cmd
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index ad5a2df..348c064 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -653,7 +653,7 @@ class NetTestController:
if command["type"] == "ctl_wait":
sleep(command["seconds"])
cmd_res = {"passed": True,
- "res_header": "%-14s%ss" % ("ctl_wait",
+ "res_header": "%-9s%ss" % ("ctl_wait",
command["seconds"]),
"msg": "",
"res_data": None}
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index 9c26dfc..7f2e6d1 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -84,17 +84,30 @@ class NetTestResultSerializer:
seq_num += 1
+ m_id_max = 0
for cmd, cmd_res in task:
- self._format_command(cmd, cmd_res, output_pairs)
+ if "machine" in cmd and\
+ len(cmd["machine"]) > m_id_max:
+ m_id_max = len(cmd["machine"])
+ for cmd, cmd_res in task:
+ self._format_command(cmd, cmd_res, output_pairs, m_id_max)
self._print_pairs(output_pairs)
- def _format_command(self, command, cmd_res, output_pairs):
+ def _format_command(self, command, cmd_res, output_pairs, m_id_max):
if cmd_res["passed"]:
res = "PASS"
else:
res = "FAIL"
- output_pairs.append((8*" " + cmd_res["res_header"], res))
+
+ if "machine" in command:
+ m_id = "host %s: " % command["machine"]
+ m_id += " " * (m_id_max - len(command["machine"]))
+ else:
+ #len("ctl") == 3; len("host ") == 5; 5-3 = 2
+ m_id = "ctl: " + " " * (m_id_max + 2)
+
+ output_pairs.append((8*" " + m_id + cmd_res["res_header"], res))
if "msg" in cmd_res and cmd_res["msg"] != "":
output_pairs.append((12*" " + "message: " + cmd_res["msg"], ""))
10 years
[lnst] setup.py: remove usage of "with" due to older python versions compatibility
by Jiří Pírko
commit 5e93d7d291fe486264026f6033a7cf4d43f6fa31
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Tue Mar 18 12:14:18 2014 +0100
setup.py: remove usage of "with" due to older python versions compatibility
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
setup.py | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/setup.py b/setup.py
index f0a56e6..9421fd4 100755
--- a/setup.py
+++ b/setup.py
@@ -29,15 +29,21 @@ def process_template(template_path, values):
raise Exception("Not a template!")
file_path = re.sub(template_name_re, "", template_path)
- with open(template_path, "r") as t, open(file_path, "w") as f:
- template = t.read()
- for var, value in values.iteritems():
- template = template.replace("@%s@" % var, value)
- f.write(template)
+ t = open(template_path, "r")
+ f = open(file_path, "w")
+ template = t.read()
+ for var, value in values.iteritems():
+ template = template.replace("@%s@" % var, value)
+ f.write(template)
+ f.close()
+ t.close()
def gzip_file(path):
- with open(path, "rb") as src, gzip.open(path + ".gz", "wb") as dst:
- dst.writelines(src)
+ src = open(path, "rb")
+ dst = gzip.open(path + ".gz", "wb")
+ dst.writelines(src)
+ dst.close()
+ src.close()
# Various paths
CONF_DIR = "/etc/"
10 years
[PATCH] ResultSerializer: update summary formatting
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
There are two updates to summary formating in this commit:
* shorten the alignment of command types to -9 from -14 the reason is
* that the longes command type is now 'ctl_wait' instead of
* 'system_config'
* add machine identification to each command in the format:
* 'machine id: cmd_type'
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 8 ++++----
lnst/Common/TestsCommon.py | 2 +-
lnst/Controller/NetTestController.py | 2 +-
lnst/Controller/NetTestResultSerializer.py | 20 +++++++++++++++++---
4 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index abfa71a..47a3e4a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -344,7 +344,7 @@ class NetTestCommandGeneric:
raise CommandException(msg)
def _format_cmd_res_header(self):
- return "%-14s" % self._command["type"]
+ return "%-9s" % self._command["type"]
def set_handle_intr(self):
pass
@@ -383,11 +383,11 @@ class NetTestCommandExec(NetTestCommandGeneric):
cmd_val = self._command["command"]
if "bg_id" in self._command:
- bg_id = " bg_id: %s" % self._command["bg_id"]
+ bg_id = "bg_id: %s " % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s cmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
+ cmd = "%-9s%scmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
return cmd
class NetTestCommandConfig(NetTestCommandGeneric):
@@ -454,7 +454,7 @@ class NetTestCommandControl(NetTestCommandGeneric):
def _format_cmd_res_header(self):
cmd_type = self._command["type"]
cmd_val = self._command["proc_id"]
- cmd = "%-14s id: %s" % (cmd_type, cmd_val)
+ cmd = "%-9sid: %s" % (cmd_type, cmd_val)
return cmd
class NetTestCommandWait(NetTestCommandControl):
diff --git a/lnst/Common/TestsCommon.py b/lnst/Common/TestsCommon.py
index 01ae678..8086121 100644
--- a/lnst/Common/TestsCommon.py
+++ b/lnst/Common/TestsCommon.py
@@ -146,5 +146,5 @@ class TestGeneric(NetTestCommandGeneric):
bg_id = " bg_id: %s" % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s%s" %(cmd_type, cmd_val, bg_id)
+ cmd = "%-9s%s%s" %(cmd_type, cmd_val, bg_id)
return cmd
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index ad5a2df..348c064 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -653,7 +653,7 @@ class NetTestController:
if command["type"] == "ctl_wait":
sleep(command["seconds"])
cmd_res = {"passed": True,
- "res_header": "%-14s%ss" % ("ctl_wait",
+ "res_header": "%-9s%ss" % ("ctl_wait",
command["seconds"]),
"msg": "",
"res_data": None}
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index 9c26dfc..56bd490 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -84,17 +84,31 @@ class NetTestResultSerializer:
seq_num += 1
+ #len("ctl") == 3 -> for the ctl_wait command
+ m_id_max = 3
for cmd, cmd_res in task:
- self._format_command(cmd, cmd_res, output_pairs)
+ if "machine" in cmd and\
+ len(cmd["machine"]) > m_id_max:
+ m_id_max = len(cmd["machine"])
+ for cmd, cmd_res in task:
+ self._format_command(cmd, cmd_res, output_pairs, m_id_max)
self._print_pairs(output_pairs)
- def _format_command(self, command, cmd_res, output_pairs):
+ def _format_command(self, command, cmd_res, output_pairs, m_id_max):
if cmd_res["passed"]:
res = "PASS"
else:
res = "FAIL"
- output_pairs.append((8*" " + cmd_res["res_header"], res))
+
+ if "machine" in command:
+ m_id = "machine %s: " % command["machine"]
+ m_id += " " * (m_id_max - len(command["machine"]))
+ else:
+ #len("ctl") == 3
+ m_id = "machine ctl: " + " " * (m_id_max - 3)
+
+ output_pairs.append((8*" " + m_id + cmd_res["res_header"], res))
if "msg" in cmd_res and cmd_res["msg"] != "":
output_pairs.append((12*" " + "message: " + cmd_res["msg"], ""))
--
1.8.5.3
10 years