Merge lp:~canonical-platform-qa/ubuntu-ota-tests/wait-for-download into lp:ubuntu-ota-tests

Proposed by Christopher Lee
Status: Merged
Approved by: Leonardo Arias Fonseca
Approved revision: 45
Merged at revision: 11
Proposed branch: lp:~canonical-platform-qa/ubuntu-ota-tests/wait-for-download
Merge into: lp:ubuntu-ota-tests
Prerequisite: lp:~canonical-platform-qa/ubuntu-ota-tests/apply-update
Diff against target: 124 lines (+72/-1)
3 files modified
debian/tests/ubuntu_ota_tests/reactors.py (+33/-1)
debian/tests/ubuntu_ota_tests/selftests/test_services.py (+23/-0)
debian/tests/ubuntu_ota_tests/services.py (+16/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-ota-tests/wait-for-download
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Federico Gimenez (community) Approve
Brendan Donegan (community) Approve
Christopher Lee Pending
Barry Warsaw Pending
Review via email: mp+253301@code.launchpad.net

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

Commit message

Add a download reactor class, service method and test to download an available update.

Description of the change

Add a download reactor class and service methods with some tests. The tests rely on there being a suitable update to download.

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote : Posted in a previous version of this proposal

Merge conflicts

review: Needs Fixing
Revision history for this message
Christopher Lee (veebers) wrote : Posted in a previous version of this proposal

Looking good, some questions and one fix inline with the code.

review: Needs Fixing
Revision history for this message
Richard Huddie (rhuddie) wrote : Posted in a previous version of this proposal

Thanks Chris, I have made those updates.

Revision history for this message
Barry Warsaw (barry) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
Christopher Lee (veebers) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Autolanding.
Unapproved changes made after approval.
http://jenkins.qa.ubuntu.com/job/ubuntu-ota-tests-autolanding/10/
Executed test runs:

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Autolanding.
Merging failed. More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/ubuntu-ota-tests-autolanding/11/
Executed test runs:

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Autolanding.
Merging failed. More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/ubuntu-ota-tests-autolanding/12/
Executed test runs:

review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Lee (veebers) wrote : Posted in a previous version of this proposal

I resubmitted this to show up the merge conflicts that are apparently stopping the automerge.

43. By Richard Huddie

Merge from parent branch.

44. By Richard Huddie

Updates required for CheckForUpdateReactor changes.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

I'm getting this error when running the selftests:

======================================================================
FAIL: test_download_update (ubuntu_ota_tests.selftests.test_services.ServicesTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/adt-run.HgXbrF/build.jE3/real-tree/debian/tests/ubuntu_ota_tests/selftests/test_services.py", line 88, in test_download_update
    self.assertTrue(self.is_update_available())
AssertionError: dbus.Boolean(False) is not true

I guess that it is because the device has the latest revision installed, should we execute this test without knowing (or being able to set) the current state of the device?

review: Needs Information
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Looks good to me

review: Approve
45. By Richard Huddie

Skip download test if no download available.

Revision history for this message
Richard Huddie (rhuddie) wrote :

Hi Federico,
I changed the test so that it will skip if there is no download available.
Thanks.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

Thanks Richard, approving

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/tests/ubuntu_ota_tests/reactors.py'
2--- debian/tests/ubuntu_ota_tests/reactors.py 2015-03-17 09:30:15 +0000
3+++ debian/tests/ubuntu_ota_tests/reactors.py 2015-03-18 13:54:41 +0000
4@@ -18,7 +18,8 @@
5
6 __all__ = [
7 'CheckForUpdateReactor',
8- 'ApplyUpdateReactor'
9+ 'ApplyUpdateReactor',
10+ 'DownloadReactor'
11 ]
12
13
14@@ -34,6 +35,8 @@
15 'is_available downloading available_version update_size '
16 'last_update_date error_reason')
17 RebootingRecord = namedtuple('RebootingRecord', 'status')
18+DownloadRecord = namedtuple(
19+ 'DownloadRecord', 'downloaded percentage paused failed')
20
21
22 class BaseReactor(Reactor):
23@@ -68,3 +71,32 @@
24 def _do_Rebooting(self, signal, path, *args):
25 self.signals.append(RebootingRecord(*args))
26 self.quit()
27+
28+
29+class DownloadReactor(BaseReactor):
30+
31+ def __init__(self, iface):
32+ super().__init__(
33+ iface.DownloadUpdate, 'UpdateDownloaded', 'UpdateProgress',
34+ 'UpdatePaused', 'UpdateFailed')
35+
36+ def _do_UpdateDownloaded(self, signal, path):
37+ # No arguments passed to this method
38+ self.signals.append(DownloadRecord(
39+ downloaded=True, percentage=100, paused=False, failed=False))
40+ self.quit()
41+
42+ def _do_UpdateProgress(self, signal, path, percentage, eta):
43+ self.signals.append(DownloadRecord(
44+ downloaded=False, percentage=percentage, paused=False,
45+ failed=False))
46+
47+ def _do_UpdatePaused(self, signal, path, percentage):
48+ self.signals.append(DownloadRecord(
49+ downloaded=False, percentage=percentage, paused=True,
50+ failed=False))
51+
52+ def _do_UpdateFailed(self, signal, path, *args):
53+ self.signals.append(DownloadRecord(
54+ downloaded=False, percentage=0, paused=False, failed=True))
55+ self.quit()
56
57=== modified file 'debian/tests/ubuntu_ota_tests/selftests/test_services.py'
58--- debian/tests/ubuntu_ota_tests/selftests/test_services.py 2015-03-17 16:13:25 +0000
59+++ debian/tests/ubuntu_ota_tests/selftests/test_services.py 2015-03-18 13:54:41 +0000
60@@ -22,6 +22,13 @@
61 from ubuntu_ota_tests import services
62
63
64+def is_update_available():
65+ """Check if an update is available.
66+ :return: True if available, False otherwise."""
67+ status = services.check_for_update()
68+ return status.is_available
69+
70+
71 class ServicesTestCase(unittest.TestCase):
72
73 def setUp(self):
74@@ -68,3 +75,19 @@
75
76 self.assertEqual(len(result), 1)
77 self.assertFalse(result.status)
78+
79+ def validate_successful_download(self, record):
80+ """Validate a successful download record"""
81+ self.assertTrue(record.downloaded)
82+ self.assertFalse(record.failed)
83+ self.assertFalse(record.paused)
84+ self.assertEqual(record.percentage, 100)
85+
86+ @unittest.skipUnless(is_update_available(), 'No update to download')
87+ def test_download_update(self):
88+ sys_image_iface = services.get_system_image_interface()
89+ self.assertEqual(sys_image_iface.CancelUpdate(), '')
90+ self.assertTrue(is_update_available())
91+ signals = services.download_update()
92+ # validate that last record was a successful download signal
93+ self.validate_successful_download(signals[-1])
94
95=== modified file 'debian/tests/ubuntu_ota_tests/services.py'
96--- debian/tests/ubuntu_ota_tests/services.py 2015-03-17 16:13:25 +0000
97+++ debian/tests/ubuntu_ota_tests/services.py 2015-03-18 13:54:41 +0000
98@@ -25,6 +25,7 @@
99
100 from ubuntu_ota_tests import system
101 from ubuntu_ota_tests.reactors import ApplyUpdateReactor
102+from ubuntu_ota_tests.reactors import DownloadReactor
103 from ubuntu_ota_tests.reactors import CheckForUpdateReactor
104
105
106@@ -165,3 +166,18 @@
107 assert len(result) == 1, (
108 'Unexpected signal count: {}'.format(len(result)))
109 return result[0]
110+
111+
112+def download_update(timeout=300):
113+ """Call DownloadUpdate dbus method and wait for UpdateDownloaded signal.
114+
115+ This will trigger the download to start and wait for completion or failure
116+ signal.
117+
118+ :param timeout: Timeout for the download operation to complete in.
119+ :return: List of received signals.
120+
121+ """
122+ sys_image_iface = get_system_image_interface()
123+ reactor = DownloadReactor(sys_image_iface)
124+ return reactor.run(timeout=timeout)

Subscribers

People subscribed via source and target branches

to all changes: