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
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-10-11 15:53:31 +0000
3+++ debian/changelog 2013-11-05 20:08:06 +0000
4@@ -1,3 +1,10 @@
5+checkbox (1.16.13~OCP) UNRELEASED; urgency=low
6+
7+ [ Jeff Marcom ]
8+ * Updated scripts/network script from lp:checkbox
9+
10+ -- Jeff Marcom <jeff.marcom@canonical.com> Tue, 5 Nov 2013 11:12:04 -0400
11+
12 checkbox (1.16.12~OCP) UNRELEASED; urgency=low
13
14 [ Jeff Marcom ]
15
16=== modified file 'scripts/network'
17--- scripts/network 2013-10-11 15:53:31 +0000
18+++ scripts/network 2013-11-05 20:08:06 +0000
19@@ -63,25 +63,44 @@
20 self.mbytes = mbytes
21
22 def run(self):
23- cmd = "timeout 30 iperf -c {} -n {}".format(self.target, self.mbytes)
24+ cmd = "timeout 180 iperf -c {} -n {}".format(self.target, self.mbytes)
25
26 logging.debug(cmd)
27 try:
28 iperf_return = check_output(
29 shlex.split(cmd), universal_newlines=True)
30 except CalledProcessError as iperf_exception:
31- logging.error("Failed executing iperf, Reason:", iperf_exception)
32+ if iperf_exception.returncode != 124:
33+ # timeout command will return 124 if iperf timed out, so any
34+ # other return value means something did fail
35+ logging.error("Failed executing iperf: %s",
36+ iperf_exception.output)
37+ return iperf_exception.returncode
38+ else:
39+ # this is normal so we "except" this exception and we
40+ # "pass through" whatever output iperf did manage to produce.
41+ # When confronted with SIGTERM iperf should stop and output
42+ # a partial (but usable) result.
43+ logging.warning("iperf timed out - this should be OK")
44+ iperf_return = iperf_exception.output
45
46 # 930 Mbits/sec\n'
47 print(iperf_return)
48- match = re.search(r'\d+\sMbits', iperf_return)
49+ match = re.search(r'\d+\s([GM])bits', iperf_return)
50 if match:
51 throughput = match.group(0).split()[0]
52-
53- percent = int(throughput) / int(self.iface.max_speed) * 100
54- print("Transfer speed:")
55- print("%3.2f%% of" % percent)
56- print("theoretical max %smbs" % int(self.iface.max_speed))
57+ units = match.group(1)
58+ # self.iface.max_speed is always in mb/s, so we need to scale
59+ # throughput to match
60+ scaled_throughput = int(throughput)
61+ if units == 'G':
62+ scaled_throughput *= 1000
63+ if units == 'K':
64+ scaled_throughput /= 1000
65+ percent = scaled_throughput / int(self.iface.max_speed) * 100
66+ print("Transfer speed: {} {}b/s".format(throughput, units))
67+ print("%3.2f%% of " % percent, end="")
68+ print("theoretical max %sMb/s" % int(self.iface.max_speed))
69
70 if percent < 40:
71 logging.warn("Poor network performance detected")
72@@ -332,20 +351,6 @@
73 test_user = args.username
74 test_pass = args.password
75
76- # Stop all other interfaces
77- extra_interfaces = \
78- [iface for iface in os.listdir("/sys/class/net")
79- if iface != "lo" and iface != args.interface]
80-
81- for iface in extra_interfaces:
82- logging.debug("Shutting down interface:%s", iface)
83- try:
84- cmd = "ip link set dev %s down" % iface
85- check_call(shlex.split(cmd))
86- except CalledProcessError as interface_failure:
87- logging.error("Failed to use %s:%s", cmd, interface_failure)
88- sys.exit(3)
89-
90 if test_target is None:
91 # Set FTP parameters based on config file
92 test_target = config.get("FTP", "Target")
93@@ -360,19 +365,46 @@
94 logging.error("Please supply target via: %s", config_file)
95 sys.exit(1)
96
97- # Execute FTP transfer benchmarking test
98- if args.test_type.lower() == "ftp":
99- ftp_benchmark = FTPPerformanceTest(
100- test_target, test_user, test_pass, args.interface)
101-
102- if args.filesize:
103- ftp_benchmark.binary_size = int(args.filesize)
104- sys.exit(ftp_benchmark.run())
105-
106- elif args.test_type.lower() == "iperf":
107- iperf_benchmark = IPerfPerformanceTest(args.interface, test_target)
108- sys.exit(iperf_benchmark.run())
109-
110+
111+ result = 0
112+ # Stop all other interfaces
113+ extra_interfaces = \
114+ [iface for iface in os.listdir("/sys/class/net")
115+ if iface != "lo" and iface != args.interface]
116+
117+ for iface in extra_interfaces:
118+ logging.debug("Shutting down interface:%s", iface)
119+ try:
120+ cmd = "ip link set dev %s down" % iface
121+ check_call(shlex.split(cmd))
122+ except CalledProcessError as interface_failure:
123+ logging.error("Failed to use %s:%s", cmd, interface_failure)
124+ result = 3
125+
126+ if result == 0:
127+ # Execute FTP transfer benchmarking test
128+ if args.test_type.lower() == "ftp":
129+ ftp_benchmark = FTPPerformanceTest(
130+ test_target, test_user, test_pass, args.interface)
131+
132+ if args.filesize:
133+ ftp_benchmark.binary_size = int(args.filesize)
134+ result = ftp_benchmark.run()
135+
136+ elif args.test_type.lower() == "iperf":
137+ iperf_benchmark = IPerfPerformanceTest(args.interface, test_target)
138+ result = iperf_benchmark.run()
139+
140+ for iface in extra_interfaces:
141+ logging.debug("Restoring interface:%s", iface)
142+ try:
143+ cmd = "ip link set dev %s up" % iface
144+ check_call(shlex.split(cmd))
145+ except CalledProcessError as interface_failure:
146+ logging.error("Failed to use %s:%s", cmd, interface_failure)
147+ result = 3
148+
149+ sys.exit(result)
150
151 def interface_info(args):
152

Subscribers

People subscribed via source and target branches