Status: | Merged |
---|---|
Approved by: | Omer Akram |
Approved revision: | 598 |
Merged at revision: | 592 |
Proposed branch: | lp:~dobey/autopilot/ual-break |
Merge into: | lp:autopilot |
Diff against target: |
177 lines (+42/-37) 3 files modified
autopilot/application/_launcher.py (+20/-14) autopilot/tests/unit/test_application_launcher.py (+18/-21) debian/control (+4/-2) |
To merge this branch: | bzr merge lp:~dobey/autopilot/ual-break |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Omer Akram (community) | Approve | ||
Santiago Baldassin (community) | Approve | ||
platform-qa-bot | continuous-integration | Approve | |
Review via email: mp+318667@code.launchpad.net |
Commit message
Update dependency for ubuntu-app-launch API break.
Get logs directly from systemd journal now, for ual launched apps.
Description of the change
platform-qa-bot (platform-qa-bot) wrote : | # |
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:593
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:594
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:595
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:596
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:597
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:598
https:/
Executed test runs:
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Santiago Baldassin (sbaldassin) wrote : | # |
Code looks good to me
Preview Diff
1 | === modified file 'autopilot/application/_launcher.py' | |||
2 | --- autopilot/application/_launcher.py 2015-12-08 21:42:14 +0000 | |||
3 | +++ autopilot/application/_launcher.py 2017-03-01 23:12:03 +0000 | |||
4 | @@ -1,7 +1,7 @@ | |||
5 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
6 | 2 | # | 2 | # |
7 | 3 | # Autopilot Functional Test Tool | 3 | # Autopilot Functional Test Tool |
9 | 4 | # Copyright (C) 2013 Canonical | 4 | # Copyright (C) 2013,2017 Canonical |
10 | 5 | # | 5 | # |
11 | 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
12 | 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
13 | @@ -20,21 +20,20 @@ | |||
14 | 20 | """Base module for application launchers.""" | 20 | """Base module for application launchers.""" |
15 | 21 | 21 | ||
16 | 22 | import fixtures | 22 | import fixtures |
18 | 23 | from gi.repository import GLib | 23 | from gi import require_version |
19 | 24 | try: | 24 | try: |
21 | 25 | from gi import require_version | 25 | require_version('UbuntuAppLaunch', '3') |
22 | 26 | except ValueError: | ||
23 | 26 | require_version('UbuntuAppLaunch', '2') | 27 | require_version('UbuntuAppLaunch', '2') |
28 | 27 | from gi.repository import UbuntuAppLaunch | 28 | from gi.repository import GLib, UbuntuAppLaunch |
29 | 28 | except ImportError: | 29 | |
26 | 29 | # Note: the renamed package is not in Trusty. | ||
27 | 30 | from gi.repository import UpstartAppLaunch as UbuntuAppLaunch | ||
30 | 31 | import json | 30 | import json |
31 | 32 | import logging | 31 | import logging |
32 | 33 | import os | 32 | import os |
33 | 34 | import psutil | 33 | import psutil |
34 | 35 | import subprocess | 34 | import subprocess |
35 | 36 | import signal | 35 | import signal |
37 | 37 | from testtools.content import content_from_file | 36 | from systemd import journal |
38 | 38 | from autopilot.utilities import safe_text_content | 37 | from autopilot.utilities import safe_text_content |
39 | 39 | 38 | ||
40 | 40 | from autopilot._timeout import Timeout | 39 | from autopilot._timeout import Timeout |
41 | @@ -186,13 +185,20 @@ | |||
42 | 186 | self.addCleanup(self._stop_application, app_id) | 185 | self.addCleanup(self._stop_application, app_id) |
43 | 187 | self.addCleanup(self._attach_application_log, app_id) | 186 | self.addCleanup(self._attach_application_log, app_id) |
44 | 188 | 187 | ||
45 | 188 | @staticmethod | ||
46 | 189 | def _get_user_unit_match(app_id): | ||
47 | 190 | return 'ubuntu-app-launch-*-%s-*.service' % app_id | ||
48 | 191 | |||
49 | 189 | def _attach_application_log(self, app_id): | 192 | def _attach_application_log(self, app_id): |
56 | 190 | log_path = UbuntuAppLaunch.application_log_path(app_id) | 193 | j = journal.Reader() |
57 | 191 | if log_path and os.path.exists(log_path): | 194 | j.log_level(journal.LOG_INFO) |
58 | 192 | self.caseAddDetail( | 195 | j.add_match(_SYSTEMD_USER_UNIT=self._get_user_unit_match(app_id)) |
59 | 193 | "Application Log (%s)" % app_id, | 196 | log_data = '' |
60 | 194 | content_from_file(log_path) | 197 | for i in j: |
61 | 195 | ) | 198 | log_data += str(i) + '\n' |
62 | 199 | if len(log_data) > 0: | ||
63 | 200 | self.caseAddDetail('Application Log (%s)' % app_id, | ||
64 | 201 | safe_text_content(log_data)) | ||
65 | 196 | 202 | ||
66 | 197 | def _stop_application(self, app_id): | 203 | def _stop_application(self, app_id): |
67 | 198 | state = {} | 204 | state = {} |
68 | 199 | 205 | ||
69 | === modified file 'autopilot/tests/unit/test_application_launcher.py' | |||
70 | --- autopilot/tests/unit/test_application_launcher.py 2014-07-22 02:30:19 +0000 | |||
71 | +++ autopilot/tests/unit/test_application_launcher.py 2017-03-01 23:12:03 +0000 | |||
72 | @@ -1,7 +1,7 @@ | |||
73 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
74 | 2 | # | 2 | # |
75 | 3 | # Autopilot Functional Test Tool | 3 | # Autopilot Functional Test Tool |
77 | 4 | # Copyright (C) 2013 Canonical | 4 | # Copyright (C) 2013,2017 Canonical |
78 | 5 | # | 5 | # |
79 | 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
80 | 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
81 | @@ -33,8 +33,7 @@ | |||
82 | 33 | raises, | 33 | raises, |
83 | 34 | ) | 34 | ) |
84 | 35 | from testtools.content import text_content | 35 | from testtools.content import text_content |
87 | 36 | import tempfile | 36 | from unittest.mock import MagicMock, Mock, patch |
86 | 37 | from unittest.mock import Mock, patch | ||
88 | 38 | 37 | ||
89 | 39 | from autopilot.application import ( | 38 | from autopilot.application import ( |
90 | 40 | ClickApplicationLauncher, | 39 | ClickApplicationLauncher, |
91 | @@ -782,32 +781,30 @@ | |||
92 | 782 | app_id = self.getUniqueString() | 781 | app_id = self.getUniqueString() |
93 | 783 | case_addDetail = Mock() | 782 | case_addDetail = Mock() |
94 | 784 | launcher = UpstartApplicationLauncher(case_addDetail) | 783 | launcher = UpstartApplicationLauncher(case_addDetail) |
97 | 785 | with patch.object(_l.UbuntuAppLaunch, 'application_log_path') as p: | 784 | j = MagicMock(spec=_l.journal.Reader) |
98 | 786 | p.return_value = None | 785 | with patch.object(_l.journal, 'Reader', return_value=j): |
99 | 787 | launcher._attach_application_log(app_id) | 786 | launcher._attach_application_log(app_id) |
102 | 788 | 787 | expected = launcher._get_user_unit_match(app_id) | |
103 | 789 | p.assert_called_once_with(app_id) | 788 | j.add_match.assert_called_once_with(_SYSTEMD_USER_UNIT=expected) |
104 | 790 | self.assertEqual(0, case_addDetail.call_count) | 789 | self.assertEqual(0, case_addDetail.call_count) |
105 | 791 | 790 | ||
107 | 792 | def test_attach_application_log_attaches_log_file(self): | 791 | def test_attach_application_log_attaches_log(self): |
108 | 793 | token = self.getUniqueString() | 792 | token = self.getUniqueString() |
109 | 794 | case_addDetail = Mock() | 793 | case_addDetail = Mock() |
110 | 795 | launcher = UpstartApplicationLauncher(case_addDetail) | 794 | launcher = UpstartApplicationLauncher(case_addDetail) |
111 | 796 | app_id = self.getUniqueString() | 795 | app_id = self.getUniqueString() |
118 | 797 | with tempfile.NamedTemporaryFile(mode='w') as f: | 796 | j = MagicMock(spec=_l.journal.Reader) |
119 | 798 | f.write(token) | 797 | j.__iter__ = lambda x: iter([token]) |
120 | 799 | f.flush() | 798 | with patch.object(_l.journal, 'Reader', return_value=j): |
121 | 800 | with patch.object(_l.UbuntuAppLaunch, 'application_log_path', | 799 | launcher._attach_application_log(app_id) |
116 | 801 | return_value=f.name): | ||
117 | 802 | launcher._attach_application_log(app_id) | ||
122 | 803 | 800 | ||
130 | 804 | self.assertEqual(1, case_addDetail.call_count) | 801 | self.assertEqual(1, case_addDetail.call_count) |
131 | 805 | content_name, content_obj = case_addDetail.call_args[0] | 802 | content_name, content_obj = case_addDetail.call_args[0] |
132 | 806 | self.assertEqual( | 803 | self.assertEqual( |
133 | 807 | "Application Log (%s)" % app_id, | 804 | "Application Log (%s)" % app_id, |
134 | 808 | content_name | 805 | content_name |
135 | 809 | ) | 806 | ) |
136 | 810 | self.assertThat(content_obj.as_text(), Contains(token)) | 807 | self.assertThat(content_obj.as_text(), Contains(token)) |
137 | 811 | 808 | ||
138 | 812 | def test_stop_adds_app_stopped_observer(self): | 809 | def test_stop_adds_app_stopped_observer(self): |
139 | 813 | mock_add_detail = Mock() | 810 | mock_add_detail = Mock() |
140 | 814 | 811 | ||
141 | === modified file 'debian/control' | |||
142 | --- debian/control 2017-03-01 21:54:53 +0000 | |||
143 | +++ debian/control 2017-03-01 23:12:03 +0000 | |||
144 | @@ -8,7 +8,7 @@ | |||
145 | 8 | dvipng, | 8 | dvipng, |
146 | 9 | gir1.2-gtk-3.0, | 9 | gir1.2-gtk-3.0, |
147 | 10 | gir1.2-ibus-1.0, | 10 | gir1.2-ibus-1.0, |
149 | 11 | gir1.2-ubuntu-app-launch-2 | gir1.2-upstart-app-launch-2, | 11 | gir1.2-ubuntu-app-launch-3 | gir1.2-ubuntu-app-launch-2, |
150 | 12 | graphviz, | 12 | graphviz, |
151 | 13 | libjs-jquery, | 13 | libjs-jquery, |
152 | 14 | libjs-underscore, | 14 | libjs-underscore, |
153 | @@ -27,6 +27,7 @@ | |||
154 | 27 | python3-setuptools, | 27 | python3-setuptools, |
155 | 28 | python3-sphinx, | 28 | python3-sphinx, |
156 | 29 | python3-subunit, | 29 | python3-subunit, |
157 | 30 | python3-systemd, | ||
158 | 30 | python3-testscenarios, | 31 | python3-testscenarios, |
159 | 31 | python3-testtools, | 32 | python3-testtools, |
160 | 32 | python3-tz, | 33 | python3-tz, |
161 | @@ -43,7 +44,7 @@ | |||
162 | 43 | 44 | ||
163 | 44 | Package: python3-autopilot | 45 | Package: python3-autopilot |
164 | 45 | Architecture: all | 46 | Architecture: all |
166 | 46 | Depends: gir1.2-ubuntu-app-launch-2 | gir1.2-upstart-app-launch-2, | 47 | Depends: gir1.2-ubuntu-app-launch-3 | gir1.2-ubuntu-app-launch-2, |
167 | 47 | libjs-jquery, | 48 | libjs-jquery, |
168 | 48 | libjs-underscore, | 49 | libjs-underscore, |
169 | 49 | mir-utils, | 50 | mir-utils, |
170 | @@ -57,6 +58,7 @@ | |||
171 | 57 | python3-pil, | 58 | python3-pil, |
172 | 58 | python3-psutil, | 59 | python3-psutil, |
173 | 59 | python3-subunit, | 60 | python3-subunit, |
174 | 61 | python3-systemd, | ||
175 | 60 | python3-testscenarios, | 62 | python3-testscenarios, |
176 | 61 | python3-testtools, | 63 | python3-testtools, |
177 | 62 | python3-tz, | 64 | python3-tz, |
FAILED: Continuous integration, rev:591 /platform- qa-jenkins. ubuntu. com/job/ autopilot- ci/161/ /platform- qa-jenkins. ubuntu. com/job/ build-xenial- amd64-package/ 518/console /platform- qa-jenkins. ubuntu. com/job/ build-xenial- i386-package/ 516/console /platform- qa-jenkins. ubuntu. com/job/ generic- update- mp/2019/ console
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild: /platform- qa-jenkins. ubuntu. com/job/ autopilot- ci/161/ rebuild
https:/