Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Thu Apr 5 17:17:40 2012 +0200
SshUtils: Fix hanging slaves when using -e option
This patch fixes problem with haning processes on slave machines,
after remote test execution using the -e option of nettestctl.py.
The problem is, when `ssh' is killed on the client side, the
corresponding remote `sshd' is terminated, but it doesn't signal
bash with SIGHUP if there's no tty allocated. Which (in this case
leaves two processes hanging on the slave machine (/bin/sh and
The solution here is passing -t agrument to `ssh', which results
in forced allocation of pseudo-tty. There's one issue with this
solution: when the remotely executed command finishes, `ssh'
terminates the connection which reults in printing "Connection
closed by remote host" even if everything was ok (return code 0).
So I also had to remove the error check associated with this
message. But I tested this and it still works fine, because
if the connection is closed by error, `ssh' exits with 255,
LNST can recognize that and still report it as an error.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Common/SshUtils.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Common/SshUtils.py b/Common/SshUtils.py
index 109af71..e306976 100644
@@ -142,7 +142,8 @@ def _remote_login(session, username, password, prompt, timeout=10):
msg = "Got username prompt after password prompt"
raise LoginAuthenticationError(msg, text)
elif match == 3: # "Connection closed"
- raise LoginError("Client said 'connection closed'", text)
+ logging.log(logging.INFO, "Remote command execution successful")
elif match == 4: # "Connection refused"
raise LoginError("Client said 'connection refused'", text)
elif match == 5: # "Please wait"
@@ -183,7 +184,7 @@ def remote_login(host, port, username, password, prompt, linesep="\n",
command = ""
command = "-C '%s'" % (command)
- cmd = ("ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o UserKnownHostsFile=/dev/null "
+ cmd = ("ssh -t -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o UserKnownHostsFile=/dev/null "
"-p %s %s@%s %s" % #-o PreferredAuthentications=password
(port, username, host, command))
From: Radek Pazdera <rpazdera(a)redhat.com>
I'm trying to implement a set of automatic tests for multicast
implementation in kernel using LNST. The thing is, there is only
a little documentation for the interface at the moment, so some of
the features that need test coverage are not implemented Python's
socket module. That's why I need C for writing tests.
I figured that this might be useful also in other areas of network
stack testing and added a few new things into LNST. I'm sending it
here for review.
I created a directory called `test_tools'. That should be a place for
storing non-python tools and utilities for testing, that can be used
from LNST tests. I placed there a first set of tools for multicast.
The communication between the C and LNST is achieved through a test
called `TestMulticast'. This test takes arguments from the XML recipe
file and executes the selected test setup from multicast tools. It also
collects and evaluates results when the test ends.
Additionaly, I added a couple of example command sequences to
These should serve as a-sort-of building blocks for creating test
recipes. Then if you'd like to run tests for IGMPv2 for instance you
can only create netconfigs, include several test cases and run it as
one big recipe.
Example of these tests in practice is in the `rpazdera-multicast.xml'
recipe I added to `example_recipes' directory.
Is this solution acceptable for you to include it into LNST?
Radek Pazdera (3):
TestMulticast.py: Adding test for multicast tools
multicast: Adding new folder for test tools
multicast: Adding example recipe
Tests/TestMulticast.py | 129 +++++++++++++
example_recipes/cmd_sequences/multicast/if.xml | 77 ++++++++
example_recipes/cmd_sequences/multicast/loop.xml | 70 +++++++
example_recipes/cmd_sequences/multicast/simple.xml | 33 ++++
example_recipes/cmd_sequences/multicast/ttl.xml | 112 ++++++++++++
example_recipes/rpazdera-multicast.xml | 39 ++++
test_tools/multicast/Makefile | 22 +++
test_tools/multicast/client/send_simple.c | 59 ++++++
test_tools/multicast/multicast_utils.h | 192 ++++++++++++++++++++
test_tools/multicast/offline/sockopt_if.c | 70 +++++++
test_tools/multicast/offline/sockopt_loop.c | 52 ++++++
test_tools/multicast/offline/sockopt_ttl.c | 79 ++++++++
test_tools/multicast/parameters.h | 152 ++++++++++++++++
test_tools/multicast/server/recv_simple.c | 50 +++++
test_tools/multicast/sockopt_utils.h | 176 ++++++++++++++++++
15 files changed, 1312 insertions(+), 0 deletions(-)
create mode 100644 Tests/TestMulticast.py
create mode 100644 example_recipes/cmd_sequences/multicast/if.xml
create mode 100644 example_recipes/cmd_sequences/multicast/loop.xml
create mode 100644 example_recipes/cmd_sequences/multicast/simple.xml
create mode 100644 example_recipes/cmd_sequences/multicast/ttl.xml
create mode 100644 example_recipes/rpazdera-multicast.xml
create mode 100644 test_tools/multicast/Makefile
create mode 100644 test_tools/multicast/client/send_simple.c
create mode 100644 test_tools/multicast/multicast_utils.h
create mode 100644 test_tools/multicast/offline/sockopt_if.c
create mode 100644 test_tools/multicast/offline/sockopt_loop.c
create mode 100644 test_tools/multicast/offline/sockopt_ttl.c
create mode 100644 test_tools/multicast/parameters.h
create mode 100644 test_tools/multicast/server/recv_simple.c
create mode 100644 test_tools/multicast/sockopt_utils.h
I ran into a minor issue, while I was working with LNST. If you execute
nettestctl.py with the -e option that automatically starts the slaves,
they are run from the directory that is default after logging with
ssh (usually user's home dir). This makes it hard to use paths relative
to the install_path in the tests.
I changed the command so nettestslave.py gets executed from the install
directory, where it resides, so relative paths are valid.
Changed the way nettestslave.py is executed so the
cwd is the root of lnst install, not where ssh logs
to by default (which is usually root home dir).
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Common/SlaveUtils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Common/SlaveUtils.py b/Common/SlaveUtils.py
index d8db772..6cb7cc0 100644
@@ -37,6 +37,6 @@ def prepare_client_session(host, port, login,
if prompt is None:
prompt = "Started"
- command = "/%s/%s/%s" % (install_path, test_dir, command)
+ command = "cd /%s/%s/ && ./%s" % (install_path, test_dir, command)
return wait_for_login(host, port, login, passwd, prompt,
\ No newline at end of file