Merge lp:~sinzui/launchpad/prf-flavor-loop into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~sinzui/launchpad/prf-flavor-loop
Merge into: lp:launchpad
Diff against target: 116 lines
2 files modified
lib/lp/registry/scripts/productreleasefinder/finder.py (+9/-8)
lib/lp/registry/tests/test_prf_finder.py (+22/-11)
To merge this branch: bzr merge lp:~sinzui/launchpad/prf-flavor-loop
Reviewer Review Type Date Requested Status
Eleanor Berger (community) code Approve
Review via email: mp+13919@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

This is my branch to fix the flavor striping and file upload looping rules in
the product release finder.

    lp:~sinzui/launchpad/prf-flavor-loop
    Diff size: 117
    Launchpad bug: https://bugs.launchpad.net/bugs/456525
                   https://bugs.launchpad.net/bugs/415595
    Test command: ./bin/test -vv -t "test_prf_finder"
    Pre-implementation: dreamcat4 and suraia, both of whom read the source
                        code with me as we diagnosed why their files were
                        missing.
    Target release: 3.1.10

= Fix the flavor striping and looping rules in the product release finder =

Bug #456525 [PRF does not strip the flavor info after the ~]
    The releases version are incorrect because the ~ that marked the start of
    the flavor information was converted to a -.

Bug #415595 [PRF should import all files]
    For example, I have sushi-1.0.1.tar.bz2 and sushi-1.0.1.tar.gz, but the
    release finder only imports the .tar.bz2. Looking at the code it seems
    that only the first matching file is added.

== Rules ==

Bug #456525 [PRF does not strip the flavor info after the ~]
    Add the '~' to the flavor_pattern.

Bug #415595 [PRF should import all files]
    hasReleaseTarball() wrongly assumes that if the release has anything like
    a code tarball, that there all the downloading is complete. So downloading
    for a release stops once the first package is downloaded which means
    release notes and installers are also being ignored.

    handleRelease() knows the filename. It should pass it to
    hasReleaseTarball() to verify if the release already has the file. Rename
    hasReleaseTarball => hasReleaseFile(self, product_name, series_name,
    release_name, file_name)

== QA ==

    * Run the PRF
    * Visit project php-fpm
    * Verify the 0.6 release exists and it has php-fpm-0.6~5.3.1.tar.gz
    * Visit /sushi.nigiri/1.0
    * Visit several of the release.
    * Verify that each has more than one milestone.

== Lint ==

Linting changed files:
  lib/lp/registry/scripts/productreleasefinder/finder.py
  lib/lp/registry/tests/test_prf_finder.py

== Test ==

    * lib/lp/registry/tests/test_prf_finder.py
      * Added a test to verify the file and an alternate file are handled
        correctly before and after one it uploaded.
      * Added a test to verify that the release.version (AKA milestone.name)
        does not contain the flavor information from the '~'.

== Implementation ==

    * lib/lp/registry/scripts/productreleasefinder/finder.py
      * Updated the flavor_pattern rules to match '~'.
      * Renamed hasReleaseTarball => hasReleaseFile and added the filename
        argument. The method now matches on file name, not file tpe so that
        a tar.gz and tar.bzr will both be uploded. This will also allow
        multiple tar.gz that contain flavor info in the name to be uploaded.

Revision history for this message
Eleanor Berger (intellectronica) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/scripts/productreleasefinder/finder.py'
2--- lib/lp/registry/scripts/productreleasefinder/finder.py 2009-07-17 00:26:05 +0000
3+++ lib/lp/registry/scripts/productreleasefinder/finder.py 2009-10-25 17:05:27 +0000
4@@ -47,7 +47,8 @@
5 'sparc',
6 ])
7 flavor_pattern = re.compile(r"""
8- (_[a-z][a-z]_[A-Z][A-Z] # Language version
9+ (~ # Packaging target
10+ |_[a-z][a-z]_[A-Z][A-Z] # or language version
11 |_(%s) # or processor version
12 |[\.-](win32|OSX) # or OS version
13 |\.(deb|noarch|rpm|dmg|exe) # or packaging version
14@@ -139,9 +140,10 @@
15 self.log.debug("File in %s found that matched no glob: %s",
16 product_name, url)
17
18- def hasReleaseTarball(self, product_name, series_name, release_name):
19+ def hasReleaseFile(self, product_name, series_name,
20+ release_name, filename):
21 """Return True if we have a tarball for the given product release."""
22- has_tarball = False
23+ has_file = False
24 self.ztm.begin()
25 try:
26 product = getUtility(IProductSet).getByName(product_name)
27@@ -151,13 +153,12 @@
28 release = series.getRelease(release_name)
29 if release is not None:
30 for fileinfo in release.files:
31- if (fileinfo.filetype
32- == UpstreamFileType.CODETARBALL):
33- has_tarball = True
34+ if filename == fileinfo.libraryfile.filename:
35+ has_file = True
36 break
37 finally:
38 self.ztm.abort()
39- return has_tarball
40+ return has_file
41
42 def addReleaseTarball(self, product_name, series_name, release_name,
43 filename, size, file, content_type):
44@@ -221,7 +222,7 @@
45 version, url)
46 return
47
48- if self.hasReleaseTarball(product_name, series_name, version):
49+ if self.hasReleaseFile(product_name, series_name, version, filename):
50 self.log.debug("Already have a tarball for release %s", version)
51 return
52
53
54=== modified file 'lib/lp/registry/tests/test_prf_finder.py'
55--- lib/lp/registry/tests/test_prf_finder.py 2009-07-17 00:26:05 +0000
56+++ lib/lp/registry/tests/test_prf_finder.py 2009-10-25 17:05:27 +0000
57@@ -168,21 +168,31 @@
58 ztm = self.layer.txn
59 logging.basicConfig(level=logging.CRITICAL)
60 prf = ProductReleaseFinder(ztm, logging.getLogger())
61+ file_name = 'evolution-42.0.orig.tar.gz'
62+ alt_file_name = 'evolution-42.0.orig.tar.bz2'
63
64 # create a release tarball
65 fp = open(os.path.join(
66- self.release_root, 'evolution-42.0.orig.tar.gz'), 'w')
67+ self.release_root, file_name), 'w')
68 fp.write('foo')
69 fp.close()
70
71- self.assertEqual(prf.hasReleaseTarball('evolution', 'trunk', '42.0'),
72- False)
73-
74- prf.handleRelease('evolution', 'trunk',
75- self.release_url + '/evolution-42.0.orig.tar.gz')
76-
77- self.assertEqual(prf.hasReleaseTarball('evolution', 'trunk', '42.0'),
78- True)
79+ self.assertEqual(
80+ prf.hasReleaseFile('evolution', 'trunk', '42.0', file_name),
81+ False)
82+ self.assertEqual(
83+ prf.hasReleaseFile('evolution', 'trunk', '42.0', alt_file_name),
84+ False)
85+
86+ prf.handleRelease(
87+ 'evolution', 'trunk', self.release_url + '/' + file_name)
88+
89+ self.assertEqual(
90+ prf.hasReleaseFile('evolution', 'trunk', '42.0', file_name),
91+ True)
92+ self.assertEqual(
93+ prf.hasReleaseFile('evolution', 'trunk', '42.0', alt_file_name),
94+ False)
95
96 # check to see that the release has been created
97 evo = getUtility(IProductSet).getByName('evolution')
98@@ -192,8 +202,7 @@
99 self.assertEqual(release.files.count(), 1)
100 fileinfo = release.files[0]
101 self.assertEqual(fileinfo.filetype, UpstreamFileType.CODETARBALL)
102- self.assertEqual(fileinfo.libraryfile.filename,
103- 'evolution-42.0.orig.tar.gz')
104+ self.assertEqual(fileinfo.libraryfile.filename, file_name)
105
106 # verify that the fileinfo object is sane
107 self.failUnless(verifyObject(IProductReleaseFile, fileinfo))
108@@ -345,6 +354,8 @@
109 self.assertEqual(version, '1.16.3')
110 version = extract_version('partitionmanager-21-2.noarch.rpm')
111 self.assertEqual(version, '21-2')
112+ version = extract_version('php-fpm-0.6~5.3.1.tar.gz')
113+ self.assertEqual(version, '0.6')
114
115 def test_extract_version_name_with_uppercase(self):
116 """Verify that the file's version is lowercases."""