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

Proposed by Richard Huddie on 2015-03-12
Status: Superseded
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: 109 lines (+64/-1)
3 files modified
debian/tests/ubuntu_ota_tests/reactors.py (+33/-1)
debian/tests/ubuntu_ota_tests/selftests/test_services.py (+22/-0)
debian/tests/ubuntu_ota_tests/services.py (+9/-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 Needs Fixing on 2015-03-17
Christopher Lee (community) 2015-03-12 Approve on 2015-03-17
Barry Warsaw (community) Approve on 2015-03-16
Review via email: mp+252759@code.launchpad.net

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

Commit Message

Add a download reactor class and service methods with some tests

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.
Barry Warsaw (barry) wrote :

Merge conflicts

review: Needs Fixing
Christopher Lee (veebers) wrote :

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

review: Needs Fixing
Richard Huddie (rhuddie) wrote :

Thanks Chris, I have made those updates.

Barry Warsaw (barry) wrote :

LGTM

review: Approve
Christopher Lee (veebers) wrote :

LGTM

review: Approve
review: Approve (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :

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)
review: Approve (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :

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)
review: Approve (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :

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)
Christopher Lee (veebers) wrote :

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

43. By Richard Huddie on 2015-03-18

Merge from parent branch.

44. By Richard Huddie on 2015-03-18

Updates required for CheckForUpdateReactor changes.

45. By Richard Huddie on 2015-03-18

Skip download test if no download available.

Unmerged revisions

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 14:22:33 +0000
3+++ debian/tests/ubuntu_ota_tests/reactors.py 2015-03-17 14:22:33 +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 14:22:33 +0000
59+++ debian/tests/ubuntu_ota_tests/selftests/test_services.py 2015-03-17 14:22:33 +0000
60@@ -68,3 +68,25 @@
61
62 self.assertEqual(len(result), 1)
63 self.assertFalse(result[0].status)
64+
65+ def is_update_available(self):
66+ """Check if an update is available.
67+ :return: True is available, False otherwise."""
68+ signals = services.check_for_update()
69+ self.assertEqual(len(signals), 1)
70+ return signals[0].is_available
71+
72+ def validate_successful_download(self, record):
73+ """Validate a successful download record"""
74+ self.assertTrue(record.downloaded)
75+ self.assertFalse(record.failed)
76+ self.assertFalse(record.paused)
77+ self.assertEqual(record.percentage, 100)
78+
79+ def test_download_update(self):
80+ sys_image_iface = services.get_system_image_interface()
81+ self.assertEqual(sys_image_iface.CancelUpdate(), '')
82+ self.assertTrue(self.is_update_available())
83+ signals = services.download_update()
84+ # validate that last record was a successful download signal
85+ self.validate_successful_download(signals[-1])
86
87=== modified file 'debian/tests/ubuntu_ota_tests/services.py'
88--- debian/tests/ubuntu_ota_tests/services.py 2015-03-17 14:22:33 +0000
89+++ debian/tests/ubuntu_ota_tests/services.py 2015-03-17 14:22:33 +0000
90@@ -25,6 +25,7 @@
91
92 from ubuntu_ota_tests import system
93 from ubuntu_ota_tests.reactors import ApplyUpdateReactor
94+from ubuntu_ota_tests.reactors import DownloadReactor
95 from ubuntu_ota_tests.reactors import CheckForUpdateReactor
96
97
98@@ -158,3 +159,11 @@
99 sys_image_iface = get_system_image_interface()
100 reactor = ApplyUpdateReactor(sys_image_iface)
101 return reactor.run()
102+
103+
104+def download_update(timeout=300):
105+ """Call DownloadUpdate dbus method and wait for UpdateDownloaded signal.
106+ :return: List of received signals"""
107+ sys_image_iface = get_system_image_interface()
108+ reactor = DownloadReactor(sys_image_iface)
109+ return reactor.run(timeout=timeout)

Subscribers

People subscribed via source and target branches

to all changes: