Merge lp:~salgado/launchpad/do-not-migrate-ubuntu-work-items into lp:launchpad

Proposed by Guilherme Salgado on 2012-03-12
Status: Merged
Approved by: Curtis Hovey on 2012-03-12
Approved revision: no longer in the source branch.
Merged at revision: 14939
Proposed branch: lp:~salgado/launchpad/do-not-migrate-ubuntu-work-items
Merge into: lp:launchpad
Diff against target: 111 lines (+49/-4)
2 files modified
lib/lp/scripts/garbo.py (+28/-1)
lib/lp/scripts/tests/test_garbo.py (+21/-3)
To merge this branch: bzr merge lp:~salgado/launchpad/do-not-migrate-ubuntu-work-items
Reviewer Review Type Date Requested Status
Benji York (community) code 2012-03-12 Approve on 2012-03-12
Review via email: mp+97088@code.launchpad.net

Commit Message

[r=benji][bug=953316] Change the workitem-migrator to migrate only the Blueprints of Linaro-related projects.

Description of the Change

Migrate work items only from the Blueprints of Linaro-related projects.

The Ubuntu project doesn't want their Blueprints migrated now, so we've agreed
to migrate only the Linaro blueprints for now.

To post a comment you must log in.
Benji York (benji) wrote :

This branch looks good. If it were me, I would use

    query = ("product in (select id from product where name in (%s))"
        % ",".join(sqlvalues(self.projects_to_migrate)))

instead of

    quoted_names = [
        "'%s'" % name for name in self.projects_to_migrate]
    query = ("product in (select id from product where name in (%s))"
        % ",".join(quoted_names))

