launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03287
[Merge] lp:~stevenk/launchpad/ids-bugfixes into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/ids-bugfixes into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/ids-bugfixes/+merge/57270
A bunch of bug fixes and clean-ups for IDS and IDSJ.
Firstly, I removed the IDSJ runner cronscript, since the more generic 'run_jobs' script can handle it with the addition of one line to the schema -- the cronscript is not currently running anywhere, so no config changes are needed.
Fix what looks like a bad call of Store.find, but I'm somewhat surprised that tests didn't pick it up.
No longer check for pending builds during IDS. We copy all sources (SPPHs), and binaries (BPPHs), but that doesn't involve making a copy the build information (BPBs), so we should be fine.
Set the parent of the child distroseries last, so other parts of Launchpad (notably the UI) can tell when initialisation is completed.
Flush the store of DistroSeries after we have copied them, so we can set the NAI (Nominated Arch-Indep) correctly.
Always set processor families so it can be passed into the package cloner -- this means it will always create missing builds.
--
https://code.launchpad.net/~stevenk/launchpad/ids-bugfixes/+merge/57270
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/ids-bugfixes into lp:launchpad.
=== removed file 'cronscripts/initialise_distro_series.py'
--- cronscripts/initialise_distro_series.py 2010-10-08 06:22:10 +0000
+++ cronscripts/initialise_distro_series.py 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
-#!/usr/bin/python -S
-#
-# Copyright 2010 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Initialise new distroseries."""
-
-__metaclass__ = type
-
-import _pythonpath
-
-from lp.services.job.runner import JobCronScript
-from lp.soyuz.interfaces.distributionjob import (
- IInitialiseDistroSeriesJobSource,
- )
-
-
-class RunInitialiseDistroSeriesJob(JobCronScript):
- """Run InitialiseDistroSeriesJob jobs."""
-
- config_name = 'initialisedistroseries'
- source_interface = IInitialiseDistroSeriesJobSource
-
-
-if __name__ == '__main__':
- script = RunInitialiseDistroSeriesJob()
- script.lock_and_run()
=== modified file 'lib/canonical/config/schema-lazr.conf'
--- lib/canonical/config/schema-lazr.conf 2011-04-08 04:23:51 +0000
+++ lib/canonical/config/schema-lazr.conf 2011-04-12 05:01:17 +0000
@@ -966,6 +966,7 @@
[initialisedistroseries]
dbuser: initialisedistroseries
+source_interface: lp.soyuz.interfaces.distributionjob.IInitialiseDistroSeriesJobSource
# See [error_reports].
error_dir: none
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2011-04-08 15:44:02 +0000
+++ lib/lp/registry/model/distroseries.py 2011-04-12 05:01:17 +0000
@@ -1947,7 +1947,9 @@
if distribution is None:
distribution = self.distribution
child = IStore(self).find(
- DistroSeries, name=name, distribution=distribution).one()
+ DistroSeries,
+ DistroSeries.name == name,
+ DistroSeries.distributionID == distribution.id).one()
if child is None:
if not displayname:
raise DerivationError(
=== modified file 'lib/lp/soyuz/scripts/initialise_distroseries.py'
--- lib/lp/soyuz/scripts/initialise_distroseries.py 2011-03-31 12:53:27 +0000
+++ lib/lp/soyuz/scripts/initialise_distroseries.py 2011-04-12 05:01:17 +0000
@@ -10,6 +10,7 @@
'InitialiseDistroSeries',
]
+import transaction
from zope.component import getUtility
from canonical.database.sqlbase import sqlvalues
@@ -79,24 +80,9 @@
"derives from {child.parent_series.distribution.name}/"
"{child.parent_series.name}.").format(
child=self.distroseries))
- self._checkBuilds()
self._checkQueue()
self._checkSeries()
- def _checkBuilds(self):
- """Assert there are no pending builds for parent series.
-
- Only cares about the RELEASE pocket, which is the only one inherited
- via initialiseFromParent method.
- """
- # only the RELEASE pocket is inherited, so we only check
- # pending build records for it.
- pending_builds = self.parent.getBuildRecords(
- BuildStatus.NEEDSBUILD, pocket=PackagePublishingPocket.RELEASE)
-
- if pending_builds.any():
- raise InitialisationError("Parent series has pending builds.")
-
def _checkQueue(self):
"""Assert upload queue is empty on parent series.
@@ -115,28 +101,25 @@
"Parent series queues are not empty.")
def _checkSeries(self):
- sources = self.distroseries.getAllPublishedSources()
error = (
"Can not copy distroarchseries from parent, there are "
"already distroarchseries(s) initialised for this series.")
- if bool(sources):
- raise InitialisationError(error)
+ sources = self.distroseries.getAllPublishedSources()
binaries = self.distroseries.getAllPublishedBinaries()
- if bool(binaries):
- raise InitialisationError(error)
- if bool(self.distroseries.architectures):
- raise InitialisationError(error)
- if bool(self.distroseries.components):
- raise InitialisationError(error)
- if bool(self.distroseries.sections):
+ if (
+ bool(sources) or bool(binaries) or
+ bool(self.distroseries.architectures) or
+ bool(self.distroseries.components) or
+ bool(self.distroseries.sections)):
raise InitialisationError(error)
def initialise(self):
- self._set_parent()
self._copy_configuration()
self._copy_architectures()
self._copy_packages()
self._copy_packagesets()
+ self._set_parent()
+ transaction.commit()
def _set_parent(self):
self.distroseries.parent_series = self.parent
@@ -157,7 +140,7 @@
AND enabled = TRUE %s
""" % (sqlvalues(self.distroseries, self.distroseries.owner,
self.parent) + (include,)))
-
+ self._store.flush()
self.distroseries.nominatedarchindep = self.distroseries[
self.parent.nominatedarchindep.architecturetag]
@@ -190,7 +173,7 @@
spns = []
# The overhead from looking up each packageset is mitigated by
- # this usually running from a job
+ # this usually running from a job.
if self.packagesets:
for pkgsetname in self.packagesets:
pkgset = getUtility(IPackagesetSet).getByName(
@@ -213,11 +196,10 @@
destination = PackageLocation(
target_archive, self.distroseries.distribution,
self.distroseries, PackagePublishingPocket.RELEASE)
- proc_families = None
+ proc_families = [
+ das[1].processorfamily
+ for das in distroarchseries_list]
if self.rebuild:
- proc_families = [
- das[1].processorfamily
- for das in distroarchseries_list]
distroarchseries_list = ()
getUtility(IPackageCloner).clonePackages(
origin, destination, distroarchseries_list,
@@ -280,7 +262,7 @@
WHERE distroseries in (
SELECT id
FROM Distroseries
- WHERE id = ChildSeries.parent_series
+ WHERE id = %s
)
EXCEPT
SELECT sourcepackagename
@@ -291,7 +273,7 @@
WHERE id = ChildSeries.id
)
)
- """ % self.distroseries.id)
+ """ % (self.distroseries.id, self.parent.id))
def _copy_packagesets(self):
"""Copy packagesets from the parent distroseries."""
=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2011-03-31 12:53:27 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2011-04-12 05:01:17 +0000
@@ -52,6 +52,7 @@
transaction.commit()
self.parent_das.addOrUpdateChroot(lf)
self.parent_das.supports_virtualized = True
+ self.parent.main_archive.require_virtualized = False
self.parent.nominatedarchindep = self.parent_das
getUtility(ISourcePackageFormatSelectionSet).add(
self.parent, SourcePackageFormat.FORMAT_1_0)
@@ -101,12 +102,17 @@
source = self.factory.makeSourcePackagePublishingHistory(
distroseries=self.parent,
pocket=PackagePublishingPocket.RELEASE)
- source.createMissingBuilds()
- child = self.factory.makeDistroSeries()
- ids = InitialiseDistroSeries(self.parent, child)
- self.assertRaisesWithContent(
- InitialisationError, "Parent series has pending builds.",
- ids.check)
+ [build] = source.createMissingBuilds()
+ build.status = BuildStatus.BUILDING
+ child = self._full_initialise()
+ self.assertDistroSeriesInitialisedCorrectly(child)
+ child.updatePackageCount()
+ building_builds = child.getBuildRecords(BuildStatus.BUILDING)
+ pending_builds = child.getBuildRecords(BuildStatus.NEEDSBUILD)
+ self.assertEqual(5, child.sourcecount)
+ self.assertEqual(0, building_builds.count())
+ # 1 build is chromium, which FTBFS, and the build created earlier.
+ self.assertEqual(2, pending_builds.count())
def test_failure_with_queue_items(self):
# If the parent series has items in its queues, such as NEW and
@@ -159,6 +165,7 @@
def _full_initialise(self, arches=(), packagesets=(), rebuild=False,
distribution=None):
child = self.factory.makeDistroSeries(distribution=distribution)
+ child.main_archive.require_virtualized = False
ids = InitialiseDistroSeries(
self.parent, child, arches, packagesets, rebuild)
ids.check()
=== modified file 'lib/lp/soyuz/tests/test_initialisedistroseriesjob.py'
--- lib/lp/soyuz/tests/test_initialisedistroseriesjob.py 2011-03-25 11:13:23 +0000
+++ lib/lp/soyuz/tests/test_initialisedistroseriesjob.py 2011-04-12 05:01:17 +0000
@@ -3,17 +3,13 @@
__metaclass__ = type
-import os
-import subprocess
-import sys
-
from storm.exceptions import IntegrityError
import transaction
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
-from canonical.config import config
from canonical.database.sqlbase import flush_database_caches
+from canonical.launchpad.scripts.tests import run_script
from canonical.testing import (
DatabaseFunctionalLayer,
LaunchpadZopelessLayer,
@@ -177,10 +173,5 @@
self.assertEqual(builds.count(), 1)
def test_cronscript(self):
- script = os.path.join(
- config.root, 'cronscripts', 'initialise_distro_series.py')
- args = [sys.executable, script, '-v']
- process = subprocess.Popen(
- args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout, stderr = process.communicate()
- self.assertEqual(process.returncode, 0)
+ run_script(
+ 'cronscripts/run_jobs.py', ['-v', 'initialisedistroseries'])