Merge lp:~canonical-platform-qa/ubuntu-ota-tests/dbus-upgrade into lp:ubuntu-ota-tests

Proposed by Leo Arias on 2015-03-17
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/ubuntu-ota-tests/dbus-upgrade
Merge into: lp:ubuntu-ota-tests
Prerequisite: lp:~canonical-platform-qa/ubuntu-ota-tests/apply-update
Diff against target: 291 lines (+136/-13)
12 files modified
.bzrignore (+2/-0)
README.rst (+1/-1)
debian/changelog (+1/-1)
debian/compat (+1/-0)
debian/control (+23/-0)
debian/rules (+11/-0)
debian/tests/control (+3/-3)
setup.py (+30/-0)
ubuntu_ota_tests/hooks.py (+17/-3)
ubuntu_ota_tests/reactors.py (+7/-1)
ubuntu_ota_tests/tests/test_basic_upgrade.py (+1/-3)
ubuntu_ota_tests/upgrade.py (+39/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-ota-tests/dbus-upgrade
Reviewer Review Type Date Requested Status
Canonical Platform QA Team 2015-03-17 Pending
Review via email: mp+253265@code.launchpad.net

This proposal supersedes a proposal from 2015-03-17.

This proposal has been superseded by a proposal from 2015-03-18.

To post a comment you must log in.
39. By Leo Arias on 2015-03-17

Removed the exit before the apply.

40. By Leo Arias on 2015-03-18

Check for update.

41. By Leo Arias on 2015-03-18

Merged with trunk. Added the download.

42. By Leo Arias on 2015-03-18

Disabled auto download.

43. By Leo Arias on 2015-03-18

Merged with prerequisite.

44. By Leo Arias on 2015-03-18

Added the missing quit.

45. By Leo Arias on 2015-03-18

Added the applied handler.

46. By Leo Arias on 2015-03-18

Do not cd into debian/tests

47. By Leo Arias on 2015-03-18

take into account when the python path is not set.

48. By Leo Arias on 2015-03-18

Use cli for system image 2.5.

49. By Leo Arias on 2015-03-19

Cleaned the test.

50. By Leo Arias on 2015-03-19

Merged with prerequisite.

51. By Leo Arias on 2015-03-19

We no longer require 3.0.

52. By Leo Arias on 2015-03-19

Removed the duplicated vars.

53. By Leo Arias on 2015-03-19

Fixed the reqs.

54. By Leo Arias on 2015-03-19

Try to upgrade with dbus in 3.0, use cli in 2.5

55. By Leo Arias on 2015-03-19

Moved the check to the upgrade.

56. By Leo Arias on 2015-03-19

Added the quit on the applied reactor.

57. By Federico Gimenez on 2015-03-23

Fixes from review; added ota-dbus-upgrade test with temporary workarounds for si 3.0; apply noop selftest skipped if there's a upgrade available (wouldn't be a noop)

58. By Federico Gimenez on 2015-03-23

test file

59. By Federico Gimenez on 2015-03-23

moved si 3.0 setup to adt-run

60. By Federico Gimenez on 2015-03-24

Added sleep after Popen call; changed suggested adt-run command to not copy the system-image cfg files once copied the first time

61. By Federico Gimenez on 2015-03-24

comment about sleep for Popen

62. By Federico Gimenez on 2015-03-25

merged trunk

63. By Federico Gimenez on 2015-03-25

Copying config files to custom config directory

64. By Federico Gimenez on 2015-03-25

skip test_check_update if there is an update available

65. By Federico Gimenez on 2015-03-25

Disabled upgrade assertion for subtask

66. By Federico Gimenez on 2015-03-26

Added bug references for test command comment and the required fix for apply upgrade

67. By Federico Gimenez on 2015-03-26

flake8

68. By Federico Gimenez on 2015-03-26

