diff options
| -rwxr-xr-x | bin/network | 25 | ||||
| -rw-r--r-- | jobs/ethernet.txt.in | 4 |
2 files changed, 24 insertions, 5 deletions
diff --git a/bin/network b/bin/network index d0d4af3..a7f4b88 100755 --- a/bin/network +++ b/bin/network @@ -24,6 +24,7 @@ from argparse import ( ArgumentParser, RawTextHelpFormatter ) +import datetime import fcntl import logging import os @@ -57,7 +58,8 @@ class IPerfPerformanceTest(object): iperf3, protocol="tcp", data_size="1", - run_time=None): + run_time=None, + scan_timeout=3600): self.iface = Interface(interface) self.target = target @@ -67,6 +69,7 @@ class IPerfPerformanceTest(object): self.iperf3 = iperf3 self.data_size = data_size self.run_time = run_time + self.scan_timeout = scan_timeout def run(self): # if max_speed is 0, assume it's wifi and move on @@ -461,12 +464,23 @@ def interface_test(args): if error_number == 0: test_targets_list = test_targets.split(",") test_targets_list.reverse() - # Keep testing until a success or we run out of targets + start_time = datetime.datetime.now() + first_loop = True + # Keep testing until a success or we run out of both targets and time while test_targets_list: test_target = test_targets_list.pop().strip() error_number = run_test(args, test_target) - if not error_number: + elapsed_seconds = (datetime.datetime.now() - start_time).seconds + if (elapsed_seconds > args.scan_timeout and not first_loop) or \ + not error_number: break + if not test_targets_list: + logging.info(" Exhausted test target list; trying again " + .center(60, "=")) + test_targets_list = test_targets.split(",") + test_targets_list.reverse() + time.sleep(30) + first_loop = False for iface in extra_interfaces: logging.debug("Restoring interface:%s", iface) @@ -587,6 +601,11 @@ TEST_TARGET_IPERF = iperf-server.example.com "of time indicated, rather than until a certain file size is " "reached.")) test_parser.add_argument( + '--scan-timeout', type=int, + default=60, + help=("Sets the maximum time, in seconds, the test will scan for " + "iperf servers before giving up.")) + test_parser.add_argument( '--config', type=str, default="/etc/checkbox.d/network.cfg", help="Supply config file for target/host network parameters") diff --git a/jobs/ethernet.txt.in b/jobs/ethernet.txt.in index 2b815d2..151325b 100644 --- a/jobs/ethernet.txt.in +++ b/jobs/ethernet.txt.in @@ -60,7 +60,7 @@ requires: package.name == 'nmap' user: root environ: TEST_TARGET_IPERF -command: network test -i {interface} -t iperf --fail-threshold 80 --runtime 900 --num_runs 4 +command: network test -i {interface} -t iperf --scan-timeout 3600 --fail-threshold 80 --runtime 900 --num_runs 4 _description: This test uses iperf to ensure network devices pass data at an acceptable minimum percentage of advertized speed. @@ -79,7 +79,7 @@ requires: package.name == 'nmap' user: root environ: TEST_TARGET_IPERF -command: network test -i {interface} -t iperf --iperf3 --fail-threshold 80 --cpu-load-fail-threshold 90 --runtime 900 --num_runs 4 +command: network test -i {interface} -t iperf --iperf3 --scan-timeout 3600 --fail-threshold 80 --cpu-load-fail-threshold 90 --runtime 900 --num_runs 4 _description: This test uses iperf3 to ensure network devices pass data at an acceptable minimum percentage of advertized speed. |
