Merge lp:~gocept/landscape-client/py3-manager-shutdownmanager-aptsources into lp:~landscape/landscape-client/trunk

Proposed by Steffen Allner
Status: Merged
Approved by: Eric Snow
Approved revision: 987
Merged at revision: 986
Proposed branch: lp:~gocept/landscape-client/py3-manager-shutdownmanager-aptsources
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~gocept/landscape-client/py3-manager-usermanager
Diff against target: 88 lines (+12/-8)
4 files modified
landscape/manager/aptsources.py (+1/-1)
landscape/manager/tests/test_aptsources.py (+7/-3)
landscape/manager/tests/test_shutdownmanager.py (+2/-2)
py3_ready_tests (+2/-2)
To merge this branch: bzr merge lp:~gocept/landscape-client/py3-manager-shutdownmanager-aptsources
Reviewer Review Type Date Requested Status
Eric Snow (community) Approve
Michael Howitz (community) Approve
🤖 Landscape Builder test results Approve
Adam Collard (community) Needs Fixing
Review via email: mp+321253@code.launchpad.net

Commit message

This is the py3 port of landscape.manager.shutdownmanager and l.m.aptsources.

There are a few bytes/unicode changes here. Also we solve some errback shenanigans with a temporary fix. A more correct fix is forthcoming.

Description of the change

This MP considers small changes for landscape.manager.shutdownmanager and l.m.aptsources.

The API version is considered to be bytes in the message schema.
The behavior of exceptions changed slightly with Python 3, i.e. to get the parameters passed during raise, we have to access execption.args as the exception on its own is not iterable anymore.

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: Success
Revno: 986
Branch: lp:~gocept/landscape-client/py3-manager-shutdownmanager-aptsources
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3806/

review: Approve (test results)
Revision history for this message
Adam Collard (adam-collard) :
review: Needs Fixing
987. By Steffen Allner

Use an explicitly defined exception in the test to be not dependent on potential changes of errors in standard library.

Revision history for this message
Steffen Allner (sallner) wrote :

Good points, I will address those.

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: 987
Branch: lp:~gocept/landscape-client/py3-manager-shutdownmanager-aptsources
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3814/

review: Approve (test results)
Revision history for this message
Michael Howitz (mh-gocept) wrote :

LGTM.

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

LGTM

Thanks for addressing Adam's comments and for opening that card about the errbacks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/manager/aptsources.py'
2--- landscape/manager/aptsources.py 2017-01-19 08:34:52 +0000
3+++ landscape/manager/aptsources.py 2017-03-29 11:48:55 +0000
4@@ -47,7 +47,7 @@
5 Turn a signaled process command to a C{ProcessError}.
6 """
7 if not failure.check(ProcessError):
8- out, err, signal = failure.value
9+ out, err, signal = failure.value.args
10 raise ProcessError("%s\n%s" % (out, err))
11 else:
12 return failure
13
14=== modified file 'landscape/manager/tests/test_aptsources.py'
15--- landscape/manager/tests/test_aptsources.py 2017-01-19 08:34:52 +0000
16+++ landscape/manager/tests/test_aptsources.py 2017-03-29 11:48:55 +0000
17@@ -3,6 +3,7 @@
18 import mock
19
20 from twisted.internet.defer import Deferred, succeed
21+from twisted.python.compat import _PY3
22
23 from landscape.manager.aptsources import AptSources
24 from landscape.manager.plugin import SUCCEEDED, FAILED
25@@ -176,7 +177,10 @@
26 If a failure happens during the manipulation of sources, the activity
27 is reported as FAILED with the error message.
28 """
29- self.sourceslist.SOURCES_LIST = "/doesntexist"
30+ def buggy_source_handler(*args):
31+ raise RuntimeError("foo")
32+
33+ self.sourceslist._handle_sources = buggy_source_handler
34
35 self.manager.dispatch_message(
36 {"type": "apt-sources-replace",
37@@ -184,7 +188,7 @@
38 "gpg-keys": [],
39 "operation-id": 1})
40
41- msg = "OSError: [Errno 2] No such file or directory: '/doesntexist'"
42+ msg = "RuntimeError: foo"
43 service = self.broker_service
44 self.assertMessages(service.message_store.get_pending_messages(),
45 [{"type": "operation-result",
46@@ -352,7 +356,7 @@
47 deferred = Deferred()
48
49 def _run_process(command, args, env={}, path=None, uid=None, gid=None):
50- deferred.errback(("nok", "some error", 1))
51+ deferred.errback(RuntimeError("nok", "some error", 1))
52 return deferred
53
54 self.sourceslist._run_process = _run_process
55
56=== modified file 'landscape/manager/tests/test_shutdownmanager.py'
57--- landscape/manager/tests/test_shutdownmanager.py 2014-08-28 09:47:21 +0000
58+++ landscape/manager/tests/test_shutdownmanager.py 2017-03-29 11:48:55 +0000
59@@ -43,7 +43,7 @@
60 self.assertTrue(self.broker_service.exchanger.is_urgent())
61 self.assertEqual(
62 self.broker_service.message_store.get_pending_messages(),
63- [{"type": "operation-result", "api": "3.2",
64+ [{"type": "operation-result", "api": b"3.2",
65 "operation-id": 100, "timestamp": 10, "status": SUCCEEDED,
66 "result-text": u"Data may arrive in batches."}])
67
68@@ -83,7 +83,7 @@
69 self.assertTrue(self.broker_service.exchanger.is_urgent())
70 self.assertEqual(
71 self.broker_service.message_store.get_pending_messages(),
72- [{"type": "operation-result", "api": "3.2",
73+ [{"type": "operation-result", "api": b"3.2",
74 "operation-id": 100, "timestamp": 0, "status": FAILED,
75 "result-text": u"Failure text is reported."}])
76
77
78=== modified file 'py3_ready_tests'
79--- py3_ready_tests 2017-03-29 11:48:55 +0000
80+++ py3_ready_tests 2017-03-29 11:48:55 +0000
81@@ -11,5 +11,5 @@
82 landscape.manager.tests.test_scriptexecution
83 landscape.manager.tests.test_customgraph
84 landscape.manager.tests.test_usermanager
85-
86-
87+landscape.manager.tests.test_shutdownmanager
88+landscape.manager.tests.test_aptsources

Subscribers

People subscribed via source and target branches

to all changes: