Merge lp:~jeffmarcom/opencompute/updated-network-script into lp:opencompute/checkbox

Proposed by Jeff Marcom
Status: Merged
Approved by: Jeff Lane 
Approved revision: 2169
Merged at revision: 2168
Proposed branch: lp:~jeffmarcom/opencompute/updated-network-script
Merge into: lp:opencompute/checkbox
Diff against target: 151 lines (+74/-35)
2 files modified
debian/changelog (+7/-0)
scripts/network (+67/-35)
To merge this branch: bzr merge lp:~jeffmarcom/opencompute/updated-network-script
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+194001@code.launchpad.net

Commit message

Updated the network script in scripts/ from base checkbox lp:checkbox.

Description of the change

This updates the network script in scripts/ from base checkbox lp:checkbox.

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

Looks good to me. Though brendan is changing it again in trunk, so we'll need to do this again down the road some time. Brendan added a Stress test using iperf as well...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
1checkbox (1.16.13~OCP) UNRELEASED; urgency=low
2
3 [ Jeff Marcom ]
4 * Updated scripts/network script from lp:checkbox
5
6 -- Jeff Marcom <jeff.marcom@canonical.com> Tue, 5 Nov 2013 11:12:04 -0400
7
1checkbox (1.16.12~OCP) UNRELEASED; urgency=low8checkbox (1.16.12~OCP) UNRELEASED; urgency=low
29
3 [ Jeff Marcom ]10 [ Jeff Marcom ]
411
=== 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 @@
63 self.mbytes = mbytes63 self.mbytes = mbytes
6464
65 def run(self):65 def run(self):
66 cmd = "timeout 30 iperf -c {} -n {}".format(self.target, self.mbytes)66 cmd = "timeout 180 iperf -c {} -n {}".format(self.target, self.mbytes)
6767
68 logging.debug(cmd)68 logging.debug(cmd)
69 try:69 try:
70 iperf_return = check_output(70 iperf_return = check_output(
71 shlex.split(cmd), universal_newlines=True)71 shlex.split(cmd), universal_newlines=True)
72 except CalledProcessError as iperf_exception:72 except CalledProcessError as iperf_exception:
73 logging.error("Failed executing iperf, Reason:", iperf_exception)73 if iperf_exception.returncode != 124:
74 # timeout command will return 124 if iperf timed out, so any
75 # other return value means something did fail
76 logging.error("Failed executing iperf: %s",
77 iperf_exception.output)
78 return iperf_exception.returncode
79 else:
80 # this is normal so we "except" this exception and we
81 # "pass through" whatever output iperf did manage to produce.
82 # When confronted with SIGTERM iperf should stop and output
83 # a partial (but usable) result.
84 logging.warning("iperf timed out - this should be OK")
85 iperf_return = iperf_exception.output
7486
75 # 930 Mbits/sec\n'87 # 930 Mbits/sec\n'
76 print(iperf_return)88 print(iperf_return)
77 match = re.search(r'\d+\sMbits', iperf_return)89 match = re.search(r'\d+\s([GM])bits', iperf_return)
78 if match:90 if match:
79 throughput = match.group(0).split()[0]91 throughput = match.group(0).split()[0]
8092 units = match.group(1)
81 percent = int(throughput) / int(self.iface.max_speed) * 10093 # self.iface.max_speed is always in mb/s, so we need to scale
82 print("Transfer speed:")94 # throughput to match
83 print("%3.2f%% of" % percent)95 scaled_throughput = int(throughput)
84 print("theoretical max %smbs" % int(self.iface.max_speed))96 if units == 'G':
97 scaled_throughput *= 1000
98 if units == 'K':
99 scaled_throughput /= 1000
100 percent = scaled_throughput / int(self.iface.max_speed) * 100
101 print("Transfer speed: {} {}b/s".format(throughput, units))
102 print("%3.2f%% of " % percent, end="")
103 print("theoretical max %sMb/s" % int(self.iface.max_speed))
85104
86 if percent < 40:105 if percent < 40:
87 logging.warn("Poor network performance detected")106 logging.warn("Poor network performance detected")
@@ -332,20 +351,6 @@
332 test_user = args.username351 test_user = args.username
333 test_pass = args.password352 test_pass = args.password
334353
335 # Stop all other interfaces
336 extra_interfaces = \
337 [iface for iface in os.listdir("/sys/class/net")
338 if iface != "lo" and iface != args.interface]
339
340 for iface in extra_interfaces:
341 logging.debug("Shutting down interface:%s", iface)
342 try:
343 cmd = "ip link set dev %s down" % iface
344 check_call(shlex.split(cmd))
345 except CalledProcessError as interface_failure:
346 logging.error("Failed to use %s:%s", cmd, interface_failure)
347 sys.exit(3)
348
349 if test_target is None:354 if test_target is None:
350 # Set FTP parameters based on config file355 # Set FTP parameters based on config file
351 test_target = config.get("FTP", "Target")356 test_target = config.get("FTP", "Target")
@@ -360,19 +365,46 @@
360 logging.error("Please supply target via: %s", config_file)365 logging.error("Please supply target via: %s", config_file)
361 sys.exit(1)366 sys.exit(1)
362367
363 # Execute FTP transfer benchmarking test368
364 if args.test_type.lower() == "ftp":369 result = 0
365 ftp_benchmark = FTPPerformanceTest(370 # Stop all other interfaces
366 test_target, test_user, test_pass, args.interface)371 extra_interfaces = \
367372 [iface for iface in os.listdir("/sys/class/net")
368 if args.filesize:373 if iface != "lo" and iface != args.interface]
369 ftp_benchmark.binary_size = int(args.filesize)374
370 sys.exit(ftp_benchmark.run())375 for iface in extra_interfaces:
371376 logging.debug("Shutting down interface:%s", iface)
372 elif args.test_type.lower() == "iperf":377 try:
373 iperf_benchmark = IPerfPerformanceTest(args.interface, test_target)378 cmd = "ip link set dev %s down" % iface
374 sys.exit(iperf_benchmark.run())379 check_call(shlex.split(cmd))
375380 except CalledProcessError as interface_failure:
381 logging.error("Failed to use %s:%s", cmd, interface_failure)
382 result = 3
383
384 if result == 0:
385 # Execute FTP transfer benchmarking test
386 if args.test_type.lower() == "ftp":
387 ftp_benchmark = FTPPerformanceTest(
388 test_target, test_user, test_pass, args.interface)
389
390 if args.filesize:
391 ftp_benchmark.binary_size = int(args.filesize)
392 result = ftp_benchmark.run()
393
394 elif args.test_type.lower() == "iperf":
395 iperf_benchmark = IPerfPerformanceTest(args.interface, test_target)
396 result = iperf_benchmark.run()
397
398 for iface in extra_interfaces:
399 logging.debug("Restoring interface:%s", iface)
400 try:
401 cmd = "ip link set dev %s up" % iface
402 check_call(shlex.split(cmd))
403 except CalledProcessError as interface_failure:
404 logging.error("Failed to use %s:%s", cmd, interface_failure)
405 result = 3
406
407 sys.exit(result)
376408
377def interface_info(args):409def interface_info(args):
378410

Subscribers

People subscribed via source and target branches