[RFC] Command Sequence Changes
by Radek Pazdera
Hello Everyone,
I'm working on changing the command sequence right now so it works better
with the new parser design and I have several ideas I'd like to
share/discuss here.
Change <command_sequence> to <task>
===================================
The first one is to rename the <command_sequence> tag to <task>. I
wanted to add more semantics to the very general command sequence tag
with the test fixtures proposal. However, after a deeper discussion,
we agreed that it might be too limiting and even confusing in some cases.
Task, on the other hand is not limiting at all. It can be used the same
way command sequences are at the moment, but the name is less abstract
and it suggests that each "task" should do only one thing.
There could be several types of tasks with different properties. For
example:
<task type="setup">
this type of task would have quit_on_fail=1
<task type="test">
quit_on_fail=0
<task type="teardown">
quit_on_fail=1, but finish the whole task before exiting
(we want to do as much cleanup as possible)
The default behaviour would be "test". This means we would get basically
all the benefits from test fixtures without losing the variability of
command sequences. It also works very well if you try to explain what
LNST actually does (you need to specify what infrastructure you need for
the test and the tasks you'd like to run).
Change type="exec" && type="test" to <run>
==========================================
The other change I'd like to do is to move all the three tags that we
use to run some commands/test_modules/test_tools under a single tag
called <run>. It would look something like this:
Shell commands (former type="exec"):
<run command="sleep 5" machine="1">
Test tools (former type="exec" from="tool"):
<run from="tool" command="./mighty_tool" machine="1">
Test modules (former type="test"):
<run module="IcmpPing" machine="1">
<options/>
</run>
This would be nice, in my opinion, because there would be only a single
way to run something from the recipe.
Slight modification of intr, kill, wait, and ctl_wait
=====================================================
These are all right in my opinion, I only changed the attribute from
'value' to something else:
<intr machine="1" id="5">
<kill machine="1" id="5">
<wait machine="1" id="5">
value was changed to id
<ctl_wait seconds="5">
value changed to seconds
Change type="system_config" to <config>
==================================
We used system_config to differentiate from the other configs that vere
present in the past in the LNST recipe. However, they are all gone now,
so we could shorten the system config to simply config:
<config option="/proc/sys/lol" value="10">
With these changes the <command_sequence>s/<tasks> are really a sequences
of commands, because each tag name is a verb that represents the action
that will be done:
config, run, run, ctl_wait, wait, intr, kill ...
Scopes for processes and configuration
======================================
Additionally, what we'll have to change is the limitation of lifetime of
a process to only a single task. We already have something similar with
system_config settings using the "persistent" attribute.
We could unify both things and define "scopes" for both the <config> and
the <run> tag. The default value would be "local", but in case the
setting/process should last longer than the command sequence, the user
could set the scope to "global". For instance:
<task type="setup">
<config option="name" value="5" scope="global">
<run command="tcpdump -i eth0" bg_id="tcpdump" scope="global">
</task>
<task type="test"/>
<task type="test"/>
<task type="teardown">
<config option="name" value="0" scope="global">
<kill id="tcpdump">
</task>
Another alternative to this could be:
lifetime="local"
lifetime="unlimited"
What do you think?
Any feedback is greatly appreciated :-).
Cheers,
-Radek
10 years, 8 months
[lnst] NmConfigDevice: remove gi.repository import
by Jiří Pírko
commit 0407e084777f522974b381815e040daefef76018
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Jul 18 10:19:28 2013 +0200
NmConfigDevice: remove gi.repository import
The gi package is not available by default on RHEL 6 machines which
results in lnst crashing with an exception.
This commit removes the related import and instead I define the needed
constants. Its only three values, each used only once so it shouldn't be
a big problem.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NmConfigDevice.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 8c76f73..88c2817 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -18,7 +18,6 @@ import dbus
import uuid
import socket, struct
import time
-from gi.repository import NetworkManager, GObject
from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
@@ -27,6 +26,11 @@ NM_BUS = "org.freedesktop.NetworkManager"
OBJ_PRE = "/org/freedesktop/NetworkManager"
IF_PRE = NM_BUS
+#NetworkManager constants for state values
+_ACON_ACTIVATED = 2
+_DEV_UNAVAILABLE = 20
+_DEV_DISCONNECTED = 30
+
class NmConfigDeviceGeneric(object):
'''
Generic class for device manipulation all type classes should
@@ -185,7 +189,7 @@ class NmConfigDeviceGeneric(object):
act_con_props = dbus.Interface(act_con,
"org.freedesktop.DBus.Properties")
self._poll_loop(act_con_props.Get,
- NetworkManager.ActiveConnectionState.ACTIVATED,
+ _ACON_ACTIVATED,
IF_PRE + ".Connection.Active", "State")
def _nm_deactivate_connection(self, netdev):
@@ -212,13 +216,13 @@ class NmConfigDeviceEth(NmConfigDeviceGeneric):
dev_props = dbus.Interface(dev, "org.freedesktop.DBus.Properties")
state = dev_props.Get(IF_PRE + ".Device", "State")
- if state == NetworkManager.DeviceState.UNAVAILABLE:
+ if state == _DEV_UNAVAILABLE:
logging.info("Resetting interface so NM manages it.")
exec_cmd("ip link set %s down" % netdev["name"])
exec_cmd("ip link set %s up" % netdev["name"])
self._poll_loop(dev_props.Get,
- NetworkManager.DeviceState.DISCONNECTED,
+ _DEV_DISCONNECTED,
IF_PRE + ".Device", "State")
super(NmConfigDeviceEth, self).up()
10 years, 8 months
[PATCH] NmConfigDevice: remove gi.repository import
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The gi package is not available by default on RHEL 6 machines which
results in lnst crashing with an exception.
This commit removes the related import and instead I define the needed
constants. Its only three values, each used only once so it shouldn't be
a big problem.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 8c76f73..88c2817 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -18,7 +18,6 @@ import dbus
import uuid
import socket, struct
import time
-from gi.repository import NetworkManager, GObject
from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
@@ -27,6 +26,11 @@ NM_BUS = "org.freedesktop.NetworkManager"
OBJ_PRE = "/org/freedesktop/NetworkManager"
IF_PRE = NM_BUS
+#NetworkManager constants for state values
+_ACON_ACTIVATED = 2
+_DEV_UNAVAILABLE = 20
+_DEV_DISCONNECTED = 30
+
class NmConfigDeviceGeneric(object):
'''
Generic class for device manipulation all type classes should
@@ -185,7 +189,7 @@ class NmConfigDeviceGeneric(object):
act_con_props = dbus.Interface(act_con,
"org.freedesktop.DBus.Properties")
self._poll_loop(act_con_props.Get,
- NetworkManager.ActiveConnectionState.ACTIVATED,
+ _ACON_ACTIVATED,
IF_PRE + ".Connection.Active", "State")
def _nm_deactivate_connection(self, netdev):
@@ -212,13 +216,13 @@ class NmConfigDeviceEth(NmConfigDeviceGeneric):
dev_props = dbus.Interface(dev, "org.freedesktop.DBus.Properties")
state = dev_props.Get(IF_PRE + ".Device", "State")
- if state == NetworkManager.DeviceState.UNAVAILABLE:
+ if state == _DEV_UNAVAILABLE:
logging.info("Resetting interface so NM manages it.")
exec_cmd("ip link set %s down" % netdev["name"])
exec_cmd("ip link set %s up" % netdev["name"])
self._poll_loop(dev_props.Get,
- NetworkManager.DeviceState.DISCONNECTED,
+ _DEV_DISCONNECTED,
IF_PRE + ".Device", "State")
super(NmConfigDeviceEth, self).up()
--
1.8.1.4
10 years, 8 months
[PATCH 1/2] NetTestSlave: add kill_command method
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The new method will kill the command with a specified id. The id is
either the bg_id of the command or None for foreground
commands, which makes the id a unique identifier. This method will be
used to forcefully kill a running command that has timed out.
This commit also modifies the message logged when killing a command.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 5 ++++-
lnst/Slave/NetTestSlave.py | 6 ++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 8dc9562..1c34c70 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -147,7 +147,10 @@ class NetTestCommand:
def kill(self):
if os.path.exists("/proc/%d" % self._pid):
- logging.debug("Killing background command with id \"%s\", pid \"%d\"" % (self._id, 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()
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 7f20b08..77ad679 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -233,6 +233,12 @@ class SlaveMethods:
return res
+ def kill_command(self, id):
+ cmd = self._command_context.get_cmd(id)
+ cmd.kill()
+ self._command_context.del_cmd(cmd)
+ return True
+
def machine_cleanup(self):
NetConfigDeviceAllCleanup(self._config)
self._netconfig.cleanup()
--
1.8.1.4
10 years, 8 months
[lnst] Machine: handle timeout exception
by Jiří Pírko
commit 98d43fde2764126910c23ac7cb7fe4c14e15c4a4
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Jul 17 14:09:45 2013 +0200
Machine: handle timeout exception
Previously when a command timed out, the exception was handled too late
resulting in a message "Recieved an unknown exception...".
This commit adds handling of this exception. The timed out command is
then killed so that it doesn't leave a process running.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index d4348e2..1847adf 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -174,7 +174,14 @@ class Machine(object):
logging.debug("Setting timeout to \"%d\"", timeout)
signal.alarm(timeout)
- cmd_res = self._rpc_call("run_command", command)
+ try:
+ cmd_res = self._rpc_call("run_command", command)
+ except MachineError as exc:
+ if "bg_id" in command:
+ self._rpc_call("kill_command", command["bg_id"])
+ else:
+ self._rpc_call("kill_command", None)
+ cmd_res = {"passed": False, "err_msg": str(exc)}
signal.alarm(0)
signal.signal(signal.SIGALRM, prev_handler)
10 years, 8 months
[PATCH] NmConfigDeviceBridge: disable stp
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
NM enables STP on bridge interfaces by default, this results in the
bridge being unusable for about 30 seconds. This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index b80a551..8c76f73 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -392,7 +392,8 @@ class NmConfigDeviceBridge(NmConfigDeviceGeneric):
'id': netdev["name"]+"_con"})
s_bridge = dbus.Dictionary({
- 'interface-name': netdev["name"]})
+ 'interface-name': netdev["name"],
+ 'stp': dbus.Boolean(False)})
s_ipv4, s_ipv6 = self._nm_make_ip_settings(netdev["addresses"])
--
1.8.1.4
10 years, 8 months
[lnst] NetTestSlave: add kill_command method
by Jiří Pírko
commit f7daa79818bfdae1bd664cee1877b18c8dea8ec8
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Jul 17 14:09:44 2013 +0200
NetTestSlave: add kill_command method
The new method will kill the command with a specified id. The id is
either the bg_id of the command or None for foreground
commands, which makes the id a unique identifier. This method will be
used to forcefully kill a running command that has timed out.
This commit also modifies the message logged when killing a command.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 5 ++++-
lnst/Slave/NetTestSlave.py | 6 ++++++
2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 8dc9562..1c34c70 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -147,7 +147,10 @@ class NetTestCommand:
def kill(self):
if os.path.exists("/proc/%d" % self._pid):
- logging.debug("Killing background command with id \"%s\", pid \"%d\"" % (self._id, 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()
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 7f20b08..77ad679 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -233,6 +233,12 @@ class SlaveMethods:
return res
+ def kill_command(self, id):
+ cmd = self._command_context.get_cmd(id)
+ cmd.kill()
+ self._command_context.del_cmd(cmd)
+ return True
+
def machine_cleanup(self):
NetConfigDeviceAllCleanup(self._config)
self._netconfig.cleanup()
10 years, 8 months
[lnst] NmConfigDeviceBridge: disable stp
by Jiří Pírko
commit 4a93138b52cbcad996207afec09677f514eca773
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Jul 17 14:09:27 2013 +0200
NmConfigDeviceBridge: disable stp
NM enables STP on bridge interfaces by default, this results in the
bridge being unusable for about 30 seconds. This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NmConfigDevice.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index b80a551..8c76f73 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -392,7 +392,8 @@ class NmConfigDeviceBridge(NmConfigDeviceGeneric):
'id': netdev["name"]+"_con"})
s_bridge = dbus.Dictionary({
- 'interface-name': netdev["name"]})
+ 'interface-name': netdev["name"],
+ 'stp': dbus.Boolean(False)})
s_ipv4, s_ipv6 = self._nm_make_ip_settings(netdev["addresses"])
10 years, 8 months
[PATCH] setup.py: Fixing manpages bug
by Radek Pazdera
As it turns out, the setup script has been packaging the man pages
incorrectly (they were not gziped) the whole time.
This patch fixes that issue.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
setup.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/setup.py b/setup.py
index babfbcf..9fc6ebe 100755
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,7 @@ def process_template(template_path, values):
f.write(template)
def gzip_file(path):
- with open(path, "rb") as src, open(path + ".gz", "wb") as dst:
+ with open(path, "rb") as src, gzip.open(path + ".gz", "wb") as dst:
dst.writelines(src)
# Various paths
--
1.7.7.6
10 years, 8 months