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
=== modified file 'systemimageclient.cpp'
--- systemimageclient.cpp 2012-07-23 07:34:59 +0000
+++ systemimageclient.cpp 2012-07-23 15:22:24 +0000
@@ -279,7 +279,7 @@
279 if (m_desiredVersion != 0) {279 if (m_desiredVersion != 0) {
280 updateToDesiredVersion(entries);280 updateToDesiredVersion(entries);
281 } else {281 } else {
282 updateToNewestVersion(entries);282 updateToNewestMandatoryVersion(entries);
283 }283 }
284 }284 }
285}285}
@@ -302,37 +302,37 @@
302 }302 }
303}303}
304304
305void SystemImageClient::updateToNewestVersion(const QList<IndexEntry> &entries)305void SystemImageClient::updateToNewestMandatoryVersion(const QList<IndexEntry> &entries)
306{306{
307 IndexEntry higherModelEntry;307 IndexEntry higherMandatoryEntry;
308 foreach(const IndexEntry& entry, entries) {308 foreach(const IndexEntry& entry, entries) {
309 if (entry.models().contains(m_model)) {309 if (entry.type() == IndexEntry::MandatoryUpdate && entry.models().contains(m_model)) {
310 if (higherModelEntry.models().isEmpty()) {310 if (higherMandatoryEntry.models().isEmpty()) {
311 higherModelEntry = entry;311 higherMandatoryEntry = entry;
312 } else if (higherModelEntry.version() < entry.version()) {312 } else if (higherMandatoryEntry.version() < entry.version()) {
313 higherModelEntry = entry;313 higherMandatoryEntry = entry;
314 }314 }
315 }315 }
316 }316 }
317317
318 if (!higherModelEntry.models().isEmpty() && higherModelEntry.version() > m_currentImageVersion) {318 if (!higherMandatoryEntry.models().isEmpty() && higherMandatoryEntry.version() > m_currentImageVersion) {
319 switch (higherModelEntry.type()) {319 downloadAndInstallEntry(higherMandatoryEntry);
320 case IndexEntry::MandatoryUpdate:
321 downloadAndInstallEntry(higherModelEntry);
322 break;
323
324 case IndexEntry::RecommendedUpdate:
325 // Inform whoever might be interested we have a new recommended update
326 Q_EMIT newRecommendedUpdate(higherModelEntry);
327 qApp->exit();
328 break;
329
330 case IndexEntry::NonRecommendedUpdate:
331 // Nothing
332 qApp->exit();
333 break;
334 }
335 } else {320 } else {
321 // There is no mandatory version newer than the current one, let's see if there is a recommended one
322 IndexEntry higherRecommendedEntry;
323 foreach(const IndexEntry& entry, entries) {
324 if (entry.type() == IndexEntry::RecommendedUpdate && entry.models().contains(m_model)) {
325 if (higherRecommendedEntry.models().isEmpty()) {
326 higherRecommendedEntry = entry;
327 } else if (higherRecommendedEntry.version() < entry.version()) {
328 higherRecommendedEntry = entry;
329 }
330 }
331 }
332
333 if (!higherRecommendedEntry.models().isEmpty() && higherRecommendedEntry.version() > m_currentImageVersion) {
334 Q_EMIT newRecommendedUpdate(higherRecommendedEntry);
335 }
336 qApp->exit();336 qApp->exit();
337 }337 }
338}338}
339339
=== modified file 'systemimageclient.h'
--- systemimageclient.h 2012-07-18 14:49:17 +0000
+++ systemimageclient.h 2012-07-23 15:22:24 +0000
@@ -71,7 +71,7 @@
71 void downloadImageFinished(bool success, quint64 size);71 void downloadImageFinished(bool success, quint64 size);
7272
73 void updateToDesiredVersion(const QList<IndexEntry> &entries);73 void updateToDesiredVersion(const QList<IndexEntry> &entries);
74 void updateToNewestVersion(const QList<IndexEntry> &entries);74 void updateToNewestMandatoryVersion(const QList<IndexEntry> &entries);
75 void downloadAndInstallEntry(const IndexEntry &entry);75 void downloadAndInstallEntry(const IndexEntry &entry);
7676
77 enum DownloadTarget {77 enum DownloadTarget {
7878
=== modified file 'tests/systemimageclient/data/index_test_version'
--- tests/systemimageclient/data/index_test_version 2012-07-19 14:01:36 +0000
+++ tests/systemimageclient/data/index_test_version 2012-07-23 15:22:24 +0000
@@ -5,7 +5,7 @@
5model: cp0015model: cp001
6model: cp0026model: cp002
7version: 17version: 1
8type: recommended8type: mandatory
9size: 1964437939size: 196443793
10hash_type: sha110hash_type: sha1
11hash: da39a3ee5e6b4b0d3255bfef95601890afd8070911hash: da39a3ee5e6b4b0d3255bfef95601890afd80709
@@ -28,7 +28,7 @@
28model: cp00228model: cp002
29model: ct00129model: ct001
30version: 230version: 2
31type: recommended31type: mandatory
32size: 19344379332size: 193443793
33hash_type: sha133hash_type: sha1
34hash: da39a3ee5e6b4b0d3255bfef95601890afd8070934hash: da39a3ee5e6b4b0d3255bfef95601890afd80709
3535
=== modified file 'tests/systemimageclient/systemimageclienttest.cpp'
--- tests/systemimageclient/systemimageclienttest.cpp 2012-07-19 14:01:36 +0000
+++ tests/systemimageclient/systemimageclienttest.cpp 2012-07-23 15:22:24 +0000
@@ -180,6 +180,44 @@
180 }180 }
181181
182 // Test the SystemImageClient chooses the right update for our model and version182 // Test the SystemImageClient chooses the right update for our model and version
183 // even if there is a newer recommended update
184 // It is a mandatory update as we can see in the index_test_version file
185 void testMandatoryUpdateCorrectVersionNewerRecommended()
186 {
187 SystemImageClient sic;
188 RecommendedUpdatesReceiver rur;
189
190 sic.m_indexRootLocation = "SomewhereOverTheRainbow";
191 sic.setModel("cp001");
192 sic.setCurrentImageVersion(1);
193 sic.setSystemPartitions(QStringList() << "dontcare");
194
195 QVERIFY(sic.isOk());
196
197 connect(&sic, SIGNAL(newRecommendedUpdate(IndexEntry)), &rur, SLOT(newRecommendedUpdate(IndexEntry)));
198
199 sic.m_downloadManager.m_filesContentToReturn << DATADIR"index_test_version" << DATADIR"test_image";
200 const bool startStatus = sic.startCheckNewImage();
201
202 QVERIFY(startStatus);
203
204 QTest::qWait(100);
205
206 QCOMPARE(rur.m_updatesReceived, 0);
207 QCOMPARE(sic.m_downloadManager.m_lastDownloadedUrl, QUrl("SomewhereOverTheRainbow/1204x3x4x5-2.xz"));
208 QCOMPARE(sic.m_imageEntryToUpdateTo.name(), QString("Jolly Jaguar 2nd update for X3, X4 and X5"));
209 QCOMPARE(sic.m_imageEntryToUpdateTo.filename(), QString("1204x3x4x5-2.xz"));
210 QCOMPARE(sic.m_imageEntryToUpdateTo.models(), QStringList() << "cp001" << "cp002" << "ct001");
211 QCOMPARE(sic.m_imageEntryToUpdateTo.version(), 2ULL);
212 QCOMPARE(sic.m_imageEntryToUpdateTo.type(), IndexEntry::MandatoryUpdate);
213 QCOMPARE(sic.m_imageEntryToUpdateTo.size(), 193443793ULL);
214 QCOMPARE(sic.m_imageEntryToUpdateTo.hashType(), HashUtils::Sha1Hash);
215 QCOMPARE(sic.m_imageEntryToUpdateTo.hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
216 QCOMPARE(sic.m_imageEntryToUpdateTo.security(), IndexEntry::SignedFile);
217 QCOMPARE(sic.m_imageEntryToUpdateTo.changelogSecurity(), IndexEntry::RawFile);
218 }
219
220 // Test the SystemImageClient chooses the right update for our model and version
183 // It is a mandatory update as we can see in the index_test_version file221 // It is a mandatory update as we can see in the index_test_version file
184 void testMandatoryUpdateCorrectVersionRawFile()222 void testMandatoryUpdateCorrectVersionRawFile()
185 {223 {
@@ -272,7 +310,7 @@
272 QCOMPARE(sic.m_imageEntryToUpdateTo.filename(), QString("1204x3x5.xz"));310 QCOMPARE(sic.m_imageEntryToUpdateTo.filename(), QString("1204x3x5.xz"));
273 QCOMPARE(sic.m_imageEntryToUpdateTo.models(), QStringList() << "cp001" << "cp002");311 QCOMPARE(sic.m_imageEntryToUpdateTo.models(), QStringList() << "cp001" << "cp002");
274 QCOMPARE(sic.m_imageEntryToUpdateTo.version(), 1ULL);312 QCOMPARE(sic.m_imageEntryToUpdateTo.version(), 1ULL);
275 QCOMPARE(sic.m_imageEntryToUpdateTo.type(), IndexEntry::RecommendedUpdate);313 QCOMPARE(sic.m_imageEntryToUpdateTo.type(), IndexEntry::MandatoryUpdate);
276 QCOMPARE(sic.m_imageEntryToUpdateTo.size(), 196443793ULL);314 QCOMPARE(sic.m_imageEntryToUpdateTo.size(), 196443793ULL);
277 QCOMPARE(sic.m_imageEntryToUpdateTo.hashType(), HashUtils::Sha1Hash);315 QCOMPARE(sic.m_imageEntryToUpdateTo.hashType(), HashUtils::Sha1Hash);
278 QCOMPARE(sic.m_imageEntryToUpdateTo.hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));316 QCOMPARE(sic.m_imageEntryToUpdateTo.hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
@@ -310,7 +348,7 @@
310 QCOMPARE(dw.m_entries[0].filename(), QString("1204x3x5.xz"));348 QCOMPARE(dw.m_entries[0].filename(), QString("1204x3x5.xz"));
311 QCOMPARE(dw.m_entries[0].models(), QStringList() << "cp001" << "cp002");349 QCOMPARE(dw.m_entries[0].models(), QStringList() << "cp001" << "cp002");
312 QCOMPARE(dw.m_entries[0].version(), 1ULL);350 QCOMPARE(dw.m_entries[0].version(), 1ULL);
313 QCOMPARE(dw.m_entries[0].type(), IndexEntry::RecommendedUpdate);351 QCOMPARE(dw.m_entries[0].type(), IndexEntry::MandatoryUpdate);
314 QCOMPARE(dw.m_entries[0].size(), 196443793ULL);352 QCOMPARE(dw.m_entries[0].size(), 196443793ULL);
315 QCOMPARE(dw.m_entries[0].hashType(), HashUtils::Sha1Hash);353 QCOMPARE(dw.m_entries[0].hashType(), HashUtils::Sha1Hash);
316 QCOMPARE(dw.m_entries[0].hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));354 QCOMPARE(dw.m_entries[0].hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
@@ -321,7 +359,7 @@
321 QCOMPARE(dw.m_entries[1].filename(), QString("1204x3x4x5-2.xz"));359 QCOMPARE(dw.m_entries[1].filename(), QString("1204x3x4x5-2.xz"));
322 QCOMPARE(dw.m_entries[1].models(), QStringList() << "cp001" << "cp002" << "ct001");360 QCOMPARE(dw.m_entries[1].models(), QStringList() << "cp001" << "cp002" << "ct001");
323 QCOMPARE(dw.m_entries[1].version(), 2ULL);361 QCOMPARE(dw.m_entries[1].version(), 2ULL);
324 QCOMPARE(dw.m_entries[1].type(), IndexEntry::RecommendedUpdate);362 QCOMPARE(dw.m_entries[1].type(), IndexEntry::MandatoryUpdate);
325 QCOMPARE(dw.m_entries[1].size(), 193443793ULL);363 QCOMPARE(dw.m_entries[1].size(), 193443793ULL);
326 QCOMPARE(dw.m_entries[1].hashType(), HashUtils::Sha1Hash);364 QCOMPARE(dw.m_entries[1].hashType(), HashUtils::Sha1Hash);
327 QCOMPARE(dw.m_entries[1].hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));365 QCOMPARE(dw.m_entries[1].hash(), QString("da39a3ee5e6b4b0d3255bfef95601890afd80709"));

Subscribers

People subscribed via source and target branches