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

Proposed by Steffen Allner
Status: Merged
Approved by: Eric Snow
Approved revision: 980
Merged at revision: 980
Proposed branch: lp:~gocept/landscape-client/py3-watchdog
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~gocept/landscape-client/py3-broker-exchange
Diff against target: 119 lines (+18/-22)
4 files modified
landscape/tests/test_watchdog.py (+5/-8)
landscape/user/tests/test_changes.py (+9/-13)
landscape/watchdog.py (+3/-1)
py3_ready_tests (+1/-0)
To merge this branch: bzr merge lp:~gocept/landscape-client/py3-watchdog
Reviewer Review Type Date Requested Status
🤖 Landscape Builder test results Approve
Daniel Havlik (community) Approve
Eric Snow (community) Approve
Alberto Donato (community) Approve
Review via email: mp+321073@code.launchpad.net

Commit message

This is the Python 3 port of landscape.watchdog.

The key change is moving from the builtin filter(), which changed in Python 3, to a list comprehension.

Description of the change

This MP fixes the tests for landscape.watchdog module, which were mainly broken by a behaviour change in the built in filter() function. It now returned a not so well iterable, which did not yield anything in some loops, but a list comprehension for 3 items is acceptable, I suppose.

Additionally, I removed all assertItemsEqual() in the project, which implies the dependency on the py3-broker-exchange branch.

Some smaller test fixes concerning bytes have been necessary as well.

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 check
Result: Success
Revno: 978
Branch: lp:~gocept/landscape-client/py3-watchdog
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3786/

review: Approve (test results)
Revision history for this message
Alberto Donato (ack) wrote :

+1

Just a nit inline

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

I added more explicit variable names, but see the reason inline.

Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

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

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

LGTM

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

+1

review: Approve
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
Download full text (191.3 KiB)

The attempt to merge lp:~gocept/landscape-client/py3-watchdog into lp:landscape-client failed. Below is the output from the failed tests.

sudo apt -y install python-twisted-core python-distutils-extra python-mock python-configobj python-passlib
Reading package lists...
Building dependency tree...
Reading state information...
python-configobj is already the newest version (5.0.6-2).
python-configobj set to manually installed.
python-mock is already the newest version (1.3.0-2.1ubuntu1).
python-passlib is already the newest version (1.6.5-4).
python-twisted-core is already the newest version (16.0.0-1).
python-distutils-extra is already the newest version (2.39-1).
The following packages were automatically installed and are no longer required:
  golang-check.v1-dev golang-context-dev golang-github-gorilla-mux-dev
  golang-yaml.v2-dev linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic
  linux-image-4.4.0-64-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.
sudo apt -y install python3-twisted python3-distutils-extra python3-mock python3-configobj python3-passlib
Reading package lists...
Building dependency tree...
Reading state information...
python3-configobj is already the newest version (5.0.6-2).
python3-twisted is already the newest version (16.0.0-1).
python3-distutils-extra is already the newest version (2.39-1).
python3-mock is already the newest version (1.3.0-2.1ubuntu1).
python3-passlib is already the newest version (1.6.5-4).
The following packages were automatically installed and are no longer required:
  golang-check.v1-dev golang-context-dev golang-github-gorilla-mux-dev
  golang-yaml.v2-dev linux-headers-4.4.0-64 linux-headers-4.4.0-64-generic
  linux-image-4.4.0-64-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.
python setup.py build_ext -i
running build_ext
python3 setup.py build_ext -i
running build_ext
LC_ALL=C trial --unclean-warnings -j4 landscape
Running 2179 tests.
landscape.broker.tests.test_amp
  RemoteBrokerTest
    test_call_if_accepted_with_not_accepted ... [OK]
    test_fire_event ... [OK]
    test_get_accepted_message_types ... [OK]
    test_get_server_uuid ... [OK]
    test_is_message_pending ... [OK]
    test_listen_events ... [OK]
    test_call_if_accepted ... [OK]
    test_call_on_events ... [OK]
    test_method_call_error ... [OK]
    test_register_client ... [OK]
    test_ping ... [OK]
    test_register_client_accepted_message_type ... [OK]
    test_send_message ... [OK]
    test_reload_configuration ... ...

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

Looks like there was a timeout issue. I'll try it again.

Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Attempt to merge into lp:landscape-client failed due to conflicts:

text conflict in py3_ready_tests

Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

No approved revision specified.

980. By Steffen Allner

Backmerge from trunk

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

I resolved the conflict.

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: 980
Branch: lp:~gocept/landscape-client/py3-watchdog
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3800/

