diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-07-06 17:51:09 +0200 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-07-06 17:51:09 +0200 |
commit | 47827e40f71696e04ad805296dedc44a03451db3 (patch) | |
tree | ba7dc460208d3e951d0f1724bc12a3793ef9378c /test-cli/test/tests/qethernet.py | |
parent | 1d51a80b57cc8c80c78d67c85290503997060e9e (diff) | |
download | board-47827e40f71696e04ad805296dedc44a03451db3.zip board-47827e40f71696e04ad805296dedc44a03451db3.tar.gz board-47827e40f71696e04ad805296dedc44a03451db3.tar.bz2 |
In case iperf3 server is busy, clients wait and retry.
Diffstat (limited to 'test-cli/test/tests/qethernet.py')
-rw-r--r-- | test-cli/test/tests/qethernet.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/test-cli/test/tests/qethernet.py b/test-cli/test/tests/qethernet.py index d38de34..81acef1 100644 --- a/test-cli/test/tests/qethernet.py +++ b/test-cli/test/tests/qethernet.py @@ -1,6 +1,7 @@ import unittest import sh import json +import time class Qethernet(unittest.TestCase): @@ -11,6 +12,7 @@ class Qethernet(unittest.TestCase): params = None __bwreal = None __resultlist = None # resultlist is a python list of python dictionaries + timebetweenattempts = 5 # varlist content: serverip, bwexpected, port def __init__(self, testname, testfunc, varlist): @@ -37,12 +39,17 @@ class Qethernet(unittest.TestCase): self.__resultlist = [] def execute(self): - # execute iperf command against the server - try: - p = sh.iperf3("-c", self.__serverip, "-n", self.__numbytestx, "-f", "m", "-p", self.__port, "-J", - _timeout=20) - except sh.TimeoutException: - self.fail("failed: iperf timeout reached") + # execute iperf command against the server, but it implements attempts in case the server is busy + iperfdone = False + while not iperfdone: + try: + p = sh.iperf3("-c", self.__serverip, "-n", self.__numbytestx, "-f", "m", "-p", self.__port, "-J", + _timeout=20) + iperfdone = True + except sh.TimeoutException: + self.fail("failed: iperf timeout reached") + except sh.ErrorReturnCode: + time.sleep(self.timebetweenattempts) # check if it was executed succesfully if p.exit_code == 0: |