108
111
dsdjob = create_job(distroseries, package)
109
112
self.assertEqual(JobStatus.WAITING, dsdjob.job.status)
111
def find_waiting_jobs_finds_waiting_jobs(self):
114
def test_find_waiting_jobs_finds_waiting_jobs(self):
112
115
sourcepackage = self.factory.makeSourcePackage()
113
116
distroseries, sourcepackagename = (
114
117
sourcepackage.distroseries, sourcepackage.distroseries)
115
118
job = create_job(distroseries, sourcepackagename)
116
self.assertContentEqual(
117
[job], find_waiting_jobs(distroseries, sourcepackagename))
119
found_jobs = find_waiting_jobs(distroseries, sourcepackagename)
120
self.assertEqual([job], [
121
DistroSeriesDifferenceJob(found_job)
122
for found_job in found_jobs])
119
def find_waiting_jobs_ignores_other_series(self):
124
def test_find_waiting_jobs_ignores_other_series(self):
120
125
sourcepackage = self.factory.makeSourcePackage()
121
126
distroseries, sourcepackagename = (
122
127
sourcepackage.distroseries, sourcepackage.distroseries)
147
152
[], find_waiting_jobs(distroseries, sourcepackagename))
149
154
def test_createForPackagedPublication_creates_jobs_for_its_child(self):
150
derived_series = self.factory.makeDistroSeries(
151
previous_series=self.makeDerivedDistroSeries())
155
dsp = self.factory.makeDistroSeriesParent()
156
parent_dsp = self.factory.makeDistroSeriesParent(
157
derived_series=dsp.parent_series)
152
158
package = self.factory.makeSourcePackageName()
153
159
# Create a job for the derived_series parent, which should create
154
160
# two jobs. One for derived_series, and the other for its child.
155
161
self.getJobSource().createForPackagePublication(
156
derived_series.previous_series, package,
162
dsp.parent_series, package,
157
163
PackagePublishingPocket.RELEASE)
159
find_waiting_jobs(derived_series.previous_series, package)) +
160
list(find_waiting_jobs(derived_series, package)))
165
find_waiting_jobs(dsp.parent_series, package)) +
166
list(find_waiting_jobs(dsp.derived_series, package)))
161
167
self.assertEqual(2, len(jobs))
162
168
self.assertEqual(package.id, jobs[0].metadata['sourcepackagename'])
163
169
self.assertEqual(package.id, jobs[1].metadata['sourcepackagename'])
164
170
# Lastly, a job was not created for the grandparent.
166
find_waiting_jobs(derived_series.previous_series.previous_series,
171
jobs = list(find_waiting_jobs(parent_dsp.parent_series, package))
168
172
self.assertEqual(0, len(jobs))
170
174
def test_createForPackagePublication_creates_job_for_derived_series(self):
193
197
distroseries, package, PackagePublishingPocket.PROPOSED)
194
198
self.assertContentEqual([], find_waiting_jobs(distroseries, package))
200
def test_getPendingJobsForDifferences_finds_job(self):
201
dsd = self.factory.makeDistroSeriesDifference()
202
job = create_job(dsd.derived_series, dsd.source_package_name)
205
self.getJobSource().getPendingJobsForDifferences(
206
dsd.derived_series, [dsd]))
208
def test_getPendingJobsForDifferences_ignores_other_package(self):
209
dsd = self.factory.makeDistroSeriesDifference()
210
create_job(dsd.derived_series, self.factory.makeSourcePackageName())
213
self.getJobSource().getPendingJobsForDifferences(
214
dsd.derived_series, [dsd]))
216
def test_getPendingJobsForDifferences_ignores_other_derived_series(self):
217
dsd = self.factory.makeDistroSeriesDifference()
218
create_job(self.makeDerivedDistroSeries(), dsd.source_package_name)
221
self.getJobSource().getPendingJobsForDifferences(
222
dsd.derived_series, [dsd]))
224
def test_getPendingJobsForDifferences_ignores_other_parent_series(self):
225
# XXX JeroenVermeulen 2011-05-26 bug=758906: Can't test this
226
# until we can specify the right parent series when creating a
230
def test_getPendingJobsForDifferences_ignores_non_pending_jobs(self):
231
dsd = self.factory.makeDistroSeriesDifference()
232
job = create_job(dsd.derived_series, dsd.source_package_name)
233
removeSecurityProxy(job).job._status = JobStatus.COMPLETED
236
self.getJobSource().getPendingJobsForDifferences(
237
dsd.derived_series, [dsd]))
239
def test_getPendingJobsForDifferences_ignores_other_job_types(self):
240
# XXX JeroenVermeulen 2011-05-26 bug=758906: Once parent_series
241
# is incorporated into the job type, set it to dsd.parent_series
242
# on the fake job, or this test will become silently meaningless.
243
dsd = self.factory.makeDistroSeriesDifference()
245
distribution=dsd.derived_series.distribution,
246
distroseries=dsd.derived_series,
247
job_type=DistributionJobType.INITIALISE_SERIES,
248
metadata={"sourcepackagename": dsd.source_package_name.id})
251
self.getJobSource().getPendingJobsForDifferences(
252
dsd.derived_series, [dsd]))
196
254
def test_cronscript(self):
197
255
derived_series = self.makeDerivedDistroSeries()
198
256
package = self.factory.makeSourcePackageName()
242
300
self.assertEqual(1, ds_diff.count())
244
302
def test_packageset_filter_passes_inherited_packages(self):
245
derived_series = self.makeDerivedDistroSeries()
246
previous_series = derived_series.previous_series
303
dsp = self.factory.makeDistroSeriesParent()
247
304
# Parent must have a packageset or the filter will pass anyway.
248
self.factory.makePackageset(distroseries=previous_series)
305
self.factory.makePackageset(distroseries=dsp.parent_series)
249
306
package = self.factory.makeSourcePackageName()
250
307
# Package is not in the packageset _but_ both the parent and
251
308
# derived series have it.
252
309
self.factory.makeSourcePackagePublishingHistory(
253
distroseries=previous_series, sourcepackagename=package)
310
distroseries=dsp.parent_series, sourcepackagename=package)
254
311
self.factory.makeSourcePackagePublishingHistory(
255
distroseries=derived_series, sourcepackagename=package)
256
job = create_job(derived_series, package)
312
distroseries=dsp.derived_series, sourcepackagename=package)
313
job = create_job(dsp.derived_series, package)
257
314
self.assertTrue(job.passesPackagesetFilter())
259
316
def test_packageset_filter_passes_packages_unique_to_derived_series(self):
260
derived_series = self.makeDerivedDistroSeries()
261
previous_series = derived_series.previous_series
317
dsp = self.factory.makeDistroSeriesParent()
262
318
# Parent must have a packageset or the filter will pass anyway.
263
self.factory.makePackageset(distroseries=previous_series)
319
self.factory.makePackageset(distroseries=dsp.parent_series)
264
320
package = self.factory.makeSourcePackageName()
265
321
# Package exists in the derived series but not in the parent
267
323
self.factory.makeSourcePackagePublishingHistory(
268
distroseries=derived_series, sourcepackagename=package)
269
job = create_job(derived_series, package)
324
distroseries=dsp.derived_series, sourcepackagename=package)
325
job = create_job(dsp.derived_series, package)
270
326
self.assertTrue(job.passesPackagesetFilter())
272
328
def test_packageset_filter_passes_all_if_parent_has_no_packagesets(self):
273
329
# Debian in particular has no packagesets. If the parent series
274
330
# has no packagesets, the packageset filter passes all packages.
275
derived_series = self.makeDerivedDistroSeries()
276
previous_series = derived_series.previous_series
331
dsp = self.factory.makeDistroSeriesParent()
277
332
package = self.factory.makeSourcePackageName()
278
333
self.factory.makeSourcePackagePublishingHistory(
279
distroseries=previous_series, sourcepackagename=package)
280
job = create_job(derived_series, package)
334
distroseries=dsp.parent_series, sourcepackagename=package)
335
job = create_job(dsp.derived_series, package)
281
336
self.assertTrue(job.passesPackagesetFilter())
283
def makeInheritedPackageSet(self, derived_series, packages=()):
338
def makeInheritedPackageSet(self, distro_series_parent, packages=()):
284
339
"""Simulate an inherited `Packageset`.
286
341
Creates a packageset in the parent that has an equivalent in
287
342
`derived_series`.
289
previous_series = derived_series.previous_series
290
344
parent_packageset = self.factory.makePackageset(
291
distroseries=previous_series, packages=packages)
292
derived_packageset = self.factory.makePackageset(
293
distroseries=derived_series, packages=packages,
294
name=parent_packageset.name, owner=parent_packageset.owner,
295
related_set=parent_packageset)
345
distroseries=distro_series_parent.parent_series,
347
self.factory.makePackageset(
348
distroseries=distro_series_parent.derived_series,
349
packages=packages, name=parent_packageset.name,
350
owner=parent_packageset.owner, related_set=parent_packageset)
297
352
def test_packageset_filter_passes_package_in_inherited_packageset(self):
298
derived_series = self.makeDerivedDistroSeries()
299
previous_series = derived_series.previous_series
353
dsp = self.factory.makeDistroSeriesParent()
300
354
# Package is in a packageset on the parent that the derived
301
355
# series also has.
302
356
package = self.factory.makeSourcePackageName()
303
self.makeInheritedPackageSet(derived_series, [package])
357
self.makeInheritedPackageSet(dsp, [package])
304
358
# Package is in parent series and in a packageset that the
305
359
# derived series inherited.
306
360
self.factory.makeSourcePackagePublishingHistory(
307
distroseries=previous_series, sourcepackagename=package)
308
job = create_job(derived_series, package)
361
distroseries=dsp.parent_series, sourcepackagename=package)
362
job = create_job(dsp.derived_series, package)
309
363
self.assertTrue(job.passesPackagesetFilter())
311
365
def test_packageset_filter_blocks_unwanted_parent_package(self):
312
derived_series = self.makeDerivedDistroSeries()
313
previous_series = derived_series.previous_series
314
self.makeInheritedPackageSet(derived_series)
366
dsp = self.factory.makeDistroSeriesParent()
367
self.makeInheritedPackageSet(dsp)
315
368
package = self.factory.makeSourcePackageName()
316
369
# Package is in the parent series but not in a packageset shared
317
370
# between the derived series and the parent series.
318
371
self.factory.makeSourcePackagePublishingHistory(
319
distroseries=previous_series, sourcepackagename=package)
320
job = create_job(derived_series, package)
372
distroseries=dsp.parent_series, sourcepackagename=package)
373
job = create_job(dsp.derived_series, package)
321
374
self.assertFalse(job.passesPackagesetFilter())
418
473
jobs = find_waiting_jobs(derived_series, source_package_name)
419
474
self.runJob(jobs[0])
420
475
self.assertEqual(
421
DistroSeriesDifferenceStatus.NEEDS_ATTENTION, ds_diff[0].status)
476
DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT,
422
478
self.assertEqual('1.0-1', ds_diff[0].base_version)
424
480
def test_child_is_synced(self):
425
481
# If the source package gets 'synced' to the child from the parent,
426
482
# the job correctly updates the DSD.
427
derived_series = self.makeDerivedDistroSeries()
483
dsp = self.makeDerivedDistroSeries()
484
derived_series = dsp.derived_series
428
485
source_package_name = self.factory.makeSourcePackageName()
429
486
self.createPublication(
430
487
source_package_name, ['1.0-1derived1', '1.0-1'], derived_series)
431
488
self.createPublication(
432
source_package_name, ['1.0-2', '1.0-1'],
433
derived_series.previous_series)
489
source_package_name, ['1.0-2', '1.0-1'], dsp.parent_series)
434
490
jobs = find_waiting_jobs(derived_series, source_package_name)
435
491
self.runJob(jobs[0])
436
492
ds_diff = self.findDSD(derived_series, source_package_name)
537
598
def test_update_deletes_diffs(self):
538
599
# When a DSD is updated, the diffs are invalidated.
539
derived_series = self.makeDerivedDistroSeries()
600
dsp = self.makeDerivedDistroSeries()
601
derived_series = dsp.derived_series
540
602
source_package_name = self.factory.makeSourcePackageName()
541
603
self.createPublication(
542
604
source_package_name, ['1.0-1derived1', '1.0-1'], derived_series)
543
605
self.createPublication(
544
source_package_name, ['1.0-2', '1.0-1'],
545
derived_series.previous_series)
606
source_package_name, ['1.0-2', '1.0-1'], dsp.parent_series)
546
607
spr = self.factory.makeSourcePackageRelease(
547
608
sourcepackagename=source_package_name, version='1.0-1')
548
609
self.factory.makeSourcePackagePublishingHistory(
549
610
sourcepackagerelease=spr,
550
archive=derived_series.previous_series.main_archive,
551
distroseries=derived_series.previous_series,
611
archive=dsp.parent_series.main_archive,
612
distroseries=dsp.parent_series,
552
613
status=PackagePublishingStatus.SUPERSEDED)
553
614
jobs = find_waiting_jobs(derived_series, source_package_name)
554
615
self.runJob(jobs[0])