Merge ~bladernr/plainbox-provider-checkbox:reduce-network-script-output into plainbox-provider-checkbox:master

Proposed by Jeff Lane 
Status: Merged
Approved by: Sylvain Pineau
Approved revision: e66c0d8658fc4718124c3efc81d14b0c55fb4717
Merged at revision: 566e464e16e1808f0915a14d46d0b519bc7be231
Proposed branch: ~bladernr/plainbox-provider-checkbox:reduce-network-script-output
Merge into: plainbox-provider-checkbox:master
Diff against target: 138 lines (+32/-32)
1 file modified
bin/network (+32/-32)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+320439@code.launchpad.net

Description of the change

Reduce the amount of "normal" output so results are easier to read.
Replace all instances of logging.warn with logging.warning, since warn() is deprecated and warning should work in all python versions.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Looks ok, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/network b/bin/network
index 552c74c..c0ee7e6 100755
--- a/bin/network
+++ b/bin/network
@@ -107,8 +107,8 @@ class IPerfPerformanceTest(object):
107 self.timeout, self.executable, self.target, self.data_size)107 self.timeout, self.executable, self.target, self.data_size)
108108
109 logging.debug("Executing command {}".format(cmd))109 logging.debug("Executing command {}".format(cmd))
110 logging.info("Starting iperf against {}, this could take a while...".110 logging.debug("Starting iperf against {}, this could take a while...".
111 format(self.target))111 format(self.target))
112 try:112 try:
113 iperf_return = check_output(113 iperf_return = check_output(
114 shlex.split(cmd), universal_newlines=True)114 shlex.split(cmd), universal_newlines=True)
@@ -124,7 +124,7 @@ class IPerfPerformanceTest(object):
124 # "pass through" whatever output iperf did manage to produce.124 # "pass through" whatever output iperf did manage to produce.
125 # When confronted with SIGTERM iperf should stop and output125 # When confronted with SIGTERM iperf should stop and output
126 # a partial (but usable) result.126 # a partial (but usable) result.
127 logging.info("iperf timed out - this should be OK")127 logging.warning("iperf timed out - this should be OK")
128 iperf_return = iperf_exception.output128 iperf_return = iperf_exception.output
129129
130 logging.debug(iperf_return)130 logging.debug(iperf_return)
@@ -147,40 +147,39 @@ class IPerfPerformanceTest(object):
147 percent = 0147 percent = 0
148 invalid_speed = True148 invalid_speed = True
149149
150 logging.info("Min Transfer speed: {} Mb/s".format(min(speeds)))150 logging.debug("Min Transfer speed: {} Mb/s".format(min(speeds)))
151 logging.info("Max Transfer speed: {} Mb/s".format(max(speeds)))151 logging.debug("Max Transfer speed: {} Mb/s".format(max(speeds)))
152 logging.info("Avg Transfer speed: {} Mb/s".format(throughput))152 logging.info("Avg Transfer speed: {} Mb/s".format(throughput))
153 if invalid_speed:153 if invalid_speed:
154 # If we have no link_speed (e.g. wireless interfaces don't154 # If we have no link_speed (e.g. wireless interfaces don't
155 # report this), then we shouldn't penalize them because155 # report this), then we shouldn't penalize them because
156 # the transfer may have been reasonable. So in this case,156 # the transfer may have been reasonable. So in this case,
157 # we'll exit with a pass-warning.157 # we'll exit with a pass-warning.
158 logging.info("Unable to obtain maximum speed.")158 logging.warning("Unable to obtain maximum speed.")
159 logging.info("Considering the test as passed.")159 logging.warning("Considering the test as passed.")
160 return 0160 return 0
161 # Below is guaranteed to not throw an exception because we'll161 # Below is guaranteed to not throw an exception because we'll
162 # have exited above if it did.162 # have exited above if it did.
163 logging.info("{:03.2f}% of theoretical max {} Mb/s".163 logging.info("{:03.2f}% of theoretical max {} Mb/s".
164 format(percent, int(self.iface.max_speed)))164 format(percent, int(self.iface.max_speed)))
165 if cpu:165 if cpu:
166 logging.info("")
167 logging.info("CPU utilization: {}%".format(cpu[0]))166 logging.info("CPU utilization: {}%".format(cpu[0]))
168 cpu_load = float(cpu[0])167 cpu_load = float(cpu[0])
169 else:168 else:
170 cpu_load = 0.0169 cpu_load = 0.0
171 if percent < self.fail_threshold or \170 if percent < self.fail_threshold or \
172 cpu_load > self.cpu_load_fail_threshold:171 cpu_load > self.cpu_load_fail_threshold:
173 logging.warn("Poor network performance detected against {}".172 logging.warning("Poor network performance detected against {}".
174 format(self.target))173 format(self.target))
175 if percent < self.fail_threshold:174 if percent < self.fail_threshold:
176 logging.warn(" Transfer speed: {} Mb/s".175 logging.warning(" Transfer speed: {} Mb/s".
177 format(throughput))176 format(throughput))
178 logging.warn(" {:03.2f}% of theoretical max {} Mb/s\n".177 logging.warning(" {:03.2f}% of theoretical max {} Mb/s\n".
179 format(percent, int(self.iface.max_speed)))178 format(percent, int(self.iface.max_speed)))
180 if cpu_load > self.cpu_load_fail_threshold:179 if cpu_load > self.cpu_load_fail_threshold:
181 logging.warn(" CPU load: {}%".format(cpu_load))180 logging.warning(" CPU load: {}%".format(cpu_load))
182 logging.warn(" CPU load is above {}% maximum\n".181 logging.warning(" CPU load is above {}% maximum\n".
183 format(self.cpu_load_fail_threshold))182 format(self.cpu_load_fail_threshold))
184 return 30183 return 30
185184
186 logging.debug("Passed benchmark against {}".format(self.target))185 logging.debug("Passed benchmark against {}".format(self.target))
@@ -250,7 +249,7 @@ class Interface(socket.socket):
250 try:249 try:
251 return open(os.path.join(self.dev_path, type)).read().strip()250 return open(os.path.join(self.dev_path, type)).read().strip()
252 except OSError:251 except OSError:
253 logging.info("%s: Attribute not found", type)252 logging.warning("%s: Attribute not found", type)
254253
255 @property254 @property
256 def ipaddress(self):255 def ipaddress(self):
@@ -404,9 +403,10 @@ def run_test(args, test_target):
404 iperf_benchmark.run_time = args.runtime403 iperf_benchmark.run_time = args.runtime
405 run_num = 0404 run_num = 0
406 while not error_number and run_num < args.num_runs:405 while not error_number and run_num < args.num_runs:
407 error_number = iperf_benchmark.run()
408 run_num += 1406 run_num += 1
409 logging.info(" Finished run number %s ".center(60, "-"), run_num)407 logging.info(" Test Run Number %s ".center(60, "-"), run_num)
408 error_number = iperf_benchmark.run()
409 logging.info('')
410 elif args.test_type.lower() == "stress":410 elif args.test_type.lower() == "stress":
411 stress_benchmark = StressPerformanceTest(args.interface,411 stress_benchmark = StressPerformanceTest(args.interface,
412 test_target, args.iperf3)412 test_target, args.iperf3)
@@ -483,16 +483,16 @@ def interface_test(args):
483 if not test_targets_list or "example.com" in test_targets:483 if not test_targets_list or "example.com" in test_targets:
484 # Default values found in config file484 # Default values found in config file
485 logging.error("Valid target server has not been supplied.")485 logging.error("Valid target server has not been supplied.")
486 logging.info("Configuration settings can be configured 3 different "486 logging.error("Configuration settings can be configured 3 different "
487 "ways:")487 "ways:")
488 logging.info("1- If calling the script directly, pass the --target "488 logging.error("1- If calling the script directly, pass the --target "
489 "option")489 "option")
490 logging.info("2- Define the TEST_TARGET_IPERF environment variable")490 logging.error("2- Define the TEST_TARGET_IPERF environment variable")
491 logging.info("3- (If running the test via checkbox/plainbox, define "491 logging.error("3- (If running the test via checkbox/plainbox, define "
492 "the ")492 "the ")
493 logging.info("target in /etc/xdg/canonical-certification.conf)")493 logging.error("target in /etc/xdg/canonical-certification.conf)")
494 logging.info("Please run this script with -h to see more details on "494 logging.error("Please run this script with -h to see more details on "
495 "how to configure")495 "how to configure")
496 sys.exit(1)496 sys.exit(1)
497497
498 # Testing begins here!498 # Testing begins here!
@@ -539,8 +539,8 @@ def interface_test(args):
539 not error_number:539 not error_number:
540 break540 break
541 if not test_targets_list:541 if not test_targets_list:
542 logging.info(" Exhausted test target list; trying again "542 logging.warning(" Exhausted test target list; trying again "
543 .center(60, "="))543 .center(60, "="))
544 test_targets_list = make_target_list(args.interface,544 test_targets_list = make_target_list(args.interface,
545 test_targets,545 test_targets,
546 False)546 False)

Subscribers

People subscribed via source and target branches