review: Approve (test results)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/tests/test_watchdog.py'
2--- landscape/tests/test_watchdog.py 2017-03-13 08:51:36 +0000
3+++ landscape/tests/test_watchdog.py 2017-03-28 18:33:15 +0000
4@@ -11,6 +11,7 @@
5 from twisted.internet import reactor
6 from twisted.python.fakepwd import UserDatabase
7
8+from landscape.lib.fs import read_text_file
9 from landscape.tests.clock import Clock
10 from landscape.tests.helpers import (
11 LandscapeTest, EnvironSaverHelper, FakeBrokerServiceHelper)
12@@ -25,9 +26,6 @@
13
14 import landscape.watchdog
15
16-from unittest import skipIf
17-from twisted.python.compat import _PY3
18-
19
20 class StubDaemon(object):
21 program = "program-name"
22@@ -800,7 +798,7 @@
23
24 self.assertTrue("Can't keep landscape-broker running." in
25 self.logfile.getvalue())
26- self.assertItemsEqual([True], stopped)
27+ self.assertCountEqual([True], stopped)
28 reactor.stop = stop[0]
29
30 result = Deferred()
31@@ -844,7 +842,7 @@
32
33 self.assertTrue("Can't keep landscape-broker running." in
34 self.logfile.getvalue())
35- self.assertItemsEqual([True], stopped)
36+ self.assertCountEqual([True], stopped)
37 reactor.stop = stop[0]
38
39 result = Deferred()
40@@ -950,7 +948,6 @@
41 mock.ANY, mock.ANY, args=mock.ANY, env=mock.ANY, uid=None,
42 gid=None)
43
44- @skipIf(_PY3, 'Takes long with Python3, probably unclean Reactor')
45 def test_request_exit(self):
46 """The request_exit() method calls exit() on the broker process."""
47
48@@ -973,8 +970,8 @@
49 self.daemon.request_exit()
50
51 def got_result(result):
52- self.assertEqual(result, "")
53- self.assertEqual(open(output_filename).read(), "CALLED")
54+ self.assertEqual(result, b"")
55+ self.assertEqual(read_text_file(output_filename), "CALLED")
56
57 return process_result.addCallback(got_result)
58
59
60=== modified file 'landscape/user/tests/test_changes.py'
61--- landscape/user/tests/test_changes.py 2017-03-22 14:56:26 +0000
62+++ landscape/user/tests/test_changes.py 2017-03-28 18:33:15 +0000
63@@ -1,5 +1,3 @@
64-from twisted.python.compat import _PY3
65-
66 from landscape.lib.persist import Persist
67 from landscape.user.changes import UserChanges
68 from landscape.user.tests.helpers import FakeUserInfo, FakeUserProvider
69@@ -292,14 +290,12 @@
70 groups.append(("sales", "x", 70, ["bo"]))
71 # Remove user "jdoe"
72 users.pop(0)
73- if _PY3:
74- assertion = self.assertCountEqual
75- else:
76- assertion = self.assertItemsEqual
77- assertion(changes.create_diff(),
78- {"create-groups": [{"gid": 50, "name": "developers"},
79- {"gid": 70, "name": "sales"}],
80- "delete-users": ["jdoe"],
81- "delete-groups": ["webdev"],
82- "create-group-members": {"developers": ["bo"],
83- "sales": ["bo"]}})
84+
85+ self.assertCountEqual(
86+ changes.create_diff(),
87+ {"create-groups": [{"gid": 50, "name": "developers"},
88+ {"gid": 70, "name": "sales"}],
89+ "delete-users": ["jdoe"],
90+ "delete-groups": ["webdev"],
91+ "create-group-members": {"developers": ["bo"],
92+ "sales": ["bo"]}})
93
94=== modified file 'landscape/watchdog.py'
95--- landscape/watchdog.py 2017-01-19 08:34:52 +0000
96+++ landscape/watchdog.py 2017-03-28 18:33:15 +0000
97@@ -339,7 +339,9 @@
98 self.broker = broker
99 self.monitor = monitor
100 self.manager = manager
101- self.daemons = filter(None, [self.broker, self.monitor, self.manager])
102+ self.daemons = [daemon
103+ for daemon in [self.broker, self.monitor, self.manager]
104+ if daemon]
105 self.reactor = reactor
106 self._checking = None
107 self._stopping = False
108
109=== modified file 'py3_ready_tests'
110--- py3_ready_tests 2017-03-28 17:05:21 +0000
111+++ py3_ready_tests 2017-03-28 18:33:15 +0000
112@@ -2,6 +2,7 @@
113 landscape.sysinfo.tests
114 landscape.user.tests
115 landscape.package.tests
116+landscape.tests.test_watchdog
117
118 landscape.tests.test_configuration
119 landscape.tests.test_schema

Subscribers

People subscribed via source and target branches

to all changes: