Merge lp:~aacid/system-image-client/mandatory_update_fix into lp:system-image-client

Proposed by Albert Astals Cid
Status: Merged
Approved by: Ted Gould
Approved revision: 76
Merged at revision: 77
Proposed branch: lp:~aacid/system-image-client/mandatory_update_fix
Merge into: lp:system-image-client
Diff against target: 185 lines (+69/-31)
4 files modified
systemimageclient.cpp (+25/-25)
systemimageclient.h (+1/-1)
tests/systemimageclient/data/index_test_version (+2/-2)
tests/systemimageclient/systemimageclienttest.cpp (+41/-3)
To merge this branch: bzr merge lp:~aacid/system-image-client/mandatory_update_fix
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
jenkins (community) continuous-integration Approve
Review via email: mp+116308@code.launchpad.net

Commit message

Fix updating to non final mandatory versions

E.g. you are in version 1, version 2 is mandatory and version 3 recommended, you should get an update to version 2

Description of the change

As discussed fix updating to non final mandatory versions

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'systemimageclient.cpp'
2--- systemimageclient.cpp 2012-07-23 07:34:59 +0000
3+++ systemimageclient.cpp 2012-07-23 15:22:24 +0000
4@@ -279,7 +279,7 @@
5 if (m_desiredVersion != 0) {
6 updateToDesiredVersion(entries);
7 } else {
8- updateToNewestVersion(entries);
9+ updateToNewestMandatoryVersion(entries);
10 }
11 }
12 }
13@@ -302,37 +302,37 @@
14 }
15 }
16
17-void SystemImageClient::updateToNewestVersion(const QList<IndexEntry> &entries)
18+void SystemImageClient::updateToNewestMandatoryVersion(const QList<IndexEntry> &entries)
19 {
20- IndexEntry higherModelEntry;
21+ IndexEntry higherMandatoryEntry;
22 foreach(const IndexEntry& entry, entries) {
23- if (entry.models().contains(m_model)) {
24- if (higherModelEntry.models().isEmpty()) {
25- higherModelEntry = entry;
26- } else if (higherModelEntry.version() < entry.version()) {
27- higherModelEntry = entry;
28+ if (entry.type() == IndexEntry::MandatoryUpdate && entry.models().contains(m_model)) {
29+ if (higherMandatoryEntry.models().isEmpty()) {
30+ higherMandatoryEntry = entry;
31+ } else if (higherMandatoryEntry.version() < entry.version()) {
32+ higherMandatoryEntry = entry;
33 }
34 }
35 }
36
37- if (!higherModelEntry.models().isEmpty() && higherModelEntry.version() > m_currentImageVersion) {
38- switch (higherModelEntry.type()) {
39- case IndexEntry::MandatoryUpdate:
40- downloadAndInstallEntry(higherModelEntry);
41- break;
42-
43- case IndexEntry::RecommendedUpdate:
44- // Inform whoever might be interested we have a new recommended update
45- Q_EMIT newRecommendedUpdate(higherModelEntry);
46- qApp->exit();
47- break;
48-
49- case IndexEntry::NonRecommendedUpdate:
50- // Nothing
51- qApp->exit();
52- break;
53- }
54+ if (!higherMandatoryEntry.models().isEmpty() && higherMandatoryEntry.version() > m_currentImageVersion) {
55+ downloadAndInstallEntry(higherMandatoryEntry);
56 } else {
57+ // There is no mandatory version newer than the current one, let's see if there is a recommended one
58+ IndexEntry higherRecommendedEntry;
59+ foreach(const IndexEntry& entry, entries) {
60+ if (entry.type() == IndexEntry::RecommendedUpdate && entry.models().contains(m_model)) {
61+ if (higherRecommendedEntry.models().isEmpty()) {
62+ higherRecommendedEntry = entry;
63+ } else if (higherRecommendedEntry.version() < entry.version()) {
64+ higherRecommendedEntry = entry;
65+ }
66+ }
67+ }
68+
69+ if (!higherRecommendedEntry.models().isEmpty() && higherRecommendedEntry.version() > m_currentImageVersion) {
70+ Q_EMIT newRecommendedUpdate(higherRecommendedEntry);
71+ }
72 qApp->exit();
73 }
74 }
75
76=== modified file 'systemimageclient.h'
77--- systemimageclient.h 2012-07-18 14:49:17 +0000
78+++ systemimageclient.h 2012-07-23 15:22:24 +0000
79@@ -71,7 +71,7 @@
80 void downloadImageFinished(bool success, quint64 size);
81
82 void updateToDesiredVersion(const QList<IndexEntry> &entries);
83- void updateToNewestVersion(const QList<IndexEntry> &entries);
84+ void updateToNewestMandatoryVersion(const QList<IndexEntry> &entries);
85 void downloadAndInstallEntry(const IndexEntry &entry);
86
87 enum DownloadTarget {
88
89=== modified file 'tests/systemimageclient/data/index_test_version'
90--- tests/systemimageclient/data/index_test_version 2012-07-19 14:01:36 +0000
91+++ tests/systemimageclient/data/index_test_version 2012-07-23 15:22:24 +0000
92@@ -5,7 +5,7 @@
93 model: cp001
94 model: cp002
95 version: 1
96-type: recommended
97+type: mandatory
98 size: 196443793
99 hash_type: sha1
100 hash: da39a3ee5e6b4b0d3255bfef95601890afd80709
101@@ -28,7 +28,7 @@
102 model: cp002
103 model: ct001
104 version: 2
105-type: recommended
106+type: mandatory
107 size: 193443793
108 hash_type: sha1
109 hash: da39a3ee5e6b4b0d3255bfef95601890afd80709
110
111=== modified file 'tests/systemimageclient/systemimageclienttest.cpp'
112--- tests/systemimageclient/systemimageclienttest.cpp 2012-07-19 14:01:36 +0000
113+++ tests/systemimageclient/systemimageclienttest.cpp 2012-07-23 15:22:24 +0000
114@@ -180,6 +180,44 @@
115 }
116
117 // Test the SystemImageClient chooses the right update for our model and version
118+ // even if there is a newer recommended update
119+ // It is a mandatory update as we can see in the index_test_version file
120+ void testMandatoryUpdateCorrectVersionNewerRecommended()
121+ {
122+ SystemImageClient sic;
123+ RecommendedUpdatesReceiver rur;
124+
125+ sic.m_indexRootLocation = "SomewhereOverTheRainbow";
126+ sic.setModel("cp001");
127+ sic.setCurrentImageVersion(1);
128+ sic.setSystemPartitions(QStringList() << "dontcare");
129+
130+ QVERIFY(sic.isOk());
131+
132+ connect(&sic, SIGNAL(newRecommendedUpdate(IndexEntry)), &rur, SLOT(newRecommendedUpdate(IndexEntry)));
133+
134+ sic.m_downloadManager.m_filesContentToReturn << DATADIR"index_test_version" << DATADIR"test_image";
135+ const bool startStatus = sic.startCheckNewImage();
136+
137+ QVERIFY(startStatus);
138+
139+ QTest::qWait(100);
140+
141+ QCOMPARE(rur.m_updatesReceived, 0);
142+ QCOMPARE(sic.m_downloadManager.m_lastDownloadedUrl, QUrl("SomewhereOverTheRainbow/1204x3x4x5-2.xz"));
143+ QCOMPARE(sic.m_imageEntryToUpdateTo.name(), QString("Jolly Jaguar 2nd update for X3, X4 and X5"));
144+ QCOMPARE(sic.m_imageEntryToUpdateTo.filename(), QString("1204x3x4x5-2.xz"));
145+ QCOMPARE(sic.m_imageEntryToUpdateTo.models(), QStringList() << "cp001" << "cp002" << "ct001");
146+ QCOMPARE(sic.m_imageEntryToUpdateTo.version(), 2ULL);
147+ QCOMPARE(sic.m_imageEntryToUpdateTo.type(), IndexEntry::MandatoryUpdate);
148+ QCOMPARE(sic.m_imageEntryToUpdateTo.size(), 193443793ULL);
149+ QCOMPARE(sic.m_imageEntryToUpdateTo.hashType(), HashUtils::Sha1Hash);
150+ QCOMPARE(sic.m_imageEntryToUpdateTo.hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
151+ QCOMPARE(sic.m_imageEntryToUpdateTo.security(), IndexEntry::SignedFile);
152+ QCOMPARE(sic.m_imageEntryToUpdateTo.changelogSecurity(), IndexEntry::RawFile);
153+ }
154+
155+ // Test the SystemImageClient chooses the right update for our model and version
156 // It is a mandatory update as we can see in the index_test_version file
157 void testMandatoryUpdateCorrectVersionRawFile()
158 {
159@@ -272,7 +310,7 @@
160 QCOMPARE(sic.m_imageEntryToUpdateTo.filename(), QString("1204x3x5.xz"));
161 QCOMPARE(sic.m_imageEntryToUpdateTo.models(), QStringList() << "cp001" << "cp002");
162 QCOMPARE(sic.m_imageEntryToUpdateTo.version(), 1ULL);
163- QCOMPARE(sic.m_imageEntryToUpdateTo.type(), IndexEntry::RecommendedUpdate);
164+ QCOMPARE(sic.m_imageEntryToUpdateTo.type(), IndexEntry::MandatoryUpdate);
165 QCOMPARE(sic.m_imageEntryToUpdateTo.size(), 196443793ULL);
166 QCOMPARE(sic.m_imageEntryToUpdateTo.hashType(), HashUtils::Sha1Hash);
167 QCOMPARE(sic.m_imageEntryToUpdateTo.hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
168@@ -310,7 +348,7 @@
169 QCOMPARE(dw.m_entries[0].filename(), QString("1204x3x5.xz"));
170 QCOMPARE(dw.m_entries[0].models(), QStringList() << "cp001" << "cp002");
171 QCOMPARE(dw.m_entries[0].version(), 1ULL);
172- QCOMPARE(dw.m_entries[0].type(), IndexEntry::RecommendedUpdate);
173+ QCOMPARE(dw.m_entries[0].type(), IndexEntry::MandatoryUpdate);
174 QCOMPARE(dw.m_entries[0].size(), 196443793ULL);
175 QCOMPARE(dw.m_entries[0].hashType(), HashUtils::Sha1Hash);
176 QCOMPARE(dw.m_entries[0].hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
177@@ -321,7 +359,7 @@
178 QCOMPARE(dw.m_entries[1].filename(), QString("1204x3x4x5-2.xz"));
179 QCOMPARE(dw.m_entries[1].models(), QStringList() << "cp001" << "cp002" << "ct001");
180 QCOMPARE(dw.m_entries[1].version(), 2ULL);
181- QCOMPARE(dw.m_entries[1].type(), IndexEntry::RecommendedUpdate);
182+ QCOMPARE(dw.m_entries[1].type(), IndexEntry::MandatoryUpdate);
183 QCOMPARE(dw.m_entries[1].size(), 193443793ULL);
184 QCOMPARE(dw.m_entries[1].hashType(), HashUtils::Sha1Hash);
185 QCOMPARE(dw.m_entries[1].hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));

Subscribers

People subscribed via source and target branches