summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qethernet.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test/tests/qethernet.py')
-rw-r--r--test-cli/test/tests/qethernet.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/test-cli/test/tests/qethernet.py b/test-cli/test/tests/qethernet.py
index be984f5..22d796c 100644
--- a/test-cli/test/tests/qethernet.py
+++ b/test-cli/test/tests/qethernet.py
@@ -1,12 +1,14 @@
import unittest
import sh
-import ex
+import re
+
class Qethernet(unittest.TestCase):
__sip = None
__numbytestx = None
__bind = None
__OKBW = None
+ __port = None
def __init__(self, testname, testfunc, varlist):
super(Qethernet, self).__init__(testfunc)
@@ -22,16 +24,21 @@ class Qethernet(unittest.TestCase):
self.__OKBW = varlist["OKBW"]
else:
raise Exception('OKBW param inside Qethernet must be defined')
+ if "port" in varlist:
+ self.__port = varlist["port"]
+ else:
+ raise Exception('port param inside Qethernet must be defined')
self.__numbytestx = "10M"
self._testMethodDoc = testname
def execute(self):
# execute iperf command against the server
if self.__bind is None:
- p = sh.iperf("-c", self.__sip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m")
+ p = sh.iperf("-c", self.__sip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port)
else:
- p = sh.iperf("-c", self.__sip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-B", self.__bind)
- #check if it was executed succesfully
+ p = sh.iperf("-c", self.__sip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port, "-B",
+ self.__bind)
+ # check if it was executed succesfully
if p.exit_code == 0:
if p.stdout == "":
self.fail("failed: error executing iperf command")
@@ -41,11 +48,12 @@ class Qethernet(unittest.TestCase):
# get first line
dat = lines[1].decode('ascii')
# search for the BW value
- a = re.search("\d+(\.\d)? Mbits/sec",dat)
- b = a.group().split( )
- BWreal = b[0]
+ a = re.search("\d+(\.\d)? Mbits/sec", dat)
+ b = a.group().split()
+ bwreal = b[0]
# check if BW is in the expected range
- self.failUnless(float(BWreal)>float(self.__OKBW)*0.9,"failed: speed is lower than spected. Speed(MB/s)" + str(BWreal))
+ self.failUnless(float(bwreal) > float(self.__OKBW) * 0.9,
+ "failed: speed is lower than spected. Speed(MB/s)" + str(bwreal))
else:
self.fail("failed: could not complete iperf command")