Better log message

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2015-03-18 19:13:46 +0000
4@@ -0,0 +1,2 @@
5+ubuntu_ota_tests.egg-info
6+dist
7
8=== modified file 'README.rst'
9--- README.rst 2015-03-11 16:31:35 +0000
10+++ README.rst 2015-03-18 19:13:46 +0000
11@@ -2,6 +2,6 @@
12
13 The included example test can be run like so::
14
15- adt-run -B --unbuilt-tree=. --- ssh -s adb
16+ adt-run --unbuilt-tree=. --- ssh -s adb
17
18 All this example does is run and exits 0.
19
20=== modified file 'debian/changelog'
21--- debian/changelog 2015-03-03 01:59:45 +0000
22+++ debian/changelog 2015-03-18 19:13:46 +0000
23@@ -1,4 +1,4 @@
24-ubuntu-ota-tests (1.0-1) UNRELEASED; urgency=medium
25+ubuntu-ota-tests (1.0) UNRELEASED; urgency=medium
26
27 * Initial release.
28
29
30=== added file 'debian/compat'
31--- debian/compat 1970-01-01 00:00:00 +0000
32+++ debian/compat 2015-03-18 19:13:46 +0000
33@@ -0,0 +1,1 @@
34+9
35
36=== modified file 'debian/control'
37--- debian/control 2015-03-08 17:34:00 +0000
38+++ debian/control 2015-03-18 19:13:46 +0000
39@@ -1,1 +1,24 @@
40+Source: ubuntu-ota-tests
41+Maintainer: QA Team <qa-team@lists.canonical.com>
42 Homepage: http://launchpad.net/ubuntu-ota-tests
43+Section: python
44+X-Python3-Version: >= 3.4
45+Priority: optional
46+Build-Depends: debhelper (>= 9),
47+ dh-python,
48+ python3-all (>= 3.3),
49+ python3-setuptools
50+Standards-Version: 3.9.6
51+XS-Testsuite: autopkgtest
52+Vcs-Bzr: https://code.launchpad.net/~canonical-platform-qa/ubuntu-ota-tests/trunk
53+Vcs-Browser: http://bazaar.launchpad.net/~canonical-platform-qa/ubuntu-ota-tests/trunk/files
54+
55+Package: python3-ubuntu-ota-tests
56+Architecture: all
57+Depends: python3-autopilot,
58+ system-image-common,
59+ ${misc:Depends},
60+ ${python3:Depends}
61+Description: support for OTA tests
62+ This package provides a Python 3 library that can be used as a DEP-8
63+ dependency for testing OTA upgrades.
64
65=== added file 'debian/rules'
66--- debian/rules 1970-01-01 00:00:00 +0000
67+++ debian/rules 2015-03-18 19:13:46 +0000
68@@ -0,0 +1,11 @@
69+#!/usr/bin/make -f
70+
71+DH_VERBOSE=1
72+#DEB_BUILD_OPTIONS=nocheck
73+
74+%:
75+ dh $@ --with python3 --buildsystem=pybuild
76+
77+# To avoid circular Build-Depends, do not run the package's test suite at
78+# build time. Instead, they will get run via DEP-8.
79+override_dh_auto_test:
80
81=== renamed file 'debian/tests/check_for_update' => 'debian/tests/check-for-update'
82=== modified file 'debian/tests/control'
83--- debian/tests/control 2015-03-17 15:28:51 +0000
84+++ debian/tests/control 2015-03-18 19:13:46 +0000
85@@ -1,4 +1,4 @@
86-Tests: ota_selftests
87+Tests: ota-selftests
88 Restrictions: allow-stderr
89 Depends: python3-autopilot,
90 python3-coverage,
91@@ -9,9 +9,9 @@
92 Restrictions: needs-root allow-stderr
93 Depends: python3-autopilot,
94 python3-psutil,
95- system-image-cli
96+ system-image-dbus (>=3.0)
97
98-Tests: check_for_update
99+Tests: check-for-update
100 Depends: system-image-common,
101 system-image-dbus,
102 ubuntu-download-manager,
103
104=== renamed file 'debian/tests/ota_basic' => 'debian/tests/ota-basic'
105=== renamed file 'debian/tests/ota_selftests' => 'debian/tests/ota-selftests'
106=== added file 'setup.py'
107--- setup.py 1970-01-01 00:00:00 +0000
108+++ setup.py 2015-03-18 19:13:46 +0000
109@@ -0,0 +1,30 @@
110+#
111+# Ubuntu OTA Tests
112+# Copyright (C) 2015 Canonical
113+#
114+# This program is free software: you can redistribute it and/or modify
115+# it under the terms of the GNU General Public License as published by
116+# the Free Software Foundation, either version 3 of the License, or
117+# (at your option) any later version.
118+#
119+# This program is distributed in the hope that it will be useful,
120+# but WITHOUT ANY WARRANTY; without even the implied warranty of
121+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
122+# GNU General Public License for more details.
123+#
124+# You should have received a copy of the GNU General Public License
125+# along with this program. If not, see <http://www.gnu.org/licenses/>.
126+#
127+
128+from setuptools import find_packages, setup
129+
130+setup(
131+ name='ubuntu-ota-tests',
132+ version='1.0',
133+ description='Ubuntu OTA tests',
134+ author='Ubuntu QA Team',
135+ author_email='qa-team@lists.canonical.com',
136+ license='GNU GPLv3',
137+ packages=find_packages(),
138+ include_package_data=True,
139+ )
140
141=== renamed directory 'debian/tests/ubuntu_ota_tests' => 'ubuntu_ota_tests'
142=== modified file 'ubuntu_ota_tests/hooks.py'
143--- debian/tests/ubuntu_ota_tests/hooks.py 2015-03-12 15:17:34 +0000
144+++ ubuntu_ota_tests/hooks.py 2015-03-18 19:13:46 +0000
145@@ -19,17 +19,25 @@
146 import logging
147 import subprocess
148
149-from systemimage import reboot
150+try:
151+ # si 3.0
152+ from systemimage.apply import BaseApply as Base
153+except ImportError:
154+ # si 2.5
155+ from systemimage.reboot import BaseReboot as Base
156+
157+from systemimage.config import config
158
159
160 log = logging.getLogger('systemimage')
161
162
163-class ADTRebootToRecovery(reboot.BaseReboot):
164+class ADTRebootToRecovery(Base):
165
166 """Hook to be used during system image upgrade to apply the upgrade."""
167
168- def reboot(self):
169+ # si 3.0
170+ def apply(self):
171 """Reboot the testbed to apply the upgrade.
172
173 This method does not execute the reboot, it tells adt-run that the
174@@ -53,6 +61,12 @@
175 log.exception('reboot exit status: {}'.format(error.returncode))
176 log.exception('reboot command output: {}'.format(error.output))
177 raise
178+ # This code may or may not run. We're racing against the system
179+ # reboot procedure.
180+ config.dbus_service.Rebooting(True)
181+
182+ # si 2.5
183+ reboot = apply
184
185 def _set_adt_reboot_to_recovery_flag(self):
186 """Set a flag to tell adt that the reboot needs to go into recovery."""
187
188=== modified file 'ubuntu_ota_tests/reactors.py'
189--- debian/tests/ubuntu_ota_tests/reactors.py 2015-03-17 11:52:35 +0000
190+++ ubuntu_ota_tests/reactors.py 2015-03-18 19:13:46 +0000
191@@ -35,9 +35,12 @@
192 'is_available downloading available_version update_size '
193 'last_update_date error_reason')
194 RebootingRecord = namedtuple('RebootingRecord', 'status')
195+
196 DownloadRecord = namedtuple(
197 'DownloadRecord', 'downloaded percentage paused failed')
198
199+AppliedRecord = namedtuple('AppliedRecord', 'status')
200+
201
202 class BaseReactor(Reactor):
203 def __init__(self, iface_method, *signals):
204@@ -66,7 +69,7 @@
205
206 class ApplyUpdateReactor(BaseReactor):
207 def __init__(self, iface):
208- super().__init__(iface.ApplyUpdate, 'Rebooting')
209+ super().__init__(iface.ApplyUpdate, 'Applied', 'Rebooting')
210
211 def _do_Rebooting(self, signal, path, *args):
212 self.signals.append(RebootingRecord(*args))
213@@ -99,4 +102,7 @@
214 def _do_UpdateFailed(self, signal, path, *args):
215 self.signals.append(DownloadRecord(
216 downloaded=False, percentage=0, paused=False, failed=True))
217+
218+ def _do_Applied(self, signal, path, *args):
219+ self.signals.append(AppliedRecord(*args))
220 self.quit()
221
222=== modified file 'ubuntu_ota_tests/tests/test_basic_upgrade.py'
223--- debian/tests/ubuntu_ota_tests/tests/test_basic_upgrade.py 2015-03-12 15:37:04 +0000
224+++ ubuntu_ota_tests/tests/test_basic_upgrade.py 2015-03-18 19:13:46 +0000
225@@ -27,8 +27,6 @@
226 def test_basic_over_the_air_upgrade(self):
227 rebooted_mark = os.environ.get('ADT_REBOOT_MARK', None)
228 if not rebooted_mark:
229- # The upgrade with dbus needs more work, it's getting stuck.
230- # upgrade.upgrade_with_system_image_dbus()
231- upgrade.upgrade_with_system_image_cli()
232+ upgrade.upgrade_with_system_image_dbus()
233 else:
234 print('Rebooted')
235
236=== modified file 'ubuntu_ota_tests/upgrade.py'
237--- debian/tests/ubuntu_ota_tests/upgrade.py 2015-03-10 21:46:22 +0000
238+++ ubuntu_ota_tests/upgrade.py 2015-03-18 19:13:46 +0000
239@@ -16,9 +16,14 @@
240 # along with this program. If not, see <http://www.gnu.org/licenses/>.
241 #
242
243+import os
244 import subprocess
245
246-from ubuntu_ota_tests import hooks
247+import ubuntu_ota_tests
248+from ubuntu_ota_tests import (
249+ hooks,
250+ services
251+)
252
253
254 def upgrade_with_system_image_cli():
255@@ -26,3 +31,36 @@
256 print('Upgrading with ' + command)
257 subprocess.check_call(command.split())
258 hooks.ADTRebootToRecovery().reboot()
259+
260+
261+def upgrade_with_system_image_dbus():
262+ os.environ['PYTHONPATH'] = (
263+ os.environ.get('PYTHONPATH') +
264+ os.path.dirname(ubuntu_ota_tests.__file__))
265+ print(os.environ.get('PYTHONPATH'))
266+ _write_adt_apply_config()
267+ services.ensure_system_image_dbus_not_running()
268+ command = 'system-image-dbus -v -C ' + _get_system_image_config_dir()
269+ print('Starting system-images with ' + command)
270+ subprocess.Popen(command.split())
271+ services.set_auto_download(False)
272+ print('Checking')
273+ status = services.check_for_update()
274+ if status.is_available:
275+ print('Downloading')
276+ services.download_update()
277+ print('Applying')
278+ services.apply_update()
279+
280+
281+def _write_adt_apply_config():
282+ config_path = _get_system_image_config_dir()
283+ adt_apply_config_path = os.path.join(config_path, '01adt_apply.ini')
284+ with open(adt_apply_config_path, 'w') as apply_config_file:
285+ apply_config_file.write('[hooks]\n')
286+ apply_config_file.write(
287+ 'apply: ubuntu_ota_tests.hooks.ADTRebootToRecovery')
288+
289+
290+def _get_system_image_config_dir():
291+ return os.environ.get('ADT_ARTIFACTS')

Subscribers

People subscribed via source and target branches

to all changes: