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
=== modified file 'devportalbinary/metadata.py'
--- devportalbinary/metadata.py 2012-07-06 15:58:03 +0000
+++ devportalbinary/metadata.py 2012-07-16 06:56:18 +0000
@@ -27,6 +27,7 @@
27 Categories,27 Categories,
28 Depends,28 Depends,
29 Description,29 Description,
30 Distribution,
30 Executable,31 Executable,
31 ExtraFiles,32 ExtraFiles,
32 ExtraFilesFromPaths,33 ExtraFilesFromPaths,
@@ -44,6 +45,9 @@
44 )45 )
45from pkgme.project_info import DictInfo46from pkgme.project_info import DictInfo
4647
48from .utils import get_latest_stable_ubuntu_distroseries
49
50
47# XXX: is this the right place?51# XXX: is this the right place?
48LINTIAN_OVERRIDES_TEMPLATE = """52LINTIAN_OVERRIDES_TEMPLATE = """
49#Partner package contents belong in /opt53#Partner package contents belong in /opt
@@ -250,6 +254,9 @@
250 """Get the package description."""254 """Get the package description."""
251 return metadata.get(self.DESCRIPTION, '')255 return metadata.get(self.DESCRIPTION, '')
252256
257 def get_distribution(self, metadata):
258 return get_latest_stable_ubuntu_distroseries()
259
253 def get_executable(self, package_name):260 def get_executable(self, package_name):
254 """Return the path to the executable."""261 """Return the path to the executable."""
255 raise NotImplementedError(self.get_executable)262 raise NotImplementedError(self.get_executable)
@@ -415,6 +422,7 @@
415 ]422 ]
416 OPTIONAL_ELEMENTS = [423 OPTIONAL_ELEMENTS = [
417 Architecture,424 Architecture,
425 Distribution,
418 ExtraFilesFromPaths,426 ExtraFilesFromPaths,
419 Maintainer,427 Maintainer,
420 Version,428 Version,
421429
=== modified file 'devportalbinary/tests/test_metadata.py'
--- devportalbinary/tests/test_metadata.py 2012-07-06 15:58:03 +0000
+++ devportalbinary/tests/test_metadata.py 2012-07-16 06:56:18 +0000
@@ -12,6 +12,7 @@
12 BuildDepends,12 BuildDepends,
13 Description,13 Description,
14 Depends,14 Depends,
15 Distribution,
15 ExtraFiles,16 ExtraFiles,
16 ExtraFilesFromPaths,17 ExtraFilesFromPaths,
17 Homepage,18 Homepage,
@@ -66,6 +67,16 @@
6667
67 BACKEND = DummyBackend68 BACKEND = DummyBackend
6869
70 def setUp(self):
71 super(MetadataTests, self).setUp()
72 # mock this for all tests to ensure we do not slow down because
73 # of network access
74 patcher = patch(
75 'devportalbinary.metadata.get_latest_stable_ubuntu_distroseries')
76 mock_get_latest_distroseries = patcher.start()
77 mock_get_latest_distroseries.return_value = 'foo'
78 self.addCleanup(patcher.stop)
79
69 def test_metadata_file(self):80 def test_metadata_file(self):
70 self.assertEqual('devportal-metadata.json', MetadataBackend.METADATA_FILE)81 self.assertEqual('devportal-metadata.json', MetadataBackend.METADATA_FILE)
7182
@@ -264,6 +275,7 @@
264 BuildDepends: ('build_depends', metadata),275 BuildDepends: ('build_depends', metadata),
265 Depends: ('depends', metadata),276 Depends: ('depends', metadata),
266 Description: ('description', metadata),277 Description: ('description', metadata),
278 Distribution: 'foo',
267 ExtraFiles: backend.get_extra_files(metadata, package_name),279 ExtraFiles: backend.get_extra_files(metadata, package_name),
268 PackageName: package_name,280 PackageName: package_name,
269 License: "unknown",281 License: "unknown",
@@ -281,6 +293,7 @@
281 {BuildDepends: ('build_depends', metadata),293 {BuildDepends: ('build_depends', metadata),
282 Depends: ('depends', metadata),294 Depends: ('depends', metadata),
283 Description: ('description', metadata),295 Description: ('description', metadata),
296 Distribution: 'foo',
284 ExtraFiles: backend.get_extra_files(metadata, package_name),297 ExtraFiles: backend.get_extra_files(metadata, package_name),
285 PackageName: package_name,298 PackageName: package_name,
286 License: "unknown",299 License: "unknown",
@@ -374,6 +387,11 @@
374 backend = self.make_backend()387 backend = self.make_backend()
375 self.assertEqual('Apache-2.0', backend.get_info(metadata)[License])388 self.assertEqual('Apache-2.0', backend.get_info(metadata)[License])
376389
390 def test_distribution(self):
391 metadata = self.make_metadata()
392 backend = self.make_backend()
393 self.assertEqual('foo', backend.get_info(metadata)[Distribution])
394
377395
378class DesktopFileTests(TestCase):396class DesktopFileTests(TestCase):
379397
380398
=== modified file 'devportalbinary/utils.py'
--- devportalbinary/utils.py 2012-04-12 16:23:09 +0000
+++ devportalbinary/utils.py 2012-07-16 06:56:18 +0000
@@ -11,6 +11,7 @@
11 )11 )
1212
13from bzrlib import urlutils13from bzrlib import urlutils
14from launchpadlib.launchpad import Launchpad
1415
1516
16def _open_file_for_writing(url, directory=None, name=None, working_dir=None):17def _open_file_for_writing(url, directory=None, name=None, working_dir=None):
@@ -64,3 +65,18 @@
64 os.close(fd)65 os.close(fd)
65 finally:66 finally:
66 download.close()67 download.close()
68
69
70_stable_ubuntu_distroseries = None
71def get_latest_stable_ubuntu_distroseries():
72 """Return the latest stable ubuntu release codename (e.g. "precise")"""
73 global _stable_ubuntu_distroseries
74 if _stable_ubuntu_distroseries is None:
75 # XXX: mvo wonders if a cachedir here would make sense
76 cachedir = None
77 launchpad = Launchpad.login_anonymously(
78 'pkgme-devportal', 'production', cachedir)
79 for distroseries in launchpad.distributions["ubuntu"].series:
80 if distroseries.status == 'Current Stable Release':
81 _stable_ubuntu_distroseries = distroseries.name
82 return _stable_ubuntu_distroseries

Subscribers

People subscribed via source and target branches