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
1diff --git a/bin/network b/bin/network
2index 552c74c..c0ee7e6 100755
3--- a/bin/network
4+++ b/bin/network
5@@ -107,8 +107,8 @@ class IPerfPerformanceTest(object):
6 self.timeout, self.executable, self.target, self.data_size)
7
8 logging.debug("Executing command {}".format(cmd))
9- logging.info("Starting iperf against {}, this could take a while...".
10- format(self.target))
11+ logging.debug("Starting iperf against {}, this could take a while...".
12+ format(self.target))
13 try:
14 iperf_return = check_output(
15 shlex.split(cmd), universal_newlines=True)
16@@ -124,7 +124,7 @@ class IPerfPerformanceTest(object):
17 # "pass through" whatever output iperf did manage to produce.
18 # When confronted with SIGTERM iperf should stop and output
19 # a partial (but usable) result.
20- logging.info("iperf timed out - this should be OK")
21+ logging.warning("iperf timed out - this should be OK")
22 iperf_return = iperf_exception.output
23
24 logging.debug(iperf_return)
25@@ -147,40 +147,39 @@ class IPerfPerformanceTest(object):
26 percent = 0
27 invalid_speed = True
28
29- logging.info("Min Transfer speed: {} Mb/s".format(min(speeds)))
30- logging.info("Max Transfer speed: {} Mb/s".format(max(speeds)))
31+ logging.debug("Min Transfer speed: {} Mb/s".format(min(speeds)))
32+ logging.debug("Max Transfer speed: {} Mb/s".format(max(speeds)))
33 logging.info("Avg Transfer speed: {} Mb/s".format(throughput))
34 if invalid_speed:
35 # If we have no link_speed (e.g. wireless interfaces don't
36 # report this), then we shouldn't penalize them because
37 # the transfer may have been reasonable. So in this case,
38 # we'll exit with a pass-warning.
39- logging.info("Unable to obtain maximum speed.")
40- logging.info("Considering the test as passed.")
41+ logging.warning("Unable to obtain maximum speed.")
42+ logging.warning("Considering the test as passed.")
43 return 0
44 # Below is guaranteed to not throw an exception because we'll
45 # have exited above if it did.
46 logging.info("{:03.2f}% of theoretical max {} Mb/s".
47 format(percent, int(self.iface.max_speed)))
48 if cpu:
49- logging.info("")
50 logging.info("CPU utilization: {}%".format(cpu[0]))
51 cpu_load = float(cpu[0])
52 else:
53 cpu_load = 0.0
54 if percent < self.fail_threshold or \
55 cpu_load > self.cpu_load_fail_threshold:
56- logging.warn("Poor network performance detected against {}".
57- format(self.target))
58+ logging.warning("Poor network performance detected against {}".
59+ format(self.target))
60 if percent < self.fail_threshold:
61- logging.warn(" Transfer speed: {} Mb/s".
62- format(throughput))
63- logging.warn(" {:03.2f}% of theoretical max {} Mb/s\n".
64- format(percent, int(self.iface.max_speed)))
65+ logging.warning(" Transfer speed: {} Mb/s".
66+ format(throughput))
67+ logging.warning(" {:03.2f}% of theoretical max {} Mb/s\n".
68+ format(percent, int(self.iface.max_speed)))
69 if cpu_load > self.cpu_load_fail_threshold:
70- logging.warn(" CPU load: {}%".format(cpu_load))
71- logging.warn(" CPU load is above {}% maximum\n".
72- format(self.cpu_load_fail_threshold))
73+ logging.warning(" CPU load: {}%".format(cpu_load))
74+ logging.warning(" CPU load is above {}% maximum\n".
75+ format(self.cpu_load_fail_threshold))
76 return 30
77
78 logging.debug("Passed benchmark against {}".format(self.target))
79@@ -250,7 +249,7 @@ class Interface(socket.socket):
80 try:
81 return open(os.path.join(self.dev_path, type)).read().strip()
82 except OSError:
83- logging.info("%s: Attribute not found", type)
84+ logging.warning("%s: Attribute not found", type)
85
86 @property
87 def ipaddress(self):
88@@ -404,9 +403,10 @@ def run_test(args, test_target):
89 iperf_benchmark.run_time = args.runtime
90 run_num = 0
91 while not error_number and run_num < args.num_runs:
92- error_number = iperf_benchmark.run()
93 run_num += 1
94- logging.info(" Finished run number %s ".center(60, "-"), run_num)
95+ logging.info(" Test Run Number %s ".center(60, "-"), run_num)
96+ error_number = iperf_benchmark.run()
97+ logging.info('')
98 elif args.test_type.lower() == "stress":
99 stress_benchmark = StressPerformanceTest(args.interface,
100 test_target, args.iperf3)
101@@ -483,16 +483,16 @@ def interface_test(args):
102 if not test_targets_list or "example.com" in test_targets:
103 # Default values found in config file
104 logging.error("Valid target server has not been supplied.")
105- logging.info("Configuration settings can be configured 3 different "
106- "ways:")
107- logging.info("1- If calling the script directly, pass the --target "
108- "option")
109- logging.info("2- Define the TEST_TARGET_IPERF environment variable")
110- logging.info("3- (If running the test via checkbox/plainbox, define "
111- "the ")
112- logging.info("target in /etc/xdg/canonical-certification.conf)")
113- logging.info("Please run this script with -h to see more details on "
114- "how to configure")
115+ logging.error("Configuration settings can be configured 3 different "
116+ "ways:")
117+ logging.error("1- If calling the script directly, pass the --target "
118+ "option")
119+ logging.error("2- Define the TEST_TARGET_IPERF environment variable")
120+ logging.error("3- (If running the test via checkbox/plainbox, define "
121+ "the ")
122+ logging.error("target in /etc/xdg/canonical-certification.conf)")
123+ logging.error("Please run this script with -h to see more details on "
124+ "how to configure")
125 sys.exit(1)
126
127 # Testing begins here!
128@@ -539,8 +539,8 @@ def interface_test(args):
129 not error_number:
130 break
131 if not test_targets_list:
132- logging.info(" Exhausted test target list; trying again "
133- .center(60, "="))
134+ logging.warning(" Exhausted test target list; trying again "
135+ .center(60, "="))
136 test_targets_list = make_target_list(args.interface,
137 test_targets,
138 False)

Subscribers

People subscribed via source and target branches