launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04352
[Merge] lp:~rvb/launchpad/use-copier-first-init-bug-814643 into lp:launchpad
Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/use-copier-first-init-bug-814643 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #814643 in Launchpad itself: "Don't use the cloner for FIRST initializations because it only considers the release pocket."
https://bugs.launchpad.net/launchpad/+bug/814643
For more details, see:
https://code.launchpad.net/~rvb/launchpad/use-copier-first-init-bug-814643/+merge/69052
This branch makes it so that we use the package copier for first-initializing a series (https://dev.launchpad.net/LEP/DerivativeDistributions#Vocabulary). This is required because only the package copier (as opposed to the package cloner) copies packages other that only those in the RELEASE pocket and because the plan is to get rid of the cloner eventually.
= Tests =
./bin/test -vvc test_initialize_distroseries test_copy_method_first_derivation
= QA =
This should be marked as qa-untestable for now and properly tested as part of the fix for https://bugs.launchpad.net/launchpad/+bug/815751 (it will fix the call to the copier to call it with 3 pockets: RELEASED, UPDATES, SECURITY).
--
https://code.launchpad.net/~rvb/launchpad/use-copier-first-init-bug-814643/+merge/69052
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/use-copier-first-init-bug-814643 into lp:launchpad.
=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
--- lib/lp/soyuz/scripts/initialize_distroseries.py 2011-07-22 11:12:23 +0000
+++ lib/lp/soyuz/scripts/initialize_distroseries.py 2011-07-25 09:49:26 +0000
@@ -309,9 +309,10 @@
sqlvalues(self.arches))
self._store.execute("""
INSERT INTO DistroArchSeries
- (distroseries, processorfamily, architecturetag, owner, official)
+ (distroseries, processorfamily, architecturetag, owner, official,
+ supports_virtualized)
SELECT %s, processorfamily, architecturetag, %s,
- bool_and(official)
+ bool_and(official), bool_or(supports_virtualized)
FROM DistroArchSeries WHERE enabled = TRUE %s
GROUP BY processorfamily, architecturetag
""" % (sqlvalues(self.distroseries, self.distroseries.owner)
@@ -344,27 +345,33 @@
self._copy_publishing_records(distroarchseries_lists)
self._copy_packaging_links()
- @classmethod
- def _use_cloner(cls, target_archive, archive, distroseries):
+ def _use_cloner(self, target_archive, archive):
"""Returns True if it's safe to use the packagecloner (as opposed
to using the packagecopier).
We use two different ways to copy packages:
- the packagecloner: fast but not conflict safe.
- the packagecopier: slow but performs lots of checks to
avoid creating conflicts.
- 1a. If the archives are different and the target archive is
- empty use the cloner.
- 1b. If the archives are the same and the target series is
- empty use the cloner.
+ 1. We'll use the cloner:
+ If this is not a first initialization.
+ And If:
+ 1.a If the archives are different and the target archive is
+ empty use the cloner.
+ Or
+ 1.b. If the archives are the same and the target series is
+ empty use the cloner.
2. Otherwise use the copier.
"""
+ if self.first_derivation:
+ return False
+
target_archive_empty = target_archive.getPublishedSources().is_empty()
case_1a = (target_archive != archive and
target_archive_empty)
case_1b = (target_archive == archive and
(target_archive_empty or
target_archive.getPublishedSources(
- distroseries=distroseries).is_empty()))
+ distroseries=self.distroseries).is_empty()))
return case_1a or case_1b
def _copy_publishing_records(self, distroarchseries_lists):
@@ -406,8 +413,7 @@
if archive.purpose is ArchivePurpose.PRIMARY:
assert target_archive is not None, (
"Target archive doesn't exist?")
- if self._use_cloner(
- target_archive, archive, self.distroseries):
+ if self._use_cloner(target_archive, archive):
origin = PackageLocation(
archive, parent.distribution, parent,
PackagePublishingPocket.RELEASE)
@@ -441,7 +447,8 @@
close_bugs=False, create_dsd_job=False)
if self.rebuild:
for pubrec in sources_published:
- pubrec.createMissingBuilds()
+ pubrec.createMissingBuilds(
+ list(self.distroseries.architectures))
except CannotCopy, error:
raise InitializationError(error)
=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2011-07-22 11:12:23 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2011-07-25 09:49:26 +0000
@@ -24,7 +24,10 @@
from lp.registry.interfaces.distroseriesparent import IDistroSeriesParentSet
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.features.testing import FeatureFixture
-from lp.soyuz.enums import SourcePackageFormat
+from lp.soyuz.enums import (
+ ArchivePurpose,
+ SourcePackageFormat,
+ )
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
from lp.soyuz.interfaces.component import IComponentSet
from lp.soyuz.interfaces.packageset import (
@@ -38,18 +41,16 @@
)
from lp.soyuz.model.component import ComponentSelection
from lp.soyuz.model.distroarchseries import DistroArchSeries
+from lp.soyuz.model.distroseriesdifferencejob import (
+ FEATURE_FLAG_ENABLE_MODULE,
+ find_waiting_jobs,
+ )
from lp.soyuz.model.section import SectionSelection
from lp.soyuz.scripts.initialize_distroseries import (
InitializationError,
InitializeDistroSeries,
)
from lp.testing import TestCaseWithFactory
-from lp.soyuz.model.distroseriesdifferencejob import (
- FEATURE_FLAG_ENABLE_MODULE,
- )
-from lp.soyuz.model.distroseriesdifferencejob import (
- find_waiting_jobs
- )
class InitializationHelperTestCase(TestCaseWithFactory):
@@ -803,68 +804,84 @@
".").format(child=child),
ids.check)
+ def createDistroSeriesWithPublication(self, distribution=None):
+ # Create a distroseries with a publication in the DEBUG archive.
+ distroseries = self.factory.makeDistroSeries(
+ distribution=distribution)
+ # Publish a package in another archive in distroseries' distribution.
+ debug_archive = self.factory.makeArchive(
+ distribution=distroseries.distribution,
+ purpose=ArchivePurpose.DEBUG)
+
+ self.factory.makeSourcePackagePublishingHistory(
+ distroseries=distroseries, archive=debug_archive)
+ return distroseries
+
def test_copy_method_diff_archive_empty_target(self):
# If the archives are different and the target archive is
# empty: use the cloner.
- archive = self.factory.makeArchive()
- distroseries = self.factory.makeDistroSeries()
- target_archive = distroseries.main_archive
-
- self.assertTrue(
- InitializeDistroSeries._use_cloner(
- target_archive, archive, distroseries))
-
- def test_copy_method_same_archive_empty_series(self):
- # If the archives are the same and the target series is
- # empty: use the cloner.
- distroseries = self.factory.makeDistroSeries()
- target_archive = distroseries.main_archive
-
- self.assertTrue(
- InitializeDistroSeries._use_cloner(
- target_archive, target_archive, distroseries))
+ distroseries = self.createDistroSeriesWithPublication()
+ parent = self.factory.makeDistroSeries()
+ target_archive = distroseries.main_archive
+
+ ids = InitializeDistroSeries(distroseries, [parent.id])
+ self.assertTrue(
+ ids._use_cloner(
+ target_archive, parent.main_archive))
+
+ def test_copy_method_first_derivation(self):
+ # If this is a first derivation: do not use the copier.
+ parent = self.factory.makeDistroSeries()
+ distroseries = self.factory.makeDistroSeries()
+ target_archive = distroseries.main_archive
+ ids = InitializeDistroSeries(distroseries, [parent.id])
+
+ self.assertFalse(
+ ids._use_cloner(target_archive, target_archive))
def test_copy_method_same_archive_empty_series_non_empty_archive(self):
- # If the archives are the same and the target series is
- # empty (another series in the same distribution
+ # In a post-first derivation, if the archives are the same and the
+ # target series is empty (another series in the same distribution
# might not be empty): use the cloner.
- distroseries = self.factory.makeDistroSeries()
+ parent = self.factory.makeDistroSeries()
+ distroseries = self.createDistroSeriesWithPublication()
other_distroseries = self.factory.makeDistroSeries(
distribution=distroseries.distribution)
self.factory.makeSourcePackagePublishingHistory(
distroseries=other_distroseries)
target_archive = distroseries.main_archive
+ ids = InitializeDistroSeries(distroseries, [parent.id])
self.assertTrue(
- InitializeDistroSeries._use_cloner(
- target_archive, target_archive, distroseries))
+ ids._use_cloner(target_archive, target_archive))
def test_copy_method_diff_archive_non_empty_target(self):
- # If the archives are different and the target archive is
- # *not* empty: don't use the cloner.
- archive = self.factory.makeArchive()
+ # In a post-first derivation, if the archives are different and the
+ # target archive is *not* empty: don't use the cloner.
+ parent = self.factory.makeDistroSeries()
distroseries = self.factory.makeDistroSeries()
target_archive = distroseries.main_archive
other_distroseries = self.factory.makeDistroSeries(
distribution=distroseries.distribution)
self.factory.makeSourcePackagePublishingHistory(
distroseries=other_distroseries)
+ ids = InitializeDistroSeries(distroseries, [parent.id])
self.assertFalse(
- InitializeDistroSeries._use_cloner(
- target_archive, archive, distroseries))
+ ids._use_cloner(target_archive, parent.main_archive))
def test_copy_method_same_archive_non_empty_series(self):
- # If the archives are the same and the target series is
- # *not* empty: don't use the cloner.
+ # In a post-first derivation, if the archives are the same and the
+ # target series is *not* empty: don't use the cloner.
+ parent = self.factory.makeDistroSeries()
distroseries = self.factory.makeDistroSeries()
self.factory.makeSourcePackagePublishingHistory(
distroseries=distroseries)
target_archive = distroseries.main_archive
+ ids = InitializeDistroSeries(distroseries, [parent.id])
self.assertFalse(
- InitializeDistroSeries._use_cloner(
- target_archive, target_archive, distroseries))
+ ids._use_cloner(target_archive, target_archive))
def test__has_same_parents_as_previous_series_explicit(self):
# IDS._has_same_parents_as_previous_series returns True if the
References