Merge lp:~gocept/landscape-client/py3-monitor-swiftusage into lp:~landscape/landscape-client/trunk

Proposed by Steffen Allner
Status: Merged
Approved by: Eric Snow
Approved revision: 1003
Merged at revision: 997
Proposed branch: lp:~gocept/landscape-client/py3-monitor-swiftusage
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~gocept/landscape-client/py3-monitor-processorinfo
Diff against target: 191 lines (+23/-40)
5 files modified
Makefile (+2/-3)
landscape/lib/persist.py (+18/-16)
landscape/monitor/swiftusage.py (+1/-1)
landscape/monitor/tests/test_swiftusage.py (+2/-1)
py3_ready_tests (+0/-19)
To merge this branch: bzr merge lp:~gocept/landscape-client/py3-monitor-swiftusage
Reviewer Review Type Date Requested Status
Eric Snow (community) Approve
Daniel Havlik (community) Approve
🤖 Landscape Builder test results Approve
Landscape Pending
Review via email: mp+321454@code.launchpad.net

Commit message

This is the Py3 port of landscape.monitor.swiftusage.

We make a few bytes/unicode fixes and address a test ordering issue.

This patch also completes the fundamental Py3 port of the Landscape client. So all tests are now run under both Python 2 and 3, rather than just the selection of tests that had been ported thus far. Further work remains to address remaining (untested) Python 3 incompatibilities.

Description of the change

This MP is the last one to port landscape.monitor to Python 3. In l.m.swiftusage an encoding was done, probably to ensure bytes as filename for the backend in the (Rooted)Persist. As these are normal files on the filesystem it should not be a problem to have it as unicodes.

Additionally the whole test suite is now running on Python 2 and 3 at the same time.
Two test in test_swiftusage are skipped because python-swift is not yet ported to Python 3.

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make ci-check
Result: Fail
Revno: 1002
Branch: lp:~gocept/landscape-client/py3-monitor-swiftusage
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3824/

review: Needs Fixing (test results)
1003. By Steffen Allner

Stabilize order by sorting.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make ci-check
Result: Success
Revno: 1003
Branch: lp:~gocept/landscape-client/py3-monitor-swiftusage
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3825/

review: Approve (test results)
Revision history for this message
Daniel Havlik (nilo) wrote :

+1

review: Approve
Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

LGTM

review: Approve
Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

