commit 8455e3fdd307f29b9029dee66bb927913373bbfb
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Tue Dec 10 17:33:51 2013 +0100
Introducing TCPConnection test module
This is a python wrapper for tcp_conn test tool.
Example of use:
<run module="TCPConnection" host="2"
bg_id="server">
<options>
<option name="mode" value="server"/>
<option name="address"
value="{ip(2,testiface)}"/>
<option name="portrange" value="10000-10050"/>
<option name="continuous" value="yes"/>
</options>
</run>
<ctl_wait seconds="3"/>
<run module="TCPConnection" host="1"
bg_id="client">
<options>
<option name="mode" value="client"/>
<option name="address"
value="{ip(2,testiface)}"/>
<option name="portrange" value="10000-10050"/>
<option name="continuous" value="yes"/>
</options>
</run>
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
test_modules/TCPConnection.py | 60 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/test_modules/TCPConnection.py b/test_modules/TCPConnection.py
new file mode 100644
index 0000000..43b88a9
--- /dev/null
+++ b/test_modules/TCPConnection.py
@@ -0,0 +1,60 @@
+"""
+This module defines TCPConnection test,
+a python wrapper for LNST's tcp_conn test tool
+"""
+
+__author__ = """
+jtluka(a)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)})
Show replies by date