because it states a little more clearly why we're doing what we're
doing and is a little shorter.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/scripts/garbo.py'
2--- lib/lp/scripts/garbo.py 2012-03-07 22:48:03 +0000
3+++ lib/lp/scripts/garbo.py 2012-03-12 19:35:26 +0000
4@@ -1075,6 +1075,31 @@
5
6 maximum_chunk_size = 500
7 offset = 0
8+ projects_to_migrate = [
9+ 'linaro-graphics-misc', 'linaro-powerdebug', 'linaro-mm-sig',
10+ 'linaro-patchmetrics', 'linaro-android-mirror', 'u-boot-linaro',
11+ 'lava-dashboard-tool', 'lava-celery', 'smartt', 'linaro-power-kernel',
12+ 'linaro-django-xmlrpc', 'linaro-multimedia-testcontent',
13+ 'linaro-status-website', 'linaro-octo-armhf', 'svammel', 'libmatrix',
14+ 'glproxy', 'lava-test', 'cbuild', 'linaro-ci',
15+ 'linaro-multimedia-ucm', 'linaro-ubuntu',
16+ 'linaro-android-infrastructure', 'linaro-wordpress-registration-form',
17+ 'linux-linaro', 'lava-server', 'linaro-android-build-tools',
18+ 'linaro-graphics-dashboard', 'linaro-fetch-image', 'unity-gles',
19+ 'lava-kernel-ci-views', 'cortex-strings', 'glmark2-extra',
20+ 'lava-dashboard', 'linaro-multimedia-speex', 'glcompbench',
21+ 'igloocommunity', 'linaro-validation-misc', 'linaro-websites',
22+ 'linaro-graphics-tests', 'linaro-android',
23+ 'jenkins-plugin-shell-status', 'binutils-linaro',
24+ 'linaro-multimedia-project', 'lava-qatracker',
25+ 'linaro-toolchain-binaries', 'linaro-image-tools',
26+ 'linaro-toolchain-misc', 'qemu-linaro', 'linaro-toolchain-benchmarks',
27+ 'lava-dispatcher', 'gdb-linaro', 'lava-android-test', 'libjpeg-turbo',
28+ 'lava-scheduler-tool', 'glmark2', 'linaro-infrastructure-misc',
29+ 'lava-lab', 'linaro-android-frontend', 'linaro-powertop',
30+ 'linaro-license-protection', 'gcc-linaro', 'lava-scheduler',
31+ 'linaro-offspring', 'linaro-python-dashboard-bundle',
32+ 'linaro-power-qa', 'lava-tool', 'linaro']
33
34 def __init__(self, log, abort_time=None):
35 super(SpecificationWorkitemMigrator, self).__init__(
36@@ -1090,9 +1115,11 @@
37 self.total = 0
38 return
39
40+ query = ("product in (select id from product where name in %s)"
41+ % ",".join(sqlvalues(self.projects_to_migrate)))
42 # Get only the specs which contain "work items" in their whiteboard
43 # and which don't have any SpecificationWorkItems.
44- query = "whiteboard ilike '%%' || %s || '%%'" % quote_like(
45+ query += " and whiteboard ilike '%%' || %s || '%%'" % quote_like(
46 'work items')
47 query += (" and id not in (select distinct specification from "
48 "SpecificationWorkItem)")
49
50=== modified file 'lib/lp/scripts/tests/test_garbo.py'
51--- lib/lp/scripts/tests/test_garbo.py 2012-03-08 22:48:17 +0000
52+++ lib/lp/scripts/tests/test_garbo.py 2012-03-12 19:35:26 +0000
53@@ -56,6 +56,7 @@
54 from lp.code.model.codeimportresult import CodeImportResult
55 from lp.registry.enums import InformationType
56 from lp.registry.interfaces.accesspolicy import IAccessPolicySource
57+from lp.registry.interfaces.distribution import IDistributionSet
58 from lp.registry.interfaces.person import IPersonSet
59 from lp.scripts.garbo import (
60 AntiqueSessionPruner,
61@@ -1061,7 +1062,8 @@
62 # When the migration is successful we remove all work-items from the
63 # whiteboard.
64 switch_dbuser('testadmin')
65- milestone = self.factory.makeMilestone()
66+ product = self.factory.makeProduct(name='linaro')
67+ milestone = self.factory.makeMilestone(product=product)
68 person = self.factory.makePerson()
69 whiteboard = dedent("""
70 Work items for %s:
71@@ -1071,7 +1073,7 @@
72 Another work item: DONE
73 """ % (milestone.name, person.name))
74 spec = self.factory.makeSpecification(
75- product=milestone.product, whiteboard=whiteboard)
76+ product=product, whiteboard=whiteboard)
77 IMasterStore(FeatureFlag).add(FeatureFlag(
78 u'default', 0, u'garbo.workitem_migrator.enabled', u'True'))
79 transaction.commit()
80@@ -1089,6 +1091,20 @@
81 status=SpecificationWorkItemStatus.DONE,
82 milestone=None, specification=spec))
83
84+ def test_SpecificationWorkitemMigrator_skips_ubuntu_blueprints(self):
85+ switch_dbuser('testadmin')
86+ whiteboard = "Work items:\nA work item: TODO"
87+ spec = self.factory.makeSpecification(
88+ whiteboard=whiteboard,
89+ distribution=getUtility(IDistributionSet)['ubuntu'])
90+ IMasterStore(FeatureFlag).add(FeatureFlag(
91+ u'default', 0, u'garbo.workitem_migrator.enabled', u'True'))
92+ transaction.commit()
93+ self.runFrequently()
94+
95+ self.assertEqual(whiteboard, spec.whiteboard)
96+ self.assertEqual(0, spec.work_items.count())
97+
98 def test_SpecificationWorkitemMigrator_parse_error(self):
99 # When we fail to parse any work items in the whiteboard we leave it
100 # untouched and don't create any SpecificationWorkItem entries.
101@@ -1098,7 +1114,9 @@
102 A work item: TODO
103 Another work item: UNKNOWNSTATUSWILLFAILTOPARSE
104 """)
105- spec = self.factory.makeSpecification(whiteboard=whiteboard)
106+ product = self.factory.makeProduct(name='linaro')
107+ spec = self.factory.makeSpecification(
108+ product=product, whiteboard=whiteboard)
109 IMasterStore(FeatureFlag).add(FeatureFlag(
110 u'default', 0, u'garbo.workitem_migrator.enabled', u'True'))
111 transaction.commit()