Merge lp:~stevenk/launchpad/ids-no-more-sampledata into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 11682
Proposed branch: lp:~stevenk/launchpad/ids-no-more-sampledata
Merge into: lp:launchpad
Diff against target: 539 lines (+185/-166)
4 files modified
lib/lp/soyuz/interfaces/packagecloner.py (+6/-1)
lib/lp/soyuz/model/packagecloner.py (+26/-7)
lib/lp/soyuz/scripts/initialise_distroseries.py (+1/-1)
lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py (+152/-157)
To merge this branch: bzr merge lp:~stevenk/launchpad/ids-no-more-sampledata
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Review via email: mp+37102@code.launchpad.net

Commit message

Remove sample data from the tests for InitialiseDistroSeries, and fix rebuild support.

Description of the change

First, a little bit of history: The tests for (what is now) InitialiseDistroSeries used to be a doctest, and I split them out in a unit test, replicating every part of the doctest. This branch now removes the tests dependence on sample data, as well as removing two unit tests that no longer make sense since they were dependent on sample data to function correctly.

The tests now creates a fresh distroseries in the setup, and populates it with four source packages, 3 binary packages and 1 failed to build. Mostly this is just moving code around, along with dropping the word 'foobuntu' everywhere I saw it.

It also fixes a bug, which was previously being masked by using the sampledata -- it now creates builds unilaterally if one doesn't exist when the rebuild=True option is passed in, and tests that correctly, rather than using hard-coded numerical values.

Finally, I cleaned up some lint that I noticed.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :
Download full text (6.3 KiB)

Hi Steven,

Great work for getting rid of the dependence on sample data!

I've just got two questions (more details below):

1) Do you think it's worth renaming createMissingBuilds() now that it also
creates builds that weren't missing (or did I mis-understand)? Or, on the
other hand (and this is my fault), if you don't see the always_create option
being used outside of the package cloner, it might be best as you originally
had it (ie. not modifying createMissingBuilds(), but just creating the builds
in the package cloner as you did originally).

2) If you do decide to keep the extra kwarg for createMissingBuilds() (or
however you rename it), we should add a test for this call specifically
(ie. test_createMissingBuilds_always_create() in test_publishing).

Cheers,
Michael

> === modified file 'lib/lp/soyuz/interfaces/publishing.py'
> --- lib/lp/soyuz/interfaces/publishing.py 2010-09-17 17:03:38 +0000
> +++ lib/lp/soyuz/interfaces/publishing.py 2010-09-30 10:48:06 +0000
> @@ -514,7 +514,7 @@
> """
>
> def createMissingBuilds(architectures_available=None, pas_verify=None,
> - logger=None):
> + logger=None, always_create=False):

The use of createMissingBuilds(always_create=True) seems a bit strange,
because if you pass always_create=True, you're not creating a missing build. What
do you think of:
       def createBuilds(..., missing_only=True) ?

hrm, I'm not sure... thoughts?

> === modified file 'lib/lp/soyuz/model/publishing.py'
> --- lib/lp/soyuz/model/publishing.py 2010-09-27 14:35:58 +0000
> +++ lib/lp/soyuz/model/publishing.py 2010-09-30 10:48:06 +0000
> @@ -563,7 +563,8 @@
> self.archive.enabled_restricted_families]
>
> def createMissingBuilds(self, architectures_available=None,
> - pas_verify=None, logger=None):
> + pas_verify=None, logger=None,
> + always_create=False):
> """See `ISourcePackagePublishingHistory`."""
> if self.archive.is_ppa:
> pas_verify = None
> @@ -581,24 +582,26 @@
> builds = []
> for arch in build_architectures:
> build_candidate = self._createMissingBuildForArchitecture(
> - arch, logger=logger)
> + arch, always_create=always_create, logger=logger)
> if build_candidate is not None:
> builds.append(build_candidate)
>
> return builds
>
> - def _createMissingBuildForArchitecture(self, arch, logger=None):
> + def _createMissingBuildForArchitecture(
> + self, arch, always_create, logger=None):
> """Create a build for a given architecture if it doesn't exist yet.

The "if it doesn't exist yet" needs to be removed I think?
>
> Return the just-created `IBinaryPackageBuild` record already
> - scored or None if a suitable build is already present.
> + scored or None if a suitable build is already present, except if
> + always_create is True, in which case a build is always created.
> """

same as above for 'always_create' as an arg to
_createMissingBuildForArchit...

Read more...

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/soyuz/interfaces/packagecloner.py'
2--- lib/lp/soyuz/interfaces/packagecloner.py 2010-08-20 20:31:18 +0000
3+++ lib/lp/soyuz/interfaces/packagecloner.py 2010-10-06 11:42:43 +0000
4@@ -17,7 +17,9 @@
5 class IPackageCloner(Interface):
6 """Copies publishing history data across archives."""
7
8- def clonePackages(origin, destination, distroarchseries_list=None):
9+ def clonePackages(
10+ origin, destination, distroarchseries_list=None,
11+ proc_familes=None, always_create=False):
12 """Copies the source packages from origin to destination as
13 well as the binary packages for the DistroArchSeries specified.
14
15@@ -25,6 +27,9 @@
16 :param destination: the location to which the data is to be copied.
17 :param distroarchseries_list: the binary packages will be copied
18 for the distroarchseries pairs specified (if any).
19+ :param proc_familes: the processor families that builds will be
20+ created for.
21+ :param always_create: if builds should always be created.
22 """
23
24 def mergeCopy(origin, destination):
25
26=== modified file 'lib/lp/soyuz/model/packagecloner.py'
27--- lib/lp/soyuz/model/packagecloner.py 2010-08-24 15:29:01 +0000
28+++ lib/lp/soyuz/model/packagecloner.py 2010-10-06 11:42:43 +0000
29@@ -26,6 +26,7 @@
30 IStoreSelector,
31 MAIN_STORE,
32 )
33+from lp.registry.interfaces.pocket import PackagePublishingPocket
34 from lp.soyuz.enums import PackagePublishingStatus
35 from lp.soyuz.interfaces.archivearch import IArchiveArchSet
36 from lp.soyuz.interfaces.packagecloner import IPackageCloner
37@@ -60,7 +61,7 @@
38 implements(IPackageCloner)
39
40 def clonePackages(self, origin, destination, distroarchseries_list=None,
41- proc_families=None):
42+ proc_families=None, always_create=False):
43 """Copies packages from origin to destination package location.
44
45 Binary packages are only copied for the `DistroArchSeries` pairs
46@@ -74,7 +75,11 @@
47 distroarchseries instances.
48 @param distroarchseries_list: the binary packages will be copied
49 for the distroarchseries pairs specified (if any).
50- @param the processor families to create builds for.
51+ @param proc_families: the processor families to create builds for.
52+ @type proc_families: Iterable
53+ @param always_create: if we should create builds for every source
54+ package copied, useful if no binaries are to be copied.
55+ @type always_create: Boolean
56 """
57 # First clone the source packages.
58 self._clone_source_packages(origin, destination)
59@@ -90,9 +95,12 @@
60 proc_families = []
61
62 self._create_missing_builds(
63- destination.distroseries, destination.archive, proc_families)
64+ destination.distroseries, destination.archive,
65+ distroarchseries_list, proc_families, always_create)
66
67- def _create_missing_builds(self, distroseries, archive, proc_families):
68+ def _create_missing_builds(
69+ self, distroseries, archive, distroarchseries_list,
70+ proc_families, always_create):
71 """Create builds for all cloned source packages.
72
73 :param distroseries: the distro series for which to create builds.
74@@ -126,7 +134,16 @@
75 return pub.sourcepackagerelease.sourcepackagename.name
76
77 for pubrec in sources_published:
78- pubrec.createMissingBuilds(architectures_available=architectures)
79+ builds = pubrec.createMissingBuilds(
80+ architectures_available=architectures)
81+ # If the last build was sucessful, we should create a new
82+ # build, since createMissingBuilds() won't.
83+ if not builds and always_create:
84+ for arch in architectures:
85+ build = pubrec.sourcepackagerelease.createBuild(
86+ distro_arch_series=arch, archive=archive,
87+ pocket=PackagePublishingPocket.RELEASE)
88+ build.queueBuild(suspended=not archive.enabled)
89 # Commit to avoid MemoryError: bug 304459
90 transaction.commit()
91
92@@ -216,7 +233,8 @@
93 in getUtility(IArchiveArchSet).getByArchive(destination.archive)]
94
95 self._create_missing_builds(
96- destination.distroseries, destination.archive, proc_families)
97+ destination.distroseries, destination.archive, (),
98+ proc_families, False)
99
100 def _compute_packageset_delta(self, origin):
101 """Given a source/target archive find obsolete or missing packages.
102@@ -245,7 +263,8 @@
103 secsrc.sourcepackagerelease = spr.id AND
104 spr.sourcepackagename = spn.id AND
105 spn.name = mcd.sourcepackagename AND
106- debversion_sort_key(spr.version) > debversion_sort_key(mcd.t_version)
107+ debversion_sort_key(spr.version) >
108+ debversion_sort_key(mcd.t_version)
109 """ % sqlvalues(
110 origin.archive,
111 PackagePublishingStatus.PENDING,
112
113=== modified file 'lib/lp/soyuz/scripts/initialise_distroseries.py'
114--- lib/lp/soyuz/scripts/initialise_distroseries.py 2010-09-22 06:42:40 +0000
115+++ lib/lp/soyuz/scripts/initialise_distroseries.py 2010-10-06 11:42:43 +0000
116@@ -203,7 +203,7 @@
117 distroarchseries_list = ()
118 getUtility(IPackageCloner).clonePackages(
119 origin, destination, distroarchseries_list,
120- proc_families)
121+ proc_families, self.rebuild)
122
123 def _copy_component_section_and_format_selections(self):
124 """Copy the section, component and format selections from the parent
125
126=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
127--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-09-22 06:42:40 +0000
128+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-10-06 11:42:43 +0000
129@@ -13,7 +13,6 @@
130 from zope.component import getUtility
131
132 from canonical.config import config
133-from canonical.launchpad.interfaces import IDistributionSet
134 from canonical.launchpad.interfaces.lpstorm import IStore
135 from canonical.testing.layers import LaunchpadZopelessLayer
136 from lp.buildmaster.enums import BuildStatus
137@@ -21,15 +20,16 @@
138 from lp.soyuz.enums import SourcePackageFormat
139 from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
140 from lp.soyuz.interfaces.packageset import IPackagesetSet
141+from lp.soyuz.interfaces.publishing import PackagePublishingStatus
142+from lp.soyuz.interfaces.sourcepackageformat import (
143+ ISourcePackageFormatSelectionSet,
144+ )
145 from lp.soyuz.model.distroarchseries import DistroArchSeries
146 from lp.soyuz.scripts.initialise_distroseries import (
147 InitialisationError,
148 InitialiseDistroSeries,
149 )
150-from lp.testing import (
151- login,
152- TestCaseWithFactory,
153- )
154+from lp.testing import TestCaseWithFactory
155
156
157 class TestInitialiseDistroSeries(TestCaseWithFactory):
158@@ -38,33 +38,59 @@
159
160 def setUp(self):
161 super(TestInitialiseDistroSeries, self).setUp()
162- login("foo.bar@canonical.com")
163- distribution_set = getUtility(IDistributionSet)
164- self.ubuntutest = distribution_set['ubuntutest']
165- self.ubuntu = distribution_set['ubuntu']
166- self.hoary = self.ubuntu['hoary']
167-
168- def _create_distroseries(self, parent_series):
169- return self.ubuntutest.newSeries(
170- 'foobuntu', 'FooBuntu', 'The Foobuntu', 'yeck', 'doom',
171- '888', parent_series, self.hoary.owner)
172-
173- def _set_pending_to_failed(self, distroseries):
174- pending_builds = distroseries.getBuildRecords(
175- BuildStatus.NEEDSBUILD, pocket=PackagePublishingPocket.RELEASE)
176- for build in pending_builds:
177- build.status = BuildStatus.FAILEDTOBUILD
178+ self.parent = self.factory.makeDistroSeries()
179+ pf = self.factory.makeProcessorFamily()
180+ pf.addProcessor('x86', '', '')
181+ self.parent_das = self.factory.makeDistroArchSeries(
182+ distroseries=self.parent, processorfamily=pf)
183+ lf = self.factory.makeLibraryFileAlias()
184+ transaction.commit()
185+ self.parent_das.addOrUpdateChroot(lf)
186+ self.parent_das.supports_virtualized = True
187+ self.parent.nominatedarchindep = self.parent_das
188+ getUtility(ISourcePackageFormatSelectionSet).add(
189+ self.parent, SourcePackageFormat.FORMAT_1_0)
190+ self._populate_parent()
191+
192+ def _populate_parent(self):
193+ packages = {'udev': '0.1-1', 'libc6': '2.8-1',
194+ 'postgresql': '9.0-1', 'chromium': '3.6'}
195+ for package in packages.keys():
196+ spn = self.factory.makeSourcePackageName(package)
197+ spph = self.factory.makeSourcePackagePublishingHistory(
198+ sourcepackagename=spn, version=packages[package],
199+ distroseries=self.parent,
200+ pocket=PackagePublishingPocket.RELEASE,
201+ status=PackagePublishingStatus.PUBLISHED)
202+ status = BuildStatus.FULLYBUILT
203+ if package is 'chromium':
204+ status = BuildStatus.FAILEDTOBUILD
205+ bpn = self.factory.makeBinaryPackageName(package)
206+ build = self.factory.makeBinaryPackageBuild(
207+ source_package_release=spph.sourcepackagerelease,
208+ distroarchseries=self.parent_das,
209+ status=status)
210+ bpr = self.factory.makeBinaryPackageRelease(
211+ binarypackagename=bpn, build=build,
212+ version=packages[package])
213+ if package is not 'chromium':
214+ self.factory.makeBinaryPackagePublishingHistory(
215+ binarypackagerelease=bpr,
216+ distroarchseries=self.parent_das,
217+ pocket=PackagePublishingPocket.RELEASE,
218+ status=PackagePublishingStatus.PUBLISHED)
219
220 def test_failure_with_no_parent_series(self):
221 # Initialising a new distro series requires a parent series to be set
222- foobuntu = self._create_distroseries(None)
223- ids = InitialiseDistroSeries(foobuntu)
224+ ids = InitialiseDistroSeries(self.factory.makeDistroSeries())
225 self.assertRaisesWithContent(
226 InitialisationError, "Parent series required.", ids.check)
227
228 def test_failure_for_already_released_distroseries(self):
229 # Initialising a distro series that has already been used will error
230- ids = InitialiseDistroSeries(self.ubuntutest['breezy-autotest'])
231+ child = self.factory.makeDistroSeries(parent_series=self.parent)
232+ self.factory.makeDistroArchSeries(distroseries=child)
233+ ids = InitialiseDistroSeries(child)
234 self.assertRaisesWithContent(
235 InitialisationError,
236 "Can not copy distroarchseries from parent, there are already "
237@@ -72,9 +98,13 @@
238
239 def test_failure_with_pending_builds(self):
240 # If the parent series has pending builds, we can't initialise
241- foobuntu = self._create_distroseries(self.hoary)
242- transaction.commit()
243- ids = InitialiseDistroSeries(foobuntu)
244+ source = self.factory.makeSourcePackagePublishingHistory(
245+ distroseries=self.parent,
246+ pocket=PackagePublishingPocket.RELEASE)
247+ source.createMissingBuilds()
248+ child = self.factory.makeDistroSeries(
249+ parent_series=self.parent)
250+ ids = InitialiseDistroSeries(child)
251 self.assertRaisesWithContent(
252 InitialisationError, "Parent series has pending builds.",
253 ids.check)
254@@ -82,190 +112,155 @@
255 def test_failure_with_queue_items(self):
256 # If the parent series has items in its queues, such as NEW and
257 # UNAPPROVED, we can't initialise
258- foobuntu = self._create_distroseries(
259- self.ubuntu['breezy-autotest'])
260- ids = InitialiseDistroSeries(foobuntu)
261+ self.parent.createQueueEntry(
262+ PackagePublishingPocket.RELEASE,
263+ 'foo.changes', 'bar', self.parent.main_archive)
264+ child = self.factory.makeDistroSeries(parent_series=self.parent)
265+ ids = InitialiseDistroSeries(child)
266 self.assertRaisesWithContent(
267 InitialisationError, "Parent series queues are not empty.",
268 ids.check)
269
270- def assertDistroSeriesInitialisedCorrectly(self, foobuntu):
271- # Check that 'pmount' has been copied correctly
272- hoary_pmount_pubs = self.hoary.getPublishedSources('pmount')
273- foobuntu_pmount_pubs = foobuntu.getPublishedSources('pmount')
274- self.assertEqual(
275- hoary_pmount_pubs.count(),
276- foobuntu_pmount_pubs.count())
277- hoary_i386_pmount_pubs = self.hoary['i386'].getReleasedPackages(
278- 'pmount')
279- foobuntu_i386_pmount_pubs = foobuntu['i386'].getReleasedPackages(
280- 'pmount')
281- self.assertEqual(
282- len(hoary_i386_pmount_pubs), len(foobuntu_i386_pmount_pubs))
283+ def assertDistroSeriesInitialisedCorrectly(self, child):
284+ # Check that 'udev' has been copied correctly
285+ parent_udev_pubs = self.parent.getPublishedSources('udev')
286+ child_udev_pubs = child.getPublishedSources('udev')
287+ self.assertEqual(
288+ parent_udev_pubs.count(), child_udev_pubs.count())
289+ parent_arch_udev_pubs = self.parent[
290+ self.parent_das.architecturetag].getReleasedPackages('udev')
291+ child_arch_udev_pubs = child[
292+ self.parent_das.architecturetag].getReleasedPackages('udev')
293+ self.assertEqual(
294+ len(parent_arch_udev_pubs), len(child_arch_udev_pubs))
295 # And the binary package, and linked source package look fine too
296- pmount_binrel = (
297- foobuntu['i386'].getReleasedPackages(
298- 'pmount')[0].binarypackagerelease)
299- self.assertEqual(pmount_binrel.title, u'pmount-0.1-1')
300- self.assertEqual(pmount_binrel.build.id, 7)
301+ udev_bin = child_arch_udev_pubs[0].binarypackagerelease
302+ self.assertEqual(udev_bin.title, u'udev-0.1-1')
303 self.assertEqual(
304- pmount_binrel.build.title,
305- u'i386 build of pmount 0.1-1 in ubuntu hoary RELEASE')
306- pmount_srcrel = pmount_binrel.build.source_package_release
307- self.assertEqual(pmount_srcrel.title, u'pmount - 0.1-1')
308- # The build of pmount 0.1-1 has been copied across.
309- foobuntu_pmount = pmount_srcrel.getBuildByArch(
310- foobuntu['i386'], foobuntu.main_archive)
311- hoary_pmount = pmount_srcrel.getBuildByArch(
312- self.hoary['i386'], self.hoary.main_archive)
313- self.assertEqual(foobuntu_pmount.id, hoary_pmount.id)
314+ udev_bin.build.title,
315+ u'%s build of udev 0.1-1 in %s %s RELEASE' % (
316+ self.parent_das.architecturetag, self.parent.parent.name,
317+ self.parent.name))
318+ udev_src = udev_bin.build.source_package_release
319+ self.assertEqual(udev_src.title, u'udev - 0.1-1')
320+ # The build of udev 0.1-1 has been copied across.
321+ child_udev = udev_src.getBuildByArch(
322+ child[self.parent_das.architecturetag], child.main_archive)
323+ parent_udev = udev_src.getBuildByArch(
324+ self.parent[self.parent_das.architecturetag],
325+ self.parent.main_archive)
326+ self.assertEqual(parent_udev.id, child_udev.id)
327 # We also inherient the permitted source formats from our parent
328 self.assertTrue(
329- foobuntu.isSourcePackageFormatPermitted(
330+ child.isSourcePackageFormatPermitted(
331 SourcePackageFormat.FORMAT_1_0))
332
333 def _full_initialise(self, arches=(), rebuild=False):
334- foobuntu = self._create_distroseries(self.hoary)
335- self._set_pending_to_failed(self.hoary)
336- transaction.commit()
337- ids = InitialiseDistroSeries(foobuntu, arches, rebuild)
338+ child = self.factory.makeDistroSeries(parent_series=self.parent)
339+ ids = InitialiseDistroSeries(child, arches, rebuild)
340 ids.check()
341 ids.initialise()
342- return foobuntu
343+ return child
344
345 def test_initialise(self):
346 # Test a full initialise with no errors
347- foobuntu = self._full_initialise()
348- self.assertDistroSeriesInitialisedCorrectly(foobuntu)
349+ child = self._full_initialise()
350+ self.assertDistroSeriesInitialisedCorrectly(child)
351
352- def test_initialise_only_i386(self):
353+ def test_initialise_only_one_das(self):
354 # Test a full initialise with no errors, but only copy i386 to
355 # the child
356- foobuntu = self._full_initialise(arches=('i386',))
357- self.assertDistroSeriesInitialisedCorrectly(foobuntu)
358+ self.factory.makeDistroArchSeries(distroseries=self.parent)
359+ child = self._full_initialise(
360+ arches=[self.parent_das.architecturetag])
361+ self.assertDistroSeriesInitialisedCorrectly(child)
362 das = list(IStore(DistroArchSeries).find(
363- DistroArchSeries, distroseries = foobuntu))
364+ DistroArchSeries, distroseries = child))
365 self.assertEqual(len(das), 1)
366- self.assertEqual(das[0].architecturetag, 'i386')
367-
368- def test_check_no_builds(self):
369- # Test that there is no build for pmount 0.1-2 in the
370- # newly-initialised series.
371- foobuntu = self._full_initialise()
372- pmount_source = self.hoary.getSourcePackage(
373- 'pmount').currentrelease
374- self.assertEqual(
375- pmount_source.title,
376- '"pmount" 0.1-2 source package in The Hoary Hedgehog Release')
377- pmount_source = foobuntu.getSourcePackage('pmount').currentrelease
378- self.assertEqual(
379- pmount_source.title,
380- '"pmount" 0.1-2 source package in The Foobuntu')
381- self.assertEqual(
382- pmount_source.sourcepackagerelease.getBuildByArch(
383- foobuntu['i386'], foobuntu.main_archive), None)
384- self.assertEqual(
385- pmount_source.sourcepackagerelease.getBuildByArch(
386- foobuntu['hppa'], foobuntu.main_archive), None)
387-
388- def test_create_builds(self):
389- # It turns out the sampledata of hoary includes pmount 0.1-1 as well
390- # as pmount 0.1-2 source, and if foobuntu and hoary don't share a
391- # pool, 0.1-1 will be marked as NBS and removed. So let's check that
392- # builds can be created for foobuntu.
393- foobuntu = self._full_initialise()
394- pmount_source = foobuntu.getSourcePackage('pmount').currentrelease
395- created_build = pmount_source.sourcepackagerelease.createBuild(
396- foobuntu['i386'], PackagePublishingPocket.RELEASE,
397- foobuntu.main_archive)
398- retrieved_build = pmount_source.sourcepackagerelease.getBuildByArch(
399- foobuntu['i386'], foobuntu.main_archive)
400- self.assertEqual(retrieved_build.id, created_build.id)
401- self.assertEqual(
402- 'i386 build of pmount 0.1-2 in ubuntutest foobuntu RELEASE',
403- created_build.title)
404+ self.assertEqual(
405+ das[0].architecturetag, self.parent_das.architecturetag)
406
407 def test_copying_packagesets(self):
408 # If a parent series has packagesets, we should copy them
409 uploader = self.factory.makePerson()
410 test1 = getUtility(IPackagesetSet).new(
411- u'test1', u'test 1 packageset', self.hoary.owner,
412- distroseries=self.hoary)
413+ u'test1', u'test 1 packageset', self.parent.owner,
414+ distroseries=self.parent)
415 test2 = getUtility(IPackagesetSet).new(
416- u'test2', u'test 2 packageset', self.hoary.owner,
417- distroseries=self.hoary)
418+ u'test2', u'test 2 packageset', self.parent.owner,
419+ distroseries=self.parent)
420 test3 = getUtility(IPackagesetSet).new(
421- u'test3', u'test 3 packageset', self.hoary.owner,
422- distroseries=self.hoary, related_set=test2)
423- test1.addSources('pmount')
424+ u'test3', u'test 3 packageset', self.parent.owner,
425+ distroseries=self.parent, related_set=test2)
426+ test1.addSources('udev')
427 getUtility(IArchivePermissionSet).newPackagesetUploader(
428- self.hoary.main_archive, uploader, test1)
429- foobuntu = self._full_initialise()
430- # We can fetch the copied sets from foobuntu
431- foobuntu_test1 = getUtility(IPackagesetSet).getByName(
432- u'test1', distroseries=foobuntu)
433- foobuntu_test2 = getUtility(IPackagesetSet).getByName(
434- u'test2', distroseries=foobuntu)
435- foobuntu_test3 = getUtility(IPackagesetSet).getByName(
436- u'test3', distroseries=foobuntu)
437+ self.parent.main_archive, uploader, test1)
438+ child = self._full_initialise()
439+ # We can fetch the copied sets from the child
440+ child_test1 = getUtility(IPackagesetSet).getByName(
441+ u'test1', distroseries=child)
442+ child_test2 = getUtility(IPackagesetSet).getByName(
443+ u'test2', distroseries=child)
444+ child_test3 = getUtility(IPackagesetSet).getByName(
445+ u'test3', distroseries=child)
446 # And we can see they are exact copies, with the related_set for the
447 # copies pointing to the packageset in the parent
448- self.assertEqual(test1.description, foobuntu_test1.description)
449- self.assertEqual(test2.description, foobuntu_test2.description)
450- self.assertEqual(test3.description, foobuntu_test3.description)
451- self.assertEqual(foobuntu_test1.relatedSets().one(), test1)
452- self.assertEqual(
453- list(foobuntu_test2.relatedSets()),
454- [test2, test3, foobuntu_test3])
455- self.assertEqual(
456- list(foobuntu_test3.relatedSets()),
457- [test2, foobuntu_test2, test3])
458+ self.assertEqual(test1.description, child_test1.description)
459+ self.assertEqual(test2.description, child_test2.description)
460+ self.assertEqual(test3.description, child_test3.description)
461+ self.assertEqual(child_test1.relatedSets().one(), test1)
462+ self.assertEqual(
463+ list(child_test2.relatedSets()),
464+ [test2, test3, child_test3])
465+ self.assertEqual(
466+ list(child_test3.relatedSets()),
467+ [test2, child_test2, test3])
468 # The contents of the packagesets will have been copied.
469- foobuntu_srcs = foobuntu_test1.getSourcesIncluded(
470+ child_srcs = child_test1.getSourcesIncluded(
471 direct_inclusion=True)
472- hoary_srcs = test1.getSourcesIncluded(direct_inclusion=True)
473- self.assertEqual(foobuntu_srcs, hoary_srcs)
474+ parent_srcs = test1.getSourcesIncluded(direct_inclusion=True)
475+ self.assertEqual(parent_srcs, child_srcs)
476 # The uploader can also upload to the new distroseries.
477 self.assertTrue(
478 getUtility(IArchivePermissionSet).isSourceUploadAllowed(
479- self.hoary.main_archive, 'pmount', uploader,
480- distroseries=self.hoary))
481+ self.parent.main_archive, 'udev', uploader,
482+ distroseries=self.parent))
483 self.assertTrue(
484 getUtility(IArchivePermissionSet).isSourceUploadAllowed(
485- foobuntu.main_archive, 'pmount', uploader,
486- distroseries=foobuntu))
487+ child.main_archive, 'udev', uploader,
488+ distroseries=child))
489
490 def test_rebuild_flag(self):
491 # No binaries will get copied if we specify rebuild=True
492- foobuntu = self._full_initialise(rebuild=True)
493- foobuntu.updatePackageCount()
494- builds = foobuntu.getBuildRecords(
495+ self.parent.updatePackageCount()
496+ child = self._full_initialise(rebuild=True)
497+ child.updatePackageCount()
498+ builds = child.getBuildRecords(
499 build_state=BuildStatus.NEEDSBUILD,
500- pocket=PackagePublishingPocket.RELEASE, arch_tag='i386')
501- self.assertEqual(foobuntu.sourcecount, 7)
502- self.assertEqual(foobuntu.binarycount, 0)
503- self.assertEqual(builds.count(), 5)
504+ pocket=PackagePublishingPocket.RELEASE)
505+ self.assertEqual(self.parent.sourcecount, child.sourcecount)
506+ self.assertEqual(child.binarycount, 0)
507+ self.assertEqual(builds.count(), self.parent.sourcecount)
508
509 def test_script(self):
510 # Do an end-to-end test using the command-line tool
511 uploader = self.factory.makePerson()
512 test1 = getUtility(IPackagesetSet).new(
513- u'test1', u'test 1 packageset', self.hoary.owner,
514- distroseries=self.hoary)
515- test1.addSources('pmount')
516+ u'test1', u'test 1 packageset', self.parent.owner,
517+ distroseries=self.parent)
518+ test1.addSources('udev')
519 getUtility(IArchivePermissionSet).newPackagesetUploader(
520- self.hoary.main_archive, uploader, test1)
521- foobuntu = self._create_distroseries(self.hoary)
522- self._set_pending_to_failed(self.hoary)
523+ self.parent.main_archive, uploader, test1)
524+ child = self.factory.makeDistroSeries(parent_series=self.parent)
525 transaction.commit()
526 ifp = os.path.join(
527 config.root, 'scripts', 'ftpmaster-tools',
528 'initialise-from-parent.py')
529 process = subprocess.Popen(
530- [sys.executable, ifp, "-vv", "-d", "ubuntutest", "foobuntu"],
531- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
532+ [sys.executable, ifp, "-vv", "-d", child.parent.name,
533+ child.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
534 stdout, stderr = process.communicate()
535 self.assertEqual(process.returncode, 0)
536 self.assertTrue(
537 "DEBUG Committing transaction." in stderr.split('\n'))
538- self.assertDistroSeriesInitialisedCorrectly(foobuntu)
539+ self.assertDistroSeriesInitialisedCorrectly(child)