...and nice work on getting all the landscape-client tests passing under Python 3!!!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2017-03-26 04:07:33 +0000
3+++ Makefile 2017-03-30 14:14:06 +0000
4@@ -5,9 +5,8 @@
5 TRIAL_ARGS ?=
6 TEST_COMMAND_PY2 = trial --unclean-warnings $(TRIAL_ARGS) landscape
7 TEST_COMMAND_PY3 = trial3 --unclean-warnings $(TRIAL_ARGS) landscape
8-READY_FILE := py3_ready_tests
9-PY3_READY := `cat $(READY_FILE)`
10-TEST_COMMAND_PY3_READY = TRIAL_ARGS= trial3 --unclean-warnings $(PY3_READY)
11+# trial3 does not support threading via `-j` at the moment
12+TEST_COMMAND_PY3_READY = TRIAL_ARGS= trial3 --unclean-warnings landscape
13 UBUNTU_RELEASE := $(shell lsb_release -cs)
14 # version in the code is authoritative
15 # Use := here, not =, it's really important, otherwise UPSTREAM_VERSION
16
17=== modified file 'landscape/lib/persist.py'
18--- landscape/lib/persist.py 2017-03-17 09:26:45 +0000
19+++ landscape/lib/persist.py 2017-03-30 14:14:06 +0000
20@@ -23,6 +23,8 @@
21 import copy
22 import re
23
24+from twisted.python.compat import StringType # Py2: basestring, Py3: str
25+
26
27 __all__ = ["Persist", "PickleBackend", "BPickleBackend",
28 "path_string_to_tuple", "path_tuple_to_string", "RootedPersist",
29@@ -201,7 +203,7 @@
30 return newobj
31
32 def _getvalue(self, path, soft=False, hard=False, weak=False):
33- if type(path) is str:
34+ if isinstance(path, StringType):
35 path = path_string_to_tuple(path)
36 marker = NOTHING
37 if soft:
38@@ -247,7 +249,7 @@
39
40 def set(self, path, value, soft=False, weak=False):
41 assert path
42- if type(path) is str:
43+ if isinstance(path, StringType):
44 path = path_string_to_tuple(path)
45 if soft:
46 map = self._softmap
47@@ -261,7 +263,7 @@
48
49 def add(self, path, value, unique=False, soft=False, weak=False):
50 assert path
51- if type(path) is str:
52+ if isinstance(path, StringType):
53 path = path_string_to_tuple(path)
54 if soft:
55 map = self._softmap
56@@ -280,7 +282,7 @@
57
58 def remove(self, path, value=NOTHING, soft=False, weak=False):
59 assert path
60- if type(path) is str:
61+ if isinstance(path, StringType):
62 path = path_string_to_tuple(path)
63 if soft:
64 map = self._softmap
65@@ -318,9 +320,9 @@
66 def move(self, oldpath, newpath, soft=False, weak=False):
67 if not (soft or weak):
68 self.assert_writable()
69- if type(oldpath) is str:
70+ if isinstance(oldpath, StringType):
71 oldpath = path_string_to_tuple(oldpath)
72- if type(newpath) is str:
73+ if isinstance(newpath, StringType):
74 newpath = path_string_to_tuple(newpath)
75 result = False
76 marker = NOTHING
77@@ -358,7 +360,7 @@
78 will be used as root of this L{RootedPersist}.
79 """
80 self.parent = parent
81- if type(root) is str:
82+ if isinstance(root, StringType):
83 self.root = path_string_to_tuple(root)
84 else:
85 self.root = root
86@@ -370,45 +372,45 @@
87 self.parent.assert_writable()
88
89 def has(self, path, value=NOTHING, soft=False, hard=False, weak=False):
90- if type(path) is str:
91+ if isinstance(path, StringType):
92 path = path_string_to_tuple(path)
93 return self.parent.has(self.root + path, value, soft, hard, weak)
94
95 def keys(self, path, soft=False, hard=False, weak=False):
96- if type(path) is str:
97+ if isinstance(path, StringType):
98 path = path_string_to_tuple(path)
99 return self.parent.keys(self.root + path, soft, hard, weak)
100
101 def get(self, path, default=None, soft=False, hard=False, weak=False):
102- if type(path) is str:
103+ if isinstance(path, StringType):
104 path = path_string_to_tuple(path)
105 return self.parent.get(self.root + path, default, soft, hard, weak)
106
107 def set(self, path, value, soft=False, weak=False):
108- if type(path) is str:
109+ if isinstance(path, StringType):
110 path = path_string_to_tuple(path)
111 return self.parent.set(self.root + path, value, soft, weak)
112
113 def add(self, path, value, unique=False, soft=False, weak=False):
114- if type(path) is str:
115+ if isinstance(path, StringType):
116 path = path_string_to_tuple(path)
117 return self.parent.add(self.root + path, value, unique, soft, weak)
118
119 def remove(self, path, value=NOTHING, soft=False, weak=False):
120- if type(path) is str:
121+ if isinstance(path, StringType):
122 path = path_string_to_tuple(path)
123 return self.parent.remove(self.root + path, value, soft, weak)
124
125 def move(self, oldpath, newpath, soft=False, weak=False):
126- if type(oldpath) is str:
127+ if isinstance(oldpath, StringType):
128 oldpath = path_string_to_tuple(oldpath)
129- if type(newpath) is str:
130+ if isinstance(newpath, StringType):
131 newpath = path_string_to_tuple(newpath)
132 return self.parent.move(self.root + oldpath, self.root + newpath,
133 soft, weak)
134
135 def root_at(self, path):
136- if type(path) is str:
137+ if isinstance(path, StringType):
138 path = path_string_to_tuple(path)
139 return self.parent.root_at(self.root + path)
140
141
142=== modified file 'landscape/monitor/swiftusage.py'
143--- landscape/monitor/swiftusage.py 2016-07-20 20:10:32 +0000
144+++ landscape/monitor/swiftusage.py 2017-03-30 14:14:06 +0000
145@@ -135,7 +135,7 @@
146 if not usage["mounted"]:
147 continue
148
149- device = usage["device"].encode("utf-8")
150+ device = usage["device"]
151 devices.add(device)
152
153 step_values = []
154
155=== modified file 'landscape/monitor/tests/test_swiftusage.py'
156--- landscape/monitor/tests/test_swiftusage.py 2016-07-20 20:10:32 +0000
157+++ landscape/monitor/tests/test_swiftusage.py 2017-03-30 14:14:06 +0000
158@@ -186,7 +186,8 @@
159 [(30, "vdb", 100000, 80000, 20000),
160 (30, "vdd", 200000, 10000, 190000)],
161 self.plugin._swift_usage_points)
162- self.assertEqual(["vdb", "vdd"], self.plugin._persist.get("devices"))
163+ self.assertEqual(
164+ ["vdb", "vdd"], sorted(self.plugin._persist.get("devices")))
165 self.assertNotIn("vdc", self.plugin._persist.get("usage"))
166
167 def test_message_remove_disappeared_devices(self):
168
169=== removed file 'py3_ready_tests'
170--- py3_ready_tests 2017-03-30 14:14:06 +0000
171+++ py3_ready_tests 1970-01-01 00:00:00 +0000
172@@ -1,19 +0,0 @@
173-landscape.lib.tests
174-landscape.sysinfo.tests
175-landscape.user.tests
176-landscape.broker.tests
177-landscape.package.tests
178-landscape.manager.tests
179-landscape.tests
180-
181-
182-landscape.monitor.tests.test_activeprocessinfo
183-landscape.monitor.tests.test_computeruptime
184-landscape.monitor.tests.test_mountinfo
185-landscape.monitor.tests.test_computerinfo
186-landscape.monitor.tests.test_loadaverage
187-landscape.monitor.tests.test_networkdevice
188-landscape.monitor.tests.test_networkactivity
189-landscape.monitor.tests.test_packagemonitor
190-landscape.monitor.tests.test_aptpreferences
191-landscape.monitor.tests.test_processorinfo

Subscribers

People subscribed via source and target branches

to all changes: