Merge lp:~cr3/checkbox/network_bandwidth_test into lp:checkbox

Proposed by Marc Tardif
Status: Merged
Approved by: Javier Collado
Approved revision: 1433
Merged at revision: 1432
Proposed branch: lp:~cr3/checkbox/network_bandwidth_test
Merge into: lp:checkbox
Diff against target: 115 lines (+16/-12)
3 files modified
debian/changelog (+1/-0)
jobs/networking.txt.in (+4/-1)
scripts/network_bandwidth_test (+11/-11)
To merge this branch: bzr merge lp:~cr3/checkbox/network_bandwidth_test
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Marc Tardif (community) Needs Resubmitting
Review via email: mp+109917@code.launchpad.net

Description of the change

Tested on Precise:

$ sudo PYTHONPATH=. ./scripts/network_bandwidth_test
$ echo $?
0

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

Looking at the script and the checkbox jobs that use it, I have a couple of comments:

- It looks like the requirement for package.name == 'nmap' is missing for the jobs generated by networking/multi_nic, that is, for networking/multi_nic_$2.

- I don't like much this regular expression pattern:
alpha_numeric = r"[^ ]+"

because it allows other whitespace characters like \t. I'd say that a better choice would be just r"\S".

- One final comment, just for my own curiosity (not really relevant for this merge request). In networking/bandwidth I see:
requires:
 package.name == 'linux'
 package.name == 'ethtool' and package.name == 'nmap'
 device.category == 'NETWORK'

and in networking/multi_nic_$2 I see:
requires: device.path == "$1" and package.name == 'linux' and package.name == 'ethtool'

My understanding is that multiline requirements are evaluated as if they were linked with an 'and' operator. Is that the case? Is there a practical difference between using multiline vs. single line requirements?

review: Needs Information
Revision history for this message
Javier Collado (javier.collado) wrote :

> - I don't like much this regular expression pattern:
> alpha_numeric = r"[^ ]+"
>
> because it allows other whitespace characters like \t. I'd say that a better
> choice would be just r"\S".

I meant r"\S+" to be consistent with the original pattern, not just r"\S".

1432. By Marc Tardif

Fixed the requires line in the networking/multi_nic_$2 job to include the nmap package name.

1433. By Marc Tardif

Renamed the regular expression called alpha_numeric to non_space.

Revision history for this message
Marc Tardif (cr3) wrote :

1. Fixed the requires line in the networking/multi_nic_$2 job to include the nmap package name.

2. The non-space regular expression is actually correct considering the output that it parses from commands like ifconfig for example. These commands separate tokens with the space character that couldn't be anything else like a tab for example. Also, a token might contain a dash which is not included in the \S regular expression. So, I have renamed the variable to be less confusing becuase you were right that alpha_numeric should be represented with \S. Instead, I have renamed the variable to non_space.

3. One of the reasons to order requires on separate lines is to determine the appropriate package when reporting a bug for a test that failed. It does a best effort based on the device category but also on the package name, where the first package takes precedence over the subsequent ones in the list.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks for those changes.

I ran the script and checked with flake8 and didn't find any python3 related issue.

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 2012-06-12 21:13:14 +0000
3+++ debian/changelog 2012-06-13 14:09:26 +0000
4@@ -18,6 +18,7 @@
5 test.
6 * [FEATURE] Python 2 to 3 conversion:
7 * scripts/cking_suite
8+ * scripts/network_bandwidth_test
9 * Removed sleep_test script no longer used by any test definition.
10
11 [Daniel Manrique]
12
13=== modified file 'jobs/networking.txt.in'
14--- jobs/networking.txt.in 2012-04-11 22:53:52 +0000
15+++ jobs/networking.txt.in 2012-06-13 14:09:26 +0000
16@@ -110,7 +110,10 @@
17 cat <<'EOF' | run_templates -s 'udev_resource | filter_templates -w "category=NETWORK" | awk "/path: / { print \$2 }" | xargs -n 1 sh -c "for i in \`ls /sys\$0/net 2>/dev/null\`; do echo \$0 \$i; done"'
18 plugin: shell
19 name: networking/multi_nic_$2
20- requires: device.path == "$1" and package.name == 'linux' and package.name == 'ethtool'
21+ requires:
22+ package.name == 'linux'
23+ package.name == 'ethtool' and package.name == 'nmap'
24+ device.path == "$1"
25 user: root
26 command: ethtool $2 | tail -1 | grep "detected: yes" && network_bandwidth_test --interface=$2 --scan=3 --log-level=debug
27 description:
28
29=== modified file 'scripts/network_bandwidth_test'
30--- scripts/network_bandwidth_test 2012-05-22 18:01:21 +0000
31+++ scripts/network_bandwidth_test 2012-06-13 14:09:26 +0000
32@@ -1,4 +1,4 @@
33-#!/usr/bin/python
34+#!/usr/bin/env python3
35
36 import os
37 import re
38@@ -50,7 +50,7 @@
39 output_patterns = {}
40
41 # Convenient output patterns
42- alpha_numeric = r"[^ ]+"
43+ non_space = r"[^ ]+"
44
45 def __init__(self, *arguments, **options):
46 if len(arguments) != self.argument_count:
47@@ -107,10 +107,10 @@
48 stderr=subprocess.PIPE)
49 error = process.stderr.read()
50 if error:
51- raise CommandException(error)
52+ raise CommandException(error.decode("utf-8"))
53
54 output = process.stdout.read()
55- return self.parse_output(output)
56+ return self.parse_output(output.decode("utf-8"))
57
58
59 class NetworkConfigOutput(CommandOutput):
60@@ -142,12 +142,12 @@
61
62 output_factory = NetworkConfigOutput
63 output_patterns = {
64- "name": r"(%s).*Link encap" % Command.alpha_numeric,
65+ "name": r"(%s).*Link encap" % Command.non_space,
66 "broadcast": r"Bcast:(%s)" % ipv4,
67 "collisions": "collisions:(\d+)",
68 "hwaddr": r"HWaddr (%s)" % mac_address,
69 "inet_addr": r"inet addr:(%s)" % ipv4,
70- "link_encap": r"Link encap:(%s)" % Command.alpha_numeric,
71+ "link_encap": r"Link encap:(%s)" % Command.non_space,
72 "netmask": r"Mask:(%s)" % ipv4,
73 "metric": r"Metric:(\d+)",
74 "mtu": r"MTU:(\d+)",
75@@ -227,19 +227,19 @@
76
77 fraction = r"\d+(/\d+)?"
78 numeric = r"[\d\.]+"
79- numeric_with_unit = r"%s( %s)?" % (numeric, Command.alpha_numeric)
80+ numeric_with_unit = r"%s( %s)?" % (numeric, Command.non_space)
81
82 output_patterns = {
83 "access_point": r"Access Point: (.*)",
84 "bit_rate": r"Bit Rate[=:](%s)/s" % numeric_with_unit,
85- "channel": r"Channel=(%s)" % Command.alpha_numeric,
86+ "channel": r"Channel=(%s)" % Command.non_space,
87 "essid": r"ESSID:\"?([^\"]+)\"?",
88 "fragment_thr": r"Fragment thr:(\w+)",
89 "frequency": r"Frequency:(%s)" % numeric_with_unit,
90 "invalid_misc": r"Invalid misc:(\d+)",
91 "link_quality": r"Link Quality[=:](%s)" % fraction,
92 "missed_beacon": r"Missed beacon:(\d+)",
93- "mode": r"Mode:(%s)" % Command.alpha_numeric,
94+ "mode": r"Mode:(%s)" % Command.non_space,
95 "noise_level": r"Noise level[=:](%s)" % numeric_with_unit,
96 "power_management": r"Power Management:(.*)",
97 "retry_limit": r"Retry limit:(\w+)",
98@@ -384,7 +384,7 @@
99 return ret
100
101 def count_0_bits(self):
102- num = long(self.binary)
103+ num = int(self.binary)
104 if num < 0:
105 raise ValueError("Only positive Numbers please: %s" % (num))
106 ret = 0
107@@ -407,7 +407,7 @@
108 return "%s/%s" % (self.address, self.prefix)
109
110 def _check_netmask(self, masklen):
111- num = long(self.netmask.binary)
112+ num = int(self.netmask.binary)
113 bits = masklen
114
115 # remove zero bits at the end

Subscribers

People subscribed via source and target branches