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
=== modified file 'lib/lp/registry/scripts/productreleasefinder/finder.py'
--- lib/lp/registry/scripts/productreleasefinder/finder.py 2009-07-17 00:26:05 +0000
+++ lib/lp/registry/scripts/productreleasefinder/finder.py 2009-10-25 17:05:27 +0000
@@ -47,7 +47,8 @@
47 'sparc',47 'sparc',
48 ])48 ])
49flavor_pattern = re.compile(r"""49flavor_pattern = re.compile(r"""
50 (_[a-z][a-z]_[A-Z][A-Z] # Language version50 (~ # Packaging target
51 |_[a-z][a-z]_[A-Z][A-Z] # or language version
51 |_(%s) # or processor version52 |_(%s) # or processor version
52 |[\.-](win32|OSX) # or OS version53 |[\.-](win32|OSX) # or OS version
53 |\.(deb|noarch|rpm|dmg|exe) # or packaging version54 |\.(deb|noarch|rpm|dmg|exe) # or packaging version
@@ -139,9 +140,10 @@
139 self.log.debug("File in %s found that matched no glob: %s",140 self.log.debug("File in %s found that matched no glob: %s",
140 product_name, url)141 product_name, url)
141142
142 def hasReleaseTarball(self, product_name, series_name, release_name):143 def hasReleaseFile(self, product_name, series_name,
144 release_name, filename):
143 """Return True if we have a tarball for the given product release."""145 """Return True if we have a tarball for the given product release."""
144 has_tarball = False146 has_file = False
145 self.ztm.begin()147 self.ztm.begin()
146 try:148 try:
147 product = getUtility(IProductSet).getByName(product_name)149 product = getUtility(IProductSet).getByName(product_name)
@@ -151,13 +153,12 @@
151 release = series.getRelease(release_name)153 release = series.getRelease(release_name)
152 if release is not None:154 if release is not None:
153 for fileinfo in release.files:155 for fileinfo in release.files:
154 if (fileinfo.filetype156 if filename == fileinfo.libraryfile.filename:
155 == UpstreamFileType.CODETARBALL):157 has_file = True
156 has_tarball = True
157 break158 break
158 finally:159 finally:
159 self.ztm.abort()160 self.ztm.abort()
160 return has_tarball161 return has_file
161162
162 def addReleaseTarball(self, product_name, series_name, release_name,163 def addReleaseTarball(self, product_name, series_name, release_name,
163 filename, size, file, content_type):164 filename, size, file, content_type):
@@ -221,7 +222,7 @@
221 version, url)222 version, url)
222 return223 return
223224
224 if self.hasReleaseTarball(product_name, series_name, version):225 if self.hasReleaseFile(product_name, series_name, version, filename):
225 self.log.debug("Already have a tarball for release %s", version)226 self.log.debug("Already have a tarball for release %s", version)
226 return227 return
227228
228229
=== modified file 'lib/lp/registry/tests/test_prf_finder.py'
--- lib/lp/registry/tests/test_prf_finder.py 2009-07-17 00:26:05 +0000
+++ lib/lp/registry/tests/test_prf_finder.py 2009-10-25 17:05:27 +0000
@@ -168,21 +168,31 @@
168 ztm = self.layer.txn168 ztm = self.layer.txn
169 logging.basicConfig(level=logging.CRITICAL)169 logging.basicConfig(level=logging.CRITICAL)
170 prf = ProductReleaseFinder(ztm, logging.getLogger())170 prf = ProductReleaseFinder(ztm, logging.getLogger())
171 file_name = 'evolution-42.0.orig.tar.gz'
172 alt_file_name = 'evolution-42.0.orig.tar.bz2'
171173
172 # create a release tarball174 # create a release tarball
173 fp = open(os.path.join(175 fp = open(os.path.join(
174 self.release_root, 'evolution-42.0.orig.tar.gz'), 'w')176 self.release_root, file_name), 'w')
175 fp.write('foo')177 fp.write('foo')
176 fp.close()178 fp.close()
177179
178 self.assertEqual(prf.hasReleaseTarball('evolution', 'trunk', '42.0'),180 self.assertEqual(
179 False)181 prf.hasReleaseFile('evolution', 'trunk', '42.0', file_name),
180182 False)
181 prf.handleRelease('evolution', 'trunk',183 self.assertEqual(
182 self.release_url + '/evolution-42.0.orig.tar.gz')184 prf.hasReleaseFile('evolution', 'trunk', '42.0', alt_file_name),
183185 False)
184 self.assertEqual(prf.hasReleaseTarball('evolution', 'trunk', '42.0'),186
185 True)187 prf.handleRelease(
188 'evolution', 'trunk', self.release_url + '/' + file_name)
189
190 self.assertEqual(
191 prf.hasReleaseFile('evolution', 'trunk', '42.0', file_name),
192 True)
193 self.assertEqual(
194 prf.hasReleaseFile('evolution', 'trunk', '42.0', alt_file_name),
195 False)
186196
187 # check to see that the release has been created197 # check to see that the release has been created
188 evo = getUtility(IProductSet).getByName('evolution')198 evo = getUtility(IProductSet).getByName('evolution')
@@ -192,8 +202,7 @@
192 self.assertEqual(release.files.count(), 1)202 self.assertEqual(release.files.count(), 1)
193 fileinfo = release.files[0]203 fileinfo = release.files[0]
194 self.assertEqual(fileinfo.filetype, UpstreamFileType.CODETARBALL)204 self.assertEqual(fileinfo.filetype, UpstreamFileType.CODETARBALL)
195 self.assertEqual(fileinfo.libraryfile.filename,205 self.assertEqual(fileinfo.libraryfile.filename, file_name)
196 'evolution-42.0.orig.tar.gz')
197206
198 # verify that the fileinfo object is sane207 # verify that the fileinfo object is sane
199 self.failUnless(verifyObject(IProductReleaseFile, fileinfo))208 self.failUnless(verifyObject(IProductReleaseFile, fileinfo))
@@ -345,6 +354,8 @@
345 self.assertEqual(version, '1.16.3')354 self.assertEqual(version, '1.16.3')
346 version = extract_version('partitionmanager-21-2.noarch.rpm')355 version = extract_version('partitionmanager-21-2.noarch.rpm')
347 self.assertEqual(version, '21-2')356 self.assertEqual(version, '21-2')
357 version = extract_version('php-fpm-0.6~5.3.1.tar.gz')
358 self.assertEqual(version, '0.6')
348359
349 def test_extract_version_name_with_uppercase(self):360 def test_extract_version_name_with_uppercase(self):
350 """Verify that the file's version is lowercases."""361 """Verify that the file's version is lowercases."""