[PATCH] NetTestController: Write traceback to debug on error
by Radek Pazdera
When the recipe execution fails with an exception in NetTestController,
the exception is always caught and rethrown after propper cleanup has
been done.
This unfortunatelly leads to loosing the original exception traceback
which is very helpful for debugging.
The original traceback is now logged into debug when exception is
caught and then rethrown.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
Common/Logs.py | 6 ++++++
NetTest/NetTestController.py | 4 +++-
NetTest/NetTestSlave.py | 7 ++-----
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Common/Logs.py b/Common/Logs.py
index ac0d5d3..0772f1f 100644
--- a/Common/Logs.py
+++ b/Common/Logs.py
@@ -12,9 +12,15 @@ jzupka(a)redhat.com (Jiri Zupka)
import os, sys, shutil, datetime
from logging import Formatter
import logging.handlers
+import traceback
LOCAL_IP = "(127.0.0.1)"
+def log_exc_traceback():
+ cmd_type, value, tb = sys.exc_info()
+ exception = traceback.format_exception(cmd_type, value, tb)
+ logging.debug(''.join(exception))
+
class FindRootPathError(Exception):
def __init__(self, path, rootFolder):
Exception.__init__(self, path, rootFolder)
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index c5a218c..41707c5 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -14,7 +14,7 @@ jpirko(a)redhat.com (Jiri Pirko)
import logging
import socket
import os
-from Common.Logs import Logs
+from Common.Logs import Logs, log_exc_traceback
from Common.SshUtils import scp_from_remote
from pprint import pprint, pformat
from Common.XmlRpc import ServerProxy
@@ -295,6 +295,7 @@ class NetTestController:
try:
self._ntparse.parse_recipe()
except Exception, exc:
+ log_exc_traceback()
logging.debug("Exception raised during recipe parsing. "\
"Deconfiguring machines.")
self._deconfigure_slaves()
@@ -377,6 +378,7 @@ class NetTestController:
try:
res = self._run_recipe()
except Exception, exc:
+ log_exc_traceback()
err = exc
if packet_capture:
diff --git a/NetTest/NetTestSlave.py b/NetTest/NetTestSlave.py
index a7722e4..8065591 100644
--- a/NetTest/NetTestSlave.py
+++ b/NetTest/NetTestSlave.py
@@ -11,7 +11,7 @@ __author__ = """
jpirko(a)redhat.com (Jiri Pirko)
"""
-from Common.Logs import Logs
+from Common.Logs import Logs, log_exc_traceback
import signal
import select, logging
import os
@@ -114,10 +114,7 @@ class NetTestSlaveXMLRPC:
try:
return NetTestCommand(command).run()
except:
- import sys, traceback
- cmd_type, value, tb = sys.exc_info()
- exception = traceback.format_exception(cmd_type, value, tb)
- logging.error(''.join(exception))
+ log_exc_traceback()
raise CommandException(command)
def machine_cleanup(self):
--
1.7.7.6
11 years, 3 months
[lnst] XmlTemplates: fix for ip function parameter
by Jiří Pírko
commit 47b8946ea1eab3c08134d0f152175fb66e775468
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Aug 23 10:44:45 2012 +0200
XmlTemplates: fix for ip function parameter
When the third parameter of template function ip was negative it would
produce an IndexError exception instead of XmlTemplateError.
This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/XmlTemplates.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py
index 6afcc05..9a62481 100644
--- a/Common/XmlTemplates.py
+++ b/Common/XmlTemplates.py
@@ -234,7 +234,7 @@ class XmlTemplates:
msg = "Second parameter of function ip() is invalid: "\
"Interface %s does not exist." % if_id
raise XmlTemplateError(msg)
- if ip_id >= len(machine['netconfig'][if_id]['addresses']):
+ if ip_id >= len(machine['netconfig'][if_id]['addresses']) or ip_id < 0:
msg = "Third parameter of function ip() is invalid: "\
"Address %s does not exist." % ip_id
raise XmlTemplateError(msg)
11 years, 3 months
[lnst] recipes: team: use general netconfig unrelated to actual host
by Jiří Pírko
commit 2ac96ab7f547c78e952f2f682897e4cb4259d80f
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Thu Aug 23 10:06:03 2012 +0200
recipes: team: use general netconfig unrelated to actual host
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
...fig-test1_002.xml => netconfig-team_ab_001.xml} | 2 +-
...tconfig-test1_001.xml => netconfig-team_rr.xml} | 2 +-
recipes/team/netconfig-test2_001.xml | 20 ----------
recipes/team/netconfig-test2_002.xml | 38 --------------------
recipes/team/recipe_001.xml | 10 ++++-
recipes/team/recipe_002.xml | 10 ++++-
6 files changed, 18 insertions(+), 64 deletions(-)
---
diff --git a/recipes/team/netconfig-test1_002.xml b/recipes/team/netconfig-team_ab_001.xml
similarity index 95%
rename from recipes/team/netconfig-test1_002.xml
rename to recipes/team/netconfig-team_ab_001.xml
index 3dbf67d..d3ed392 100644
--- a/recipes/team/netconfig-test1_002.xml
+++ b/recipes/team/netconfig-team_ab_001.xml
@@ -32,7 +32,7 @@
<slave id="2"/>
</slaves>
<addresses>
- <address value="192.168.111.1/24"/>
+ <address value="{$testip}"/>
</addresses>
</interface>
</netconfig>
diff --git a/recipes/team/netconfig-test1_001.xml b/recipes/team/netconfig-team_rr.xml
similarity index 90%
rename from recipes/team/netconfig-test1_001.xml
rename to recipes/team/netconfig-team_rr.xml
index 6d12db0..4dd0a9f 100644
--- a/recipes/team/netconfig-test1_001.xml
+++ b/recipes/team/netconfig-team_rr.xml
@@ -14,7 +14,7 @@
<slave id="2"/>
</slaves>
<addresses>
- <address value="192.168.111.1/24"/>
+ <address value="{$testip}"/>
</addresses>
</interface>
</netconfig>
diff --git a/recipes/team/recipe_001.xml b/recipes/team/recipe_001.xml
index 50276e3..ef2f9e7 100644
--- a/recipes/team/recipe_001.xml
+++ b/recipes/team/recipe_001.xml
@@ -1,12 +1,18 @@
<nettestrecipe>
<machines>
+ <define>
+ <alias name="testip" value="192.168.111.1/24"/>
+ </define>
<machine id="1">
<netmachineconfig source="netmachineconfig-test1.xml"/>
- <netconfig source="netconfig-test1_001.xml"/>
+ <netconfig source="netconfig-team_rr.xml"/>
</machine>
+ <define>
+ <alias name="testip" value="192.168.111.2/24"/>
+ </define>
<machine id="2">
<netmachineconfig source="netmachineconfig-test2.xml"/>
- <netconfig source="netconfig-test2_001.xml"/>
+ <netconfig source="netconfig-team_rr.xml"/>
</machine>
</machines>
<command_sequence source="sequence_ping_simple.xml"/>
diff --git a/recipes/team/recipe_002.xml b/recipes/team/recipe_002.xml
index ebb250d..232df3b 100644
--- a/recipes/team/recipe_002.xml
+++ b/recipes/team/recipe_002.xml
@@ -1,12 +1,18 @@
<nettestrecipe>
<machines>
+ <define>
+ <alias name="testip" value="192.168.111.1/24"/>
+ </define>
<machine id="1">
<netmachineconfig source="netmachineconfig-test1.xml"/>
- <netconfig source="netconfig-test1_002.xml"/>
+ <netconfig source="netconfig-team_ab_001.xml"/>
</machine>
+ <define>
+ <alias name="testip" value="192.168.111.2/24"/>
+ </define>
<machine id="2">
<netmachineconfig source="netmachineconfig-test2.xml"/>
- <netconfig source="netconfig-test2_002.xml"/>
+ <netconfig source="netconfig-team_ab_001.xml"/>
</machine>
</machines>
<command_sequence source="sequence_ping_simple.xml"/>
11 years, 3 months
[PATCH] NetConfigDevice: set team slaves up
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
In case team slaves were specified both in teamd_config and using
<slave> tags, their state was not correctly set to UP.
This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
NetConfig/NetConfigDevice.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/NetConfig/NetConfigDevice.py b/NetConfig/NetConfigDevice.py
index 24799b5..2dd8d1a 100644
--- a/NetConfig/NetConfigDevice.py
+++ b/NetConfig/NetConfigDevice.py
@@ -234,6 +234,11 @@ class NetConfigDeviceTeam(NetConfigDeviceGeneric):
port_netdev = self._config[slave_id]
NetConfigDevice(port_netdev, self._config).down()
+ def _ports_up(self):
+ for slave_id in get_slaves(self._netdev):
+ port_netdev = self._config[slave_id]
+ NetConfigDevice(port_netdev, self._config).up()
+
def configure(self):
self._ports_down()
@@ -250,6 +255,7 @@ class NetConfigDeviceTeam(NetConfigDeviceGeneric):
for slave_id in get_slaves(self._netdev):
self.slave_add(slave_id)
+ self._ports_up()
def deconfigure(self):
for slave_id in get_slaves(self._netdev):
--
1.7.11.4
11 years, 3 months
[lnst trac] #11: Race in NetTestController.__prepare_device()
by fedora-badges
#11: Race in NetTestController.__prepare_device()
------------------------+-----------------------
Reporter: rpazdera | Owner: rpazdera
Type: defect | Status: new
Priority: critical | Milestone:
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
------------------------+-----------------------
There's a race in this method of NetTestController class. Sometimes
multiple devices with a same MAC address can be accepted by LNST.
It can happen if you try to create a device with MAC that already exist on
the target domain. If the interface addition is somehow delayed (because
of scheduling for instance), the wait_for() function will pass correctly.
It will find the already existing device, while the freshly created
doesn't exist yet.
The correct behavior would be to recognize this and fail because of a
hwaddr collision between two interfaces.
I will look at this and send a patch asap.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/11>
lnst <http://example.org/>
My example project
11 years, 3 months
[PATCH] XmlTemplates: fix for ip function parameter
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
When the third parameter of template function ip was negative it would
produce an IndexError exception instead of XmlTemplateError.
This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
Common/XmlTemplates.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py
index 6afcc05..9a62481 100644
--- a/Common/XmlTemplates.py
+++ b/Common/XmlTemplates.py
@@ -234,7 +234,7 @@ class XmlTemplates:
msg = "Second parameter of function ip() is invalid: "\
"Interface %s does not exist." % if_id
raise XmlTemplateError(msg)
- if ip_id >= len(machine['netconfig'][if_id]['addresses']):
+ if ip_id >= len(machine['netconfig'][if_id]['addresses']) or ip_id < 0:
msg = "Third parameter of function ip() is invalid: "\
"Address %s does not exist." % ip_id
raise XmlTemplateError(msg)
--
1.7.11.4
11 years, 3 months
[lnst] nettestctl: kill -r cmd line parameter
by Jiří Pírko
commit 83e13d54c416f3907a6aed85ce2120f4a3662314
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Thu Aug 23 09:24:21 2012 +0200
nettestctl: kill -r cmd line parameter
Since recipe xml is always required, remove it being an option and
rather push it to the end of command line right before action.
This also allows to specify multiple recipes to be executed at once with
possibility of using shell expansion.
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
nettestctl.py | 54 ++++++++++++++++++++++++++----------------------------
1 files changed, 26 insertions(+), 28 deletions(-)
---
diff --git a/nettestctl.py b/nettestctl.py
index 617202a..de07911 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -27,16 +27,16 @@ def usage():
Print usage of this app
"""
print "Usage:"
- print "nettestctl.py [OPTION...] ACTION"
+ print "nettestctl.py [OPTION...] [RECIPE...] ACTION"
print ""
print "ACTION = [run | dump | config_only]"
print ""
+ print "options:"
print " -d, --debug emit debugging messages"
print " -p, --packet_capture capture and log all ongoing\n" \
" network communication during\n" \
" the test"
print " -h, --help print this message"
- print " -r, --recipe=FILE use this net test recipe"
print " -e, --remoteexec transfer and execute\n" \
" application on slaves"
print " -c, --cleanup perform config cleanup\n" \
@@ -44,12 +44,11 @@ def usage():
print " -x, --result=FILE file to write xml_result"
sys.exit()
-def process_recipe(args, file_path, remoteexec, cleanup,
+def process_recipe(action, file_path, remoteexec, cleanup,
res_serializer, packet_capture):
nettestctl = NetTestController(os.path.realpath(file_path),
remoteexec=remoteexec, cleanup=cleanup,
res_serializer=res_serializer)
- action = args[0]
if action == "run":
return nettestctl.run_recipe(packet_capture)
elif action == "dump":
@@ -109,8 +108,6 @@ def main():
debug += 1
elif opt in ("-h", "--help"):
usage()
- elif opt in ("-r", "--recipe"):
- recipe_path = arg
elif opt in ("-e", "--remoteexec"):
remoteexec = True
elif opt in ("-c", "--cleanup"):
@@ -127,32 +124,33 @@ def main():
logging.error("No action command passed")
usage();
- if not recipe_path:
- logging.error("No recipe xml file passed")
- usage();
+ action = args.pop()
summary = []
res_serializer = NetTestResultSerializer()
- if os.path.isdir(recipe_path):
- all_files = []
- for root, dirs, files in os.walk(recipe_path):
- dirs[:] = [] # do not walk subdirs
- all_files += files
-
- all_files.sort()
- for f in all_files:
- recipe_file = os.path.join(recipe_path, f)
- if re.match(r'^.*\.xml$', recipe_file):
- logging.info("Processing recipe file \"%s\"" % recipe_file)
- summary.append(get_recipe_result(args, recipe_file, remoteexec,
- cleanup, res_serializer,
- packet_capture))
- Logs.set_logging_root_path(clean=False)
- else:
- summary.append(get_recipe_result(args, recipe_path, remoteexec,
- cleanup, res_serializer,
- packet_capture))
+ for recipe_path in args:
+ if os.path.isdir(recipe_path):
+ all_files = []
+ for root, dirs, files in os.walk(recipe_path):
+ dirs[:] = [] # do not walk subdirs
+ all_files += files
+
+ all_files.sort()
+ for f in all_files:
+ recipe_file = os.path.join(recipe_path, f)
+ if re.match(r'^.*\.xml$', recipe_file):
+ logging.info("Processing recipe file \"%s\"" % recipe_file)
+ summary.append(get_recipe_result(action, recipe_file,
+ remoteexec, cleanup,
+ res_serializer,
+ packet_capture))
+ Logs.set_logging_root_path(clean=False)
+ else:
+ summary.append(get_recipe_result(action, recipe_path, remoteexec,
+ cleanup, res_serializer,
+ packet_capture))
+
Logs.set_logging_root_path(clean=False)
print_summary(summary)
11 years, 3 months
[lnst] #4: Change machine_id, phys_id, netdev_id from int to str
by fedora-badges
#4: Change machine_id, phys_id, netdev_id from int to str
-------------------------+-------------------------
Reporter: rpazdera | Owner: rpazdera@…
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
-------------------------+-------------------------
It would be nice to be able to have a possibility of giving symbolic names
to either machines, physical devices or configured interfaces.
Currently only integer values are accepted as machine_id, netdev_phys_id
and interface_id.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/4>
lnst <http://example.org/>
My example project
11 years, 3 months
[lnst] recipes: team: fix to work with string keys
by Jiří Pírko
commit a64f7e5a67338eaa4fd4a3c734caeb0483350576
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Thu Aug 23 09:00:04 2012 +0200
recipes: team: fix to work with string keys
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
recipes/team/sequence_ping_simple.xml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/recipes/team/sequence_ping_simple.xml b/recipes/team/sequence_ping_simple.xml
index d4d2adf..41d053c 100644
--- a/recipes/team/sequence_ping_simple.xml
+++ b/recipes/team/sequence_ping_simple.xml
@@ -2,7 +2,7 @@
<command type="exec" value="sleep 4"/>
<command machine_id="1" timeout="30" type="test" value="IcmpPing">
<options>
- <option name="addr" value="{$recipe['machines'][2]['netconfig'][3]['addresses'][0]}"/>
+ <option name="addr" value="{$recipe['machines']['2']['netconfig']['3']['addresses'][0]}"/>
<option name="count" value="40"/>
<option name="interval" value="0.2"/>
<option name="limit_rate" value="95"/>
11 years, 3 months
[PATCH 0/4] Ticket #4
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The following is a set of patches resolving ticket #4.
machine_id, phys_id, interface_id and background_id can now have string
values. This can be used to make recipes more readable.
As far as I know these changes should have no impact on existing recipes
but if you encounter any problems please contact me.
Ondrej Lichtner (4):
Ticket #4: machine_id from int to string
Ticket #4: phys_id from int to string
Ticket #4: interface_id from int to string
Ticket #4: bg_id from int to string
Common/XmlTemplates.py | 14 +++++++-------
NetConfig/NetConfigDevNames.py | 2 +-
NetTest/NetTestCommand.py | 18 +++++++++---------
NetTest/NetTestController.py | 18 +++++++++---------
NetTest/NetTestParse.py | 30 +++++++++++++++---------------
netconfig.py | 2 +-
6 files changed, 42 insertions(+), 42 deletions(-)
--
1.7.11.4
11 years, 3 months