Merge lp:~sil2100/update-manager/fix-test-failure-origin into lp:update-manager

Proposed by Łukasz Zemczak
Status: Merged
Merged at revision: 2792
Proposed branch: lp:~sil2100/update-manager/fix-test-failure-origin
Merge into: lp:update-manager
Diff against target: 27 lines (+9/-0)
1 file modified
tests/test_update_origin.py (+9/-0)
To merge this branch: bzr merge lp:~sil2100/update-manager/fix-test-failure-origin
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+330446@code.launchpad.net

Commit message

Fix the testOriginMatcherWithVersionInUpdatesAndSecurity test as it was making wrong assumptions, not checking if packages actually had ANY package in -security.

Description of the change

Fix the testOriginMatcherWithVersionInUpdatesAndSecurity test as it was making wrong assumptions, not checking if packages actually had ANY package in -security.

The test was supposed to check the case of when there's an update in -updates that's higher version than in -security. There is a check to make sure we're not adding packages to the test set if they have the same version in both -updates and -security, but things start to fail if a package has a more than 2 versions in xenial and none in -security. e.g. in the case of having 3 versions, one in xenial and 2 in xenial-updates, the package was instantly marked as 'good' for the test case. And the test is failing as it fails to mark the package as having a security update - since it doesn't have one.

Solution: when choosing packages to be used in the test, let's check if there is ANY version in -security. Otherwise it makes no sense to try and use the package for testing. This test-case seemed to work by sheer luck before.

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

This change fixes the current artful autopkgtest failure which started happening when we released a new packagekit SRU to xenial-updates.

https://objectstorage.prodstack4-5.canonical.com/v1/AUTH_77e2ada1e7a84929a74ba3b87153c0ac/autopkgtest-artful/artful/armhf/u/update-manager/20170907_003254_8b9e0@/log.gz

Revision history for this message
Brian Murray (brian-murray) wrote :

I wonder if there isn't a way to reduce the number of checks that we are doing here, pkg.candidate.origins and then pkg.versions, rather than having two. I tried something but it didn't end up working out so if you don't have any ideas feel free to merge and upload it.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

In theory we could do it in one loop, but I don't think that would look any better or be any more efficient. The first loop over pkg.candidate.origins is a quick one, as that's the pointer to the latest available upgrade candidate. It's clean enough since we know what we're looping through.

Let me merge it as is in that case.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_update_origin.py'
2--- tests/test_update_origin.py 2017-08-09 16:34:04 +0000
3+++ tests/test_update_origin.py 2017-09-08 16:26:21 +0000
4@@ -76,14 +76,23 @@
5 # ensure that the origin is not -updates and -security
6 is_in_updates = False
7 is_in_security = False
8+ had_security = False
9 for v in pkg.candidate.origins:
10 # test if the package is not in both updates and security
11 if v.archive == "xenial-updates":
12 is_in_updates = True
13 elif v.archive == "xenial-security":
14 is_in_security = True
15+ # ensure that the package actually has any version in -security
16+ for v in pkg.versions:
17+ for (pkgfile, _unused) in v._cand.file_list:
18+ o = apt.package.Origin(pkg, pkgfile)
19+ if o.archive == "xenial-security":
20+ had_security = True
21+ break
22 if (is_in_updates and
23 not is_in_security and
24+ had_security and
25 len(pkg._pkg.version_list) > 2):
26 test_pkgs.add(pkg.name)
27 self.assertTrue(len(test_pkgs) > 0,

Subscribers

People subscribed via source and target branches

to status/vote changes: