opencompute-developers team mailing list archive
-
opencompute-developers team
-
Mailing list archive
-
Message #00201
[Merge] lp:~jeffmarcom/opencompute/updated-network-script into lp:opencompute/checkbox
Jeff Marcom has proposed merging lp:~jeffmarcom/opencompute/updated-network-script into lp:opencompute/checkbox.
Commit message:
Updated the network script in scripts/ from base checkbox lp:checkbox.
Requested reviews:
Open Compute Developers (opencompute-developers)
For more details, see:
https://code.launchpad.net/~jeffmarcom/opencompute/updated-network-script/+merge/194001
This updates the network script in scripts/ from base checkbox lp:checkbox.
--
https://code.launchpad.net/~jeffmarcom/opencompute/updated-network-script/+merge/194001
Your team Open Compute Developers is requested to review the proposed merge of lp:~jeffmarcom/opencompute/updated-network-script into lp:opencompute/checkbox.
=== modified file 'debian/changelog'
--- debian/changelog 2013-10-11 15:53:31 +0000
+++ debian/changelog 2013-11-05 20:08:06 +0000
@@ -1,3 +1,10 @@
+checkbox (1.16.13~OCP) UNRELEASED; urgency=low
+
+ [ Jeff Marcom ]
+ * Updated scripts/network script from lp:checkbox
+
+ -- Jeff Marcom <jeff.marcom@xxxxxxxxxxxxx> Tue, 5 Nov 2013 11:12:04 -0400
+
checkbox (1.16.12~OCP) UNRELEASED; urgency=low
[ Jeff Marcom ]
=== modified file 'scripts/network'
--- scripts/network 2013-10-11 15:53:31 +0000
+++ scripts/network 2013-11-05 20:08:06 +0000
@@ -63,25 +63,44 @@
self.mbytes = mbytes
def run(self):
- cmd = "timeout 30 iperf -c {} -n {}".format(self.target, self.mbytes)
+ cmd = "timeout 180 iperf -c {} -n {}".format(self.target, self.mbytes)
logging.debug(cmd)
try:
iperf_return = check_output(
shlex.split(cmd), universal_newlines=True)
except CalledProcessError as iperf_exception:
- logging.error("Failed executing iperf, Reason:", iperf_exception)
+ if iperf_exception.returncode != 124:
+ # timeout command will return 124 if iperf timed out, so any
+ # other return value means something did fail
+ logging.error("Failed executing iperf: %s",
+ iperf_exception.output)
+ return iperf_exception.returncode
+ else:
+ # this is normal so we "except" this exception and we
+ # "pass through" whatever output iperf did manage to produce.
+ # When confronted with SIGTERM iperf should stop and output
+ # a partial (but usable) result.
+ logging.warning("iperf timed out - this should be OK")
+ iperf_return = iperf_exception.output
# 930 Mbits/sec\n'
print(iperf_return)
- match = re.search(r'\d+\sMbits', iperf_return)
+ match = re.search(r'\d+\s([GM])bits', iperf_return)
if match:
throughput = match.group(0).split()[0]
-
- percent = int(throughput) / int(self.iface.max_speed) * 100
- print("Transfer speed:")
- print("%3.2f%% of" % percent)
- print("theoretical max %smbs" % int(self.iface.max_speed))
+ units = match.group(1)
+ # self.iface.max_speed is always in mb/s, so we need to scale
+ # throughput to match
+ scaled_throughput = int(throughput)
+ if units == 'G':
+ scaled_throughput *= 1000
+ if units == 'K':
+ scaled_throughput /= 1000
+ percent = scaled_throughput / int(self.iface.max_speed) * 100
+ print("Transfer speed: {} {}b/s".format(throughput, units))
+ print("%3.2f%% of " % percent, end="")
+ print("theoretical max %sMb/s" % int(self.iface.max_speed))
if percent < 40:
logging.warn("Poor network performance detected")
@@ -332,20 +351,6 @@
test_user = args.username
test_pass = args.password
- # Stop all other interfaces
- extra_interfaces = \
- [iface for iface in os.listdir("/sys/class/net")
- if iface != "lo" and iface != args.interface]
-
- for iface in extra_interfaces:
- logging.debug("Shutting down interface:%s", iface)
- try:
- cmd = "ip link set dev %s down" % iface
- check_call(shlex.split(cmd))
- except CalledProcessError as interface_failure:
- logging.error("Failed to use %s:%s", cmd, interface_failure)
- sys.exit(3)
-
if test_target is None:
# Set FTP parameters based on config file
test_target = config.get("FTP", "Target")
@@ -360,19 +365,46 @@
logging.error("Please supply target via: %s", config_file)
sys.exit(1)
- # Execute FTP transfer benchmarking test
- if args.test_type.lower() == "ftp":
- ftp_benchmark = FTPPerformanceTest(
- test_target, test_user, test_pass, args.interface)
-
- if args.filesize:
- ftp_benchmark.binary_size = int(args.filesize)
- sys.exit(ftp_benchmark.run())
-
- elif args.test_type.lower() == "iperf":
- iperf_benchmark = IPerfPerformanceTest(args.interface, test_target)
- sys.exit(iperf_benchmark.run())
-
+
+ result = 0
+ # Stop all other interfaces
+ extra_interfaces = \
+ [iface for iface in os.listdir("/sys/class/net")
+ if iface != "lo" and iface != args.interface]
+
+ for iface in extra_interfaces:
+ logging.debug("Shutting down interface:%s", iface)
+ try:
+ cmd = "ip link set dev %s down" % iface
+ check_call(shlex.split(cmd))
+ except CalledProcessError as interface_failure:
+ logging.error("Failed to use %s:%s", cmd, interface_failure)
+ result = 3
+
+ if result == 0:
+ # Execute FTP transfer benchmarking test
+ if args.test_type.lower() == "ftp":
+ ftp_benchmark = FTPPerformanceTest(
+ test_target, test_user, test_pass, args.interface)
+
+ if args.filesize:
+ ftp_benchmark.binary_size = int(args.filesize)
+ result = ftp_benchmark.run()
+
+ elif args.test_type.lower() == "iperf":
+ iperf_benchmark = IPerfPerformanceTest(args.interface, test_target)
+ result = iperf_benchmark.run()
+
+ for iface in extra_interfaces:
+ logging.debug("Restoring interface:%s", iface)
+ try:
+ cmd = "ip link set dev %s up" % iface
+ check_call(shlex.split(cmd))
+ except CalledProcessError as interface_failure:
+ logging.error("Failed to use %s:%s", cmd, interface_failure)
+ result = 3
+
+ sys.exit(result)
def interface_info(args):
Follow ups