Merge lp:~mvo/pkgme-devportal/changelog-for-the-latest into lp:pkgme-devportal

Proposed by Michael Vogt
Status: Merged
Approved by: James Westby
Approved revision: 56
Merged at revision: 53
Proposed branch: lp:~mvo/pkgme-devportal/changelog-for-the-latest
Merge into: lp:pkgme-devportal
Diff against target: 127 lines (+42/-0)
3 files modified
devportalbinary/metadata.py (+8/-0)
devportalbinary/tests/test_metadata.py (+18/-0)
devportalbinary/utils.py (+16/-0)
To merge this branch: bzr merge lp:~mvo/pkgme-devportal/changelog-for-the-latest
Reviewer Review Type Date Requested Status
Jonathan Lange Approve
James Westby Approve
Review via email: mp+114128@code.launchpad.net

Commit message

Ensure that the latest stable distro release is in the changelog (mvo)

Description of the change

This branch ensures that the changelog is always set to the latest ubuntu distribution release found on launchpad. This fixes bug #1012625. The downside of this approach is that its pretty slow and the acceptance test goes from
~7s on my system to 30s without a launchpadlib cachedir and ~26s with a launchpadlib cachedir.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

The slow down of acceptance tests is rather annoying, but I think tolerable for this
change. I'd like jml's opinion too though.

Thanks,

James

review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :

jml? Any feedback on this one?

Revision history for this message
Jonathan Lange (jml) wrote :

Hi,

Launchpad should really have a better test double! I could imagine, in this case, setting up a simplish local webserver that only served the resources that you need.

I'm OK with this landing as is.

Oh, actually, please address the XXX comment. At least, say who "I" is.

Thanks,
jml

55. By Michael Vogt

give the XXX a name

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, I addressed the XXX issue and can look into the local webserver later if needed.

Revision history for this message
Jonathan Lange (jml) wrote :

Hey mvo,

I'm sorry I didn't notice this on the first cut, but could you please rename the cache variable, ``stable_ubuntu_distroseries`` to have an underscore prefix?

Once that's done, we're good to land.

Thanks,
jml

review: Approve
56. By Michael Vogt

devportalbinary/utils.py: rename stable_ubuntu_distroseries->_stable_ubuntu_distroseries

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, I fixed the rename issue now.

I also looked into a test double for LP a bit this morning, but its really the wadl stuff that makes it rather cumbersome. I was thinking that maybe a simple proxy server would be good enough to speed the tests up but it appears that launchpadlib does not support proxies (according to #938542).

Revision history for this message
Michael Vogt (mvo) wrote :

I guess one alternative would simply be to use http://changelogs.ubuntu.com/meta-release as this dosn't require download nearly as much data as the wadl stuff.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'devportalbinary/metadata.py'
2--- devportalbinary/metadata.py 2012-07-06 15:58:03 +0000
3+++ devportalbinary/metadata.py 2012-07-16 06:56:18 +0000
4@@ -27,6 +27,7 @@
5 Categories,
6 Depends,
7 Description,
8+ Distribution,
9 Executable,
10 ExtraFiles,
11 ExtraFilesFromPaths,
12@@ -44,6 +45,9 @@
13 )
14 from pkgme.project_info import DictInfo
15
16+from .utils import get_latest_stable_ubuntu_distroseries
17+
18+
19 # XXX: is this the right place?
20 LINTIAN_OVERRIDES_TEMPLATE = """
21 #Partner package contents belong in /opt
22@@ -250,6 +254,9 @@
23 """Get the package description."""
24 return metadata.get(self.DESCRIPTION, '')
25
26+ def get_distribution(self, metadata):
27+ return get_latest_stable_ubuntu_distroseries()
28+
29 def get_executable(self, package_name):
30 """Return the path to the executable."""
31 raise NotImplementedError(self.get_executable)
32@@ -415,6 +422,7 @@
33 ]
34 OPTIONAL_ELEMENTS = [
35 Architecture,
36+ Distribution,
37 ExtraFilesFromPaths,
38 Maintainer,
39 Version,
40
41=== modified file 'devportalbinary/tests/test_metadata.py'
42--- devportalbinary/tests/test_metadata.py 2012-07-06 15:58:03 +0000
43+++ devportalbinary/tests/test_metadata.py 2012-07-16 06:56:18 +0000
44@@ -12,6 +12,7 @@
45 BuildDepends,
46 Description,
47 Depends,
48+ Distribution,
49 ExtraFiles,
50 ExtraFilesFromPaths,
51 Homepage,
52@@ -66,6 +67,16 @@
53
54 BACKEND = DummyBackend
55
56+ def setUp(self):
57+ super(MetadataTests, self).setUp()
58+ # mock this for all tests to ensure we do not slow down because
59+ # of network access
60+ patcher = patch(
61+ 'devportalbinary.metadata.get_latest_stable_ubuntu_distroseries')
62+ mock_get_latest_distroseries = patcher.start()
63+ mock_get_latest_distroseries.return_value = 'foo'
64+ self.addCleanup(patcher.stop)
65+
66 def test_metadata_file(self):
67 self.assertEqual('devportal-metadata.json', MetadataBackend.METADATA_FILE)
68
69@@ -264,6 +275,7 @@
70 BuildDepends: ('build_depends', metadata),
71 Depends: ('depends', metadata),
72 Description: ('description', metadata),
73+ Distribution: 'foo',
74 ExtraFiles: backend.get_extra_files(metadata, package_name),
75 PackageName: package_name,
76 License: "unknown",
77@@ -281,6 +293,7 @@
78 {BuildDepends: ('build_depends', metadata),
79 Depends: ('depends', metadata),
80 Description: ('description', metadata),
81+ Distribution: 'foo',
82 ExtraFiles: backend.get_extra_files(metadata, package_name),
83 PackageName: package_name,
84 License: "unknown",
85@@ -374,6 +387,11 @@
86 backend = self.make_backend()
87 self.assertEqual('Apache-2.0', backend.get_info(metadata)[License])
88
89+ def test_distribution(self):
90+ metadata = self.make_metadata()
91+ backend = self.make_backend()
92+ self.assertEqual('foo', backend.get_info(metadata)[Distribution])
93+
94
95 class DesktopFileTests(TestCase):
96
97
98=== modified file 'devportalbinary/utils.py'
99--- devportalbinary/utils.py 2012-04-12 16:23:09 +0000
100+++ devportalbinary/utils.py 2012-07-16 06:56:18 +0000
101@@ -11,6 +11,7 @@
102 )
103
104 from bzrlib import urlutils
105+from launchpadlib.launchpad import Launchpad
106
107
108 def _open_file_for_writing(url, directory=None, name=None, working_dir=None):
109@@ -64,3 +65,18 @@
110 os.close(fd)
111 finally:
112 download.close()
113+
114+
115+_stable_ubuntu_distroseries = None
116+def get_latest_stable_ubuntu_distroseries():
117+ """Return the latest stable ubuntu release codename (e.g. "precise")"""
118+ global _stable_ubuntu_distroseries
119+ if _stable_ubuntu_distroseries is None:
120+ # XXX: mvo wonders if a cachedir here would make sense
121+ cachedir = None
122+ launchpad = Launchpad.login_anonymously(
123+ 'pkgme-devportal', 'production', cachedir)
124+ for distroseries in launchpad.distributions["ubuntu"].series:
125+ if distroseries.status == 'Current Stable Release':
126+ _stable_ubuntu_distroseries = distroseries.name
127+ return _stable_ubuntu_distroseries

Subscribers

People subscribed via source and target branches