← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/cronscript-idsjob-qafail into lp:launchpad/devel

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/cronscript-idsjob-qafail into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


This branch tests the cronscript for processing InitialiseDistroSeriesJobs, as well as fixing the fail I had when attempting to QA the branch on dogfood.
-- 
https://code.launchpad.net/~stevenk/launchpad/cronscript-idsjob-qafail/+merge/39006
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/cronscript-idsjob-qafail into lp:launchpad/devel.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2010-10-18 04:59:05 +0000
+++ database/schema/security.cfg	2010-10-21 01:26:10 +0000
@@ -932,6 +932,39 @@
 public.country                                  = SELECT
 public.parsedapachelog                          = SELECT, INSERT, UPDATE
 
+[initialisedistroseries]
+type=user
+groups=script
+public.archive                                  = SELECT
+public.archivepermission                        = SELECT, INSERT
+public.binarypackagebuild                       = SELECT
+public.binarypackagepublishinghistory           = SELECT, INSERT
+public.buildfarmjob                             = SELECT
+public.buildpackagejob                          = SELECT
+public.buildqueue                               = SELECT
+public.component                                = SELECT
+public.componentselection                       = SELECT, INSERT
+public.distribution                             = SELECT
+public.distributionjob                          = SELECT
+public.distroarchseries                         = SELECT, INSERT
+public.distroseries                             = SELECT, UPDATE
+public.flatpackagesetinclusion                  = SELECT, INSERT
+public.job                                      = SELECT, UPDATE
+public.packagebuild                             = SELECT
+public.packageset                               = SELECT, INSERT
+public.packagesetgroup                          = SELECT, INSERT
+public.packagesetinclusion                      = SELECT, INSERT
+public.packagesetsources                        = SELECT, INSERT
+public.packageupload                            = SELECT
+public.packaging                                = SELECT, INSERT
+public.person                                   = SELECT
+public.processorfamily                          = SELECT
+public.section                                  = SELECT
+public.sectionselection                         = SELECT, INSERT
+public.sourcepackageformatselection             = SELECT, INSERT
+public.sourcepackagename                        = SELECT
+public.sourcepackagepublishinghistory           = SELECT, INSERT
+
 [write]
 type=group
 # Full access except for tables that are exclusively updated by

=== modified file 'lib/canonical/config/schema-lazr.conf'
--- lib/canonical/config/schema-lazr.conf	2010-10-19 08:50:08 +0000
+++ lib/canonical/config/schema-lazr.conf	2010-10-21 01:26:10 +0000
@@ -917,6 +917,8 @@
 port: 11371
 
 [initialisedistroseries]
+dbuser: initialisedistroseries
+
 # See [error_reports].
 error_dir: none
 

=== modified file 'lib/lp/soyuz/tests/test_initialisedistroseriesjob.py'
--- lib/lp/soyuz/tests/test_initialisedistroseriesjob.py	2010-10-12 07:46:56 +0000
+++ lib/lp/soyuz/tests/test_initialisedistroseriesjob.py	2010-10-21 01:26:10 +0000
@@ -1,14 +1,23 @@
 # Copyright 2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+import os
+import subprocess
+import sys
 import transaction
+from canonical.config import config 
 from canonical.testing import LaunchpadZopelessLayer
 from storm.exceptions import IntegrityError
+from storm.store import Store
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
+from lp.buildmaster.enums import BuildStatus
+from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.soyuz.interfaces.distributionjob import (
     IInitialiseDistroSeriesJobSource,
     )
+from lp.soyuz.interfaces.packageset import IPackagesetSet
+from lp.soyuz.interfaces.publishing import PackagePublishingStatus
 from lp.soyuz.model.initialisedistroseriesjob import (
     InitialiseDistroSeriesJob,
     )
@@ -88,3 +97,65 @@
         self.assertEqual(naked_job.arches, arches)
         self.assertEqual(naked_job.packagesets, packagesets)
         self.assertEqual(naked_job.rebuild, False)
+
+    def test_cronscript(self):
+        pf = self.factory.makeProcessorFamily()
+        pf.addProcessor('x86', '', '')
+        parent = self.factory.makeDistroSeries()
+        parent_das = self.factory.makeDistroArchSeries(
+            distroseries=parent, processorfamily=pf)
+        lf = self.factory.makeLibraryFileAlias()
+        transaction.commit()
+        parent_das.addOrUpdateChroot(lf)
+        parent_das.supports_virtualized = True
+        parent.nominatedarchindep = parent_das
+        packages = {'udev': '0.1-1', 'libc6': '2.8-1'}
+        for package in packages.keys():
+            spn = self.factory.makeSourcePackageName(package)
+            spph = self.factory.makeSourcePackagePublishingHistory(
+                sourcepackagename=spn, version=packages[package],
+                distroseries=parent,
+                pocket=PackagePublishingPocket.RELEASE,
+                status=PackagePublishingStatus.PUBLISHED)
+            bpn = self.factory.makeBinaryPackageName(package)
+            build = self.factory.makeBinaryPackageBuild(
+                source_package_release=spph.sourcepackagerelease,
+                distroarchseries=parent_das,
+                status=BuildStatus.FULLYBUILT)
+            bpr = self.factory.makeBinaryPackageRelease(
+                binarypackagename=bpn, build=build,
+                version=packages[package])
+            self.factory.makeBinaryPackagePublishingHistory(
+                binarypackagerelease=bpr,
+                distroarchseries=parent_das,
+                pocket=PackagePublishingPocket.RELEASE,
+                status=PackagePublishingStatus.PUBLISHED)
+        test1 = getUtility(IPackagesetSet).new(
+            u'test1', u'test 1 packageset', parent.owner,
+            distroseries=parent)
+        test1.addSources('udev')
+        parent.updatePackageCount()
+        child = self.factory.makeDistroSeries(parent_series=parent)
+        
+        job = getUtility(IInitialiseDistroSeriesJobSource).create(
+                child)
+        # Make sure everything hits the database, as the next bit is
+        # out-of-process
+        transaction.commit()
+
+        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)
+        self.assertTrue(
+            "INFO    Ran 1 InitialiseDistroSeriesJob jobs." in (
+                stderr.split('\n')))
+        # Storm assumes all changes are made in-process
+        Store.of(child).invalidate()
+        # The child distroseries is now initialised
+        child.updatePackageCount()
+        self.assertEqual(parent.sourcecount, child.sourcecount)
+        self.assertEqual(parent.binarycount, child.binarycount)