← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/ids-fix into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/ids-fix into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #830978 in Launchpad itself: "The call to IDS.check in initDerivedDistroSeries should include the parameters architectures and packagesets."
  https://bugs.launchpad.net/launchpad/+bug/830978

For more details, see:
https://code.launchpad.net/~rvb/launchpad/ids-fix/+merge/72398

This branch fixes the call to IDS.check in initDerivedDistroSeries to also include the other parameters passed to initDerivedDistroSeries. Now the checks performed by IDS are more specific and in particular, they need the parameters architectures and packagesets.

= Tests =

./bin/test -vvc test_initderiveddistroseries test_arch_check_performed
./bin/test -vvc test_initderiveddistroseries test_packageset_check_performed

= QA =

I'll land this with no-qa because the QA for this will be part of the QA in progress for 820452.
-- 
https://code.launchpad.net/~rvb/launchpad/ids-fix/+merge/72398
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/ids-fix into lp:launchpad.
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py	2011-08-15 03:41:35 +0000
+++ lib/lp/registry/model/distroseries.py	2011-08-22 10:29:26 +0000
@@ -1821,7 +1821,9 @@
         if self.isDerivedSeries():
             raise DerivationError(
                 "DistroSeries %s already has parent series." % self.name)
-        initialize_series = InitializeDistroSeries(self, parents)
+        initialize_series = InitializeDistroSeries(
+            self, parents, architectures, packagesets, rebuild, overlays,
+            overlay_pockets, overlay_components)
         try:
             initialize_series.check()
         except InitializationError, e:
@@ -1829,6 +1831,7 @@
         getUtility(IInitializeDistroSeriesJobSource).create(
             self, parents, architectures, packagesets, rebuild, overlays,
             overlay_pockets, overlay_components)
+        return True
 
     def getParentSeries(self):
         """See `IDistroSeriesPublic`."""

=== modified file 'lib/lp/registry/tests/test_initderiveddistroseries.py'
--- lib/lp/registry/tests/test_initderiveddistroseries.py	2011-07-15 16:18:00 +0000
+++ lib/lp/registry/tests/test_initderiveddistroseries.py	2011-08-22 10:29:26 +0000
@@ -163,3 +163,34 @@
         # Switch back to launchpad_main to be able to cleanup the
         # feature flags.
         self.layer.switchDbUser('launchpad_main')
+
+    def test_packageset_check_performed(self):
+        # Packagesets passed to initDerivedDistroSeries are passed down
+        # to InitializeDistroSeries to check for any pending builds.
+        parent, parent_das = self.setupParent()
+        # Create packageset p1 with a build.
+        p1, packageset1, unsed = self.createPackageInPackageset(
+            parent, u'p1', u'packageset1', True)
+        # Create packageset p2 without a build.
+        p2, packageset2, unsed = self.createPackageInPackageset(
+            parent, u'p2', u'packageset2', False)
+        child = self.factory.makeDistroSeries(
+            distribution=parent.distribution, previous_series=parent)
+
+        # Packageset p2 has no build.
+        self.assertTrue(child.initDerivedDistroSeries(
+            child.driver, [parent.id], (), (str(packageset2.id),)))
+
+    def test_arch_check_performed(self):
+        # Architectures passed to initDerivedDistroSeries are passed down
+        # to InitializeDistroSeries to check for any pending builds.
+        res = self.create2archParentAndSource(packages={'p1': '1.1'})
+        parent, parent_das, parent_das2, source = res
+        # Create builds for the architecture of parent_das2.
+        source.createMissingBuilds(architectures_available=[parent_das2])
+        child = self.factory.makeDistroSeries(
+            distribution=parent.distribution, previous_series=parent)
+
+        # Initialize only with parent_das's architecture.
+        self.assertTrue(child.initDerivedDistroSeries(
+            child.driver, [parent.id], (parent_das.architecturetag, ), ()))

=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py	2011-08-16 16:11:16 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py	2011-08-22 10:29:26 +0000
@@ -134,6 +134,39 @@
         ids.initialize()
         return child
 
+    def createPackageInPackageset(self, distroseries, package_name,
+                                  packageset_name, create_build=False):
+        # Helper method to create a package in a packageset in the given
+        # distroseries, optionaly creating the missing build for this source
+        # package.
+        spn = self.factory.getOrMakeSourcePackageName(package_name)
+        sourcepackagerelease = self.factory.makeSourcePackageRelease(
+            sourcepackagename=spn)
+        source = self.factory.makeSourcePackagePublishingHistory(
+            sourcepackagerelease=sourcepackagerelease,
+            distroseries=distroseries,
+            sourcepackagename=spn,
+            pocket=PackagePublishingPocket.RELEASE)
+        packageset = getUtility(IPackagesetSet).new(
+            packageset_name, packageset_name, distroseries.owner,
+            distroseries=distroseries)
+        packageset.addSources(package_name)
+        if create_build:
+            source.createMissingBuilds()
+        return source, packageset, sourcepackagerelease
+
+    def create2archParentAndSource(self, packages):
+        # Helper to create a parent series with 2 distroarchseries and
+        # a source.
+        parent, parent_das = self.setupParent(packages=packages)
+        unused, parent_das2 = self.setupParent(
+            parent=parent, proc='amd64', arch_tag='amd64',
+            packages=packages)
+        source = self.factory.makeSourcePackagePublishingHistory(
+            distroseries=parent,
+            pocket=PackagePublishingPocket.RELEASE)
+        return parent, parent_das, parent_das2, source
+
 
 class TestInitializeDistroSeries(InitializationHelperTestCase):
 
@@ -212,18 +245,6 @@
             ids = InitializeDistroSeries(child, [self.parent.id])
             self.assertTrue(ids.check())
 
-    def create2archParentAndSource(self, packages):
-        # Helper to create a parent series with 2 distroarchseries and
-        # a source.
-        parent, parent_das = self.setupParent(packages=packages)
-        unused, parent_das2 = self.setupParent(
-            parent=parent, proc='amd64', arch_tag='amd64',
-            packages=packages)
-        source = self.factory.makeSourcePackagePublishingHistory(
-            distroseries=parent,
-            pocket=PackagePublishingPocket.RELEASE)
-        return parent, parent_das, parent_das2, source
-
     def test_failure_with_pending_builds_specific_arches(self):
         # We only check for pending builds of the same architectures we're
         # copying over from the parents. If a build is present in the
@@ -262,27 +283,6 @@
         # which has no pending builds in it.
         self.assertTrue(ids.check())
 
-    def createPackageInPackageset(self, distroseries, package_name,
-                                  packageset_name, create_build=False):
-        # Helper method to create a package in a packageset in the given
-        # distroseries, optionaly creating the missing build for this source
-        # package.
-        spn = self.factory.getOrMakeSourcePackageName(package_name)
-        sourcepackagerelease = self.factory.makeSourcePackageRelease(
-            sourcepackagename=spn)
-        source = self.factory.makeSourcePackagePublishingHistory(
-            sourcepackagerelease=sourcepackagerelease,
-            distroseries=distroseries,
-            sourcepackagename=spn,
-            pocket=PackagePublishingPocket.RELEASE)
-        packageset = getUtility(IPackagesetSet).new(
-            packageset_name, packageset_name, distroseries.owner,
-            distroseries=distroseries)
-        packageset.addSources(package_name)
-        if create_build:
-            source.createMissingBuilds()
-        return source, packageset, sourcepackagerelease
-
     def test_failure_if_build_present_in_selected_packagesets(self):
         # Pending builds in a parent for source packages included in the
         # packagesets selected for the copy will make the queue check fail.