def addSummaryToDifference(self, distro_series_difference):
        """Helper that adds binaries with summary info to the source pubs."""
        # Avoid circular import.
        from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
        distro_series = distro_series_difference.derived_series
        parent_series = distro_series_difference.parent_series
        source_package_name_str = (
            distro_series_difference.source_package_name.name)
        stp = SoyuzTestPublisher()

        if distro_series_difference.difference_type == (
            DistroSeriesDifferenceType.MISSING_FROM_DERIVED_SERIES):
            source_pub = distro_series_difference.parent_source_pub
        else:
            source_pub = distro_series_difference.source_pub

        stp.makeSourcePackageSummaryData(source_pub)
        stp.updateDistroSeriesPackageCache(source_pub.distroseries)

        # updateDistroSeriesPackageCache reconnects the db, so the
        # objects need to be reloaded.
        dsd_source = getUtility(IDistroSeriesDifferenceSource)
        ds_diff = dsd_source.getByDistroSeriesNameAndParentSeries(
            distro_series, source_package_name_str, parent_series)
        return ds_diff
def create_child(factory):
    processor = factory.makeProcessor()
    parent = factory.makeDistroSeries()
    parent_das = factory.makeDistroArchSeries(distroseries=parent, processor=processor)
    lf = factory.makeLibraryFileAlias()
    # Since the LFA needs to be in the librarian, commit.
    transaction.commit()
    parent_das.addOrUpdateChroot(lf)
    with celebrity_logged_in("admin"):
        parent_das.supports_virtualized = True
        parent.nominatedarchindep = parent_das
        publisher = SoyuzTestPublisher()
        publisher.prepareBreezyAutotest()
        packages = {"udev": "0.1-1", "libc6": "2.8-1"}
        for package in packages.keys():
            publisher.getPubBinaries(
                distroseries=parent,
                binaryname=package,
                version=packages[package],
                status=PackagePublishingStatus.PUBLISHED,
            )
        test1 = getUtility(IPackagesetSet).new(u"test1", u"test 1 packageset", parent.owner, distroseries=parent)
        test1_packageset_id = str(test1.id)
        test1.addSources("udev")
    parent.updatePackageCount()
    child = factory.makeDistroSeries()
    getUtility(ISourcePackageFormatSelectionSet).add(child, SourcePackageFormat.FORMAT_1_0)
    # Make sure everything hits the database, switching db users aborts.
    transaction.commit()
    return parent, child, test1_packageset_id
class TestBuildJobBase(TestCaseWithFactory):
    """Setup the test publisher and some builders."""

    layer = LaunchpadZopelessLayer

    def setUp(self):
        super(TestBuildJobBase, self).setUp()
        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        self.i8 = self.factory.makeBuilder(name='i386-n-8', virtualized=False)
        self.i9 = self.factory.makeBuilder(name='i386-n-9', virtualized=False)

        processor = getUtility(IProcessorSet).getByName('hppa')
        self.h6 = self.factory.makeBuilder(
            name='hppa-n-6', processor=processor, virtualized=False)
        self.h7 = self.factory.makeBuilder(
            name='hppa-n-7', processor=processor, virtualized=False)

        self.builders = dict()
        # x86 native
        self.builders[(1, False)] = [self.i8, self.i9]

        # hppa native
        self.builders[(3, True)] = [self.h6, self.h7]

        # Ensure all builders are operational.
        for builders in self.builders.values():
            for builder in builders:
                builder.builderok = True
                builder.manual = False

        # Disable the sample data builders.
        getUtility(IBuilderSet)['bob'].builderok = False
        getUtility(IBuilderSet)['frog'].builderok = False
Ejemplo n.º 4
0
    def test_dispatchBuildToSlave(self):
        # Ensure dispatchBuildToSlave will make the right calls to the slave
        job = self.makeJob()
        test_publisher = SoyuzTestPublisher()
        test_publisher.addFakeChroots(job.build.distroseries)
        slave = OkSlave()
        builder = MockBuilder("bob-de-bouwer")
        builder.processor = getUtility(IProcessorSet).getByName("386")
        job.setBuilder(builder, slave)
        logger = BufferLogger()
        d = defer.maybeDeferred(job.dispatchBuildToSlave, "someid", logger)

        def check_dispatch(ignored):
            self.assertThat(
                logger.getLogBuffer(),
                StartsWith(
                    dedent(
                        """\
                  INFO Sending chroot file for recipe build to bob-de-bouwer
                  INFO Initiating build 1-someid on http://fake:0000
                  """
                    )
                ),
            )
            self.assertEquals(["ensurepresent", "build"], [call[0] for call in slave.call_log])
            build_args = slave.call_log[1][1:]
            self.assertEquals(build_args[0], job.getBuildCookie())
            self.assertEquals(build_args[1], "sourcepackagerecipe")
            self.assertEquals(build_args[3], [])
            distroarchseries = job.build.distroseries.architectures[0]
            self.assertEqual(build_args[4], job._extraBuildArgs(distroarchseries))

        return d.addCallback(check_dispatch)
    def setUp(self):
        """Make a PPA and publish some sources that need builds."""
        TestCaseWithFactory.setUp(self)
        self.stp = SoyuzTestPublisher()
        self.stp.prepareBreezyAutotest()

        # i386 and hppa are enabled by STP but we need to mark hppa as
        # PPA-enabled.
        self.stp.breezy_autotest_hppa.supports_virtualized = True

        # Create an arch-any and an arch-all source in a PPA.
        self.ppa = self.factory.makeArchive(purpose=ArchivePurpose.PPA,
                                            distribution=self.stp.ubuntutest)
        self.all = self.stp.getPubSource(
            sourcename="all",
            architecturehintlist="all",
            archive=self.ppa,
            status=PackagePublishingStatus.PUBLISHED)
        self.any = self.stp.getPubSource(
            sourcename="any",
            architecturehintlist="any",
            archive=self.ppa,
            status=PackagePublishingStatus.PUBLISHED)
        self.required_arches = [
            self.stp.breezy_autotest_hppa, self.stp.breezy_autotest_i386
        ]
 def setUp(self):
     super(TestDistributionHasBuildRecords, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Create the machinery we need to create builds, such as
     # DistroArchSeries and builders.
     self.processor_one = self.factory.makeProcessor()
     self.processor_two = self.factory.makeProcessor()
     self.distroseries = self.factory.makeDistroSeries()
     self.distribution = self.distroseries.distribution
     self.das_one = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries,
         processor=self.processor_one,
         supports_virtualized=True)
     self.das_two = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries,
         processor=self.processor_two,
         supports_virtualized=True)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PRIMARY)
     self.arch_ids = [arch.id for arch in self.distroseries.architectures]
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das_one
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder_one = self.factory.makeBuilder(
             processor=self.processor_one)
         self.builder_two = self.factory.makeBuilder(
             processor=self.processor_two)
     self.builds = []
     self.createBuilds()
Ejemplo n.º 7
0
    def test_dispatchBuildToSlave(self):
        # Ensure dispatchBuildToSlave will make the right calls to the slave
        job = self.makeJob()
        test_publisher = SoyuzTestPublisher()
        test_publisher.addFakeChroots(job.build.distroseries)
        slave = OkSlave()
        builder = MockBuilder("bob-de-bouwer")
        builder.processor = getUtility(IProcessorSet).getByName('386')
        job.setBuilder(builder, slave)
        logger = BufferLogger()
        d = defer.maybeDeferred(job.dispatchBuildToSlave, "someid", logger)

        def check_dispatch(ignored):
            self.assertThat(
                logger.getLogBuffer(),
                StartsWith(
                    dedent("""\
                  INFO Sending chroot file for recipe build to bob-de-bouwer
                  INFO Initiating build 1-someid on http://fake:0000
                  """)))
            self.assertEquals(["ensurepresent", "build"],
                              [call[0] for call in slave.call_log])
            build_args = slave.call_log[1][1:]
            self.assertEquals(build_args[0], job.getBuildCookie())
            self.assertEquals(build_args[1], "sourcepackagerecipe")
            self.assertEquals(build_args[3], [])
            distroarchseries = job.build.distroseries.architectures[0]
            self.assertEqual(build_args[4],
                             job._extraBuildArgs(distroarchseries))

        return d.addCallback(check_dispatch)
class TestDistributionHasBuildRecords(TestCaseWithFactory):
    """Populate a distroseries with builds"""

    layer = LaunchpadZopelessLayer

    def setUp(self):
        super(TestDistributionHasBuildRecords, self).setUp()
        self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
        # Create the machinery we need to create builds, such as
        # DistroArchSeries and builders.
        self.processor_one = self.factory.makeProcessor()
        self.processor_two = self.factory.makeProcessor()
        self.distroseries = self.factory.makeDistroSeries()
        self.distribution = self.distroseries.distribution
        self.das_one = self.factory.makeDistroArchSeries(
            distroseries=self.distroseries,
            processor=self.processor_one,
            supports_virtualized=True)
        self.das_two = self.factory.makeDistroArchSeries(
            distroseries=self.distroseries,
            processor=self.processor_two,
            supports_virtualized=True)
        self.archive = self.factory.makeArchive(
            distribution=self.distroseries.distribution,
            purpose=ArchivePurpose.PRIMARY)
        self.arch_ids = [arch.id for arch in self.distroseries.architectures]
        with person_logged_in(self.admin):
            self.publisher = SoyuzTestPublisher()
            self.publisher.prepareBreezyAutotest()
            self.distroseries.nominatedarchindep = self.das_one
            self.publisher.addFakeChroots(distroseries=self.distroseries)
            self.builder_one = self.factory.makeBuilder(
                processor=self.processor_one)
            self.builder_two = self.factory.makeBuilder(
                processor=self.processor_two)
        self.builds = []
        self.createBuilds()

    def createBuilds(self):
        for i in range(5):
            # Create some test builds.
            spph = self.publisher.getPubSource(
                sourcename=self.factory.getUniqueString(),
                version="%s.%s" % (self.factory.getUniqueInteger(), i),
                distroseries=self.distroseries,
                architecturehintlist='any')
            builds = spph.createMissingBuilds()
            for b in builds:
                b.updateStatus(BuildStatus.BUILDING)
                if i == 4:
                    b.updateStatus(BuildStatus.FAILEDTOBUILD)
                else:
                    b.updateStatus(BuildStatus.FULLYBUILT)
                b.buildqueue_record.destroySelf()
            self.builds += builds

    def test_get_build_records(self):
        # A Distribution also implements IHasBuildRecords.
        builds = self.distribution.getBuildRecords().count()
        self.assertEquals(10, builds)
 def test_copy_archive_without_leak(self):
     # If source publications are copied to a .COPY archive, they don't
     # "leak" into SourcePackage.getBuildRecords().
     admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Set up a distroseries and related bits, so we can create builds.
     source_name = self.factory.getUniqueString()
     spn = self.factory.makeSourcePackageName(name=source_name)
     processor = self.factory.makeProcessor()
     distroseries = self.factory.makeDistroSeries()
     das = self.factory.makeDistroArchSeries(
         distroseries=distroseries, processor=processor,
         supports_virtualized=True)
     with person_logged_in(admin):
         publisher = SoyuzTestPublisher()
         publisher.prepareBreezyAutotest()
         publisher.addFakeChroots(distroseries=distroseries)
         distroseries.nominatedarchindep = das
         self.factory.makeBuilder(processor=processor)
     spph = self.factory.makeSourcePackagePublishingHistory(
         sourcepackagename=spn, distroseries=distroseries)
     spph.createMissingBuilds()
     # Create a copy archive.
     copy = self.factory.makeArchive(
         purpose=ArchivePurpose.COPY,
         distribution=distroseries.distribution)
     # And copy the publication into it.
     copy_spph = spph.copyTo(
         distroseries, PackagePublishingPocket.RELEASE, copy)
     [copy_build] = copy_spph.createMissingBuilds()
     builds = copy.getBuildRecords()
     self.assertEquals([copy_build], list(builds))
     source = SourcePackage(spn, spph.distroseries)
     # SourcePackage.getBuildRecords() doesn't have two build records.
     builds = source.getBuildRecords().count()
     self.assertEquals(1, builds)
Ejemplo n.º 10
0
 def test_handles_packaging_references(self):
     person = self.factory.makePerson()
     person_id = person.id
     account_id = person.account.id
     self.factory.makeGPGKey(person)
     publisher = SoyuzTestPublisher()
     publisher.person = person
     ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
     spph = publisher.getPubSource(status=PackagePublishingStatus.PUBLISHED,
                                   distroseries=ubuntu.currentseries,
                                   maintainer=person,
                                   creator=person)
     with dbuser('garbo_frequently'):
         job = PopulateLatestPersonSourcePackageReleaseCache(
             DevNullLogger())
         while not job.isDone():
             job(chunk_size=100)
     self.assertTrue(person.hasMaintainedPackages())
     script = self.makeScript([six.ensure_str(person.name)])
     with dbuser('launchpad'):
         self.runScript(script)
     self.assertRemoved(account_id, person_id)
     self.assertEqual(person, spph.package_maintainer)
     self.assertEqual(person, spph.package_creator)
     self.assertFalse(person.hasMaintainedPackages())
Ejemplo n.º 11
0
 def setUp(self):
     super(TestBuildSet, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     self.processor_one = self.factory.makeProcessor(
         supports_virtualized=True)
     self.processor_two = self.factory.makeProcessor(
         supports_virtualized=True)
     self.distroseries = self.factory.makeDistroSeries()
     self.distribution = self.distroseries.distribution
     self.das_one = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor_one)
     self.das_two = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor_two)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PRIMARY)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das_one
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.factory.makeBuilder(processors=[self.processor_one])
         self.factory.makeBuilder(processors=[self.processor_two])
     self.builds = []
     self.spphs = []
Ejemplo n.º 12
0
    def _prepareMergeCopy(self):
        """Add a fresher and a new package to ubuntu/hoary.

        This is used to test merge copy functionality."""
        test_publisher = SoyuzTestPublisher()
        ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
        hoary = ubuntu.getSeries('hoary')
        test_publisher.addFakeChroots(hoary)
        test_publisher.setUpDefaultDistroSeries(hoary)
        test_publisher.getPubSource(sourcename="new-in-second-round",
                                    version="1.0",
                                    distroseries=hoary,
                                    archive=ubuntu.main_archive)
        test_publisher.getPubSource(sourcename="alsa-utils",
                                    version="2.0",
                                    distroseries=hoary,
                                    archive=ubuntu.main_archive)
        sources = ubuntu.main_archive.getPublishedSources(
            distroseries=hoary,
            status=self.pending_statuses,
            name=u'alsa-utils')
        for src in sources:
            if src.source_package_version != '2.0':
                src.supersede()
        LaunchpadZopelessLayer.txn.commit()
Ejemplo n.º 13
0
 def setUp(self):
     super(TestBuildNotify, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Create all of the items we need to create builds
     self.processor = self.factory.makeProcessor(supports_virtualized=True)
     self.distroseries = self.factory.makeDistroSeries()
     self.das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor)
     self.creator = self.factory.makePerson(email='*****@*****.**')
     self.gpgkey = self.factory.makeGPGKey(owner=self.creator)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PRIMARY)
     self.ppa = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PPA)
     buildd_admins = getUtility(IPersonSet).getByName(
         'launchpad-buildd-admins')
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder = self.factory.makeBuilder(
             processors=[self.processor])
         self.buildd_admins_members = list(buildd_admins.activemembers)
     self.builds = []
 def setUp(self):
     """Create the Soyuz test publisher."""
     TestCaseWithFactory.setUp(self)
     self.stp = SoyuzTestPublisher()
     self.stp.prepareBreezyAutotest()
     self.test_package_name = u"accept-test"
     self.distro = self.factory.makeDistribution()
    def setUp(self):
        super(TestBuildJobBase, self).setUp()
        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        self.i8 = self.factory.makeBuilder(name='i386-n-8', virtualized=False)
        self.i9 = self.factory.makeBuilder(name='i386-n-9', virtualized=False)

        processor = getUtility(IProcessorSet).getByName('hppa')
        self.h6 = self.factory.makeBuilder(name='hppa-n-6',
                                           processor=processor,
                                           virtualized=False)
        self.h7 = self.factory.makeBuilder(name='hppa-n-7',
                                           processor=processor,
                                           virtualized=False)

        self.builders = dict()
        # x86 native
        self.builders[(1, False)] = [self.i8, self.i9]

        # hppa native
        self.builders[(3, True)] = [self.h6, self.h7]

        # Ensure all builders are operational.
        for builders in self.builders.values():
            for builder in builders:
                builder.builderok = True
                builder.manual = False

        # Disable the sample data builders.
        getUtility(IBuilderSet)['bob'].builderok = False
        getUtility(IBuilderSet)['frog'].builderok = False
Ejemplo n.º 16
0
 def setUp(self):
     super(TestDetermineArchitecturesToBuild, self).setUp()
     self.publisher = SoyuzTestPublisher()
     self.publisher.prepareBreezyAutotest()
     armel = self.factory.makeProcessor('armel', 'armel', 'armel')
     self.publisher.breezy_autotest.newArch(
         'armel', armel, False, self.publisher.person)
     self.publisher.addFakeChroots()
class TestDistributionHasBuildRecords(TestCaseWithFactory):
    """Populate a distroseries with builds"""

    layer = LaunchpadZopelessLayer

    def setUp(self):
        super(TestDistributionHasBuildRecords, self).setUp()
        self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
        # Create the machinery we need to create builds, such as
        # DistroArchSeries and builders.
        self.processor_one = self.factory.makeProcessor()
        self.processor_two = self.factory.makeProcessor()
        self.distroseries = self.factory.makeDistroSeries()
        self.distribution = self.distroseries.distribution
        self.das_one = self.factory.makeDistroArchSeries(
            distroseries=self.distroseries, processor=self.processor_one,
            supports_virtualized=True)
        self.das_two = self.factory.makeDistroArchSeries(
            distroseries=self.distroseries, processor=self.processor_two,
            supports_virtualized=True)
        self.archive = self.factory.makeArchive(
            distribution=self.distroseries.distribution,
            purpose=ArchivePurpose.PRIMARY)
        self.arch_ids = [arch.id for arch in self.distroseries.architectures]
        with person_logged_in(self.admin):
            self.publisher = SoyuzTestPublisher()
            self.publisher.prepareBreezyAutotest()
            self.distroseries.nominatedarchindep = self.das_one
            self.publisher.addFakeChroots(distroseries=self.distroseries)
            self.builder_one = self.factory.makeBuilder(
                processor=self.processor_one)
            self.builder_two = self.factory.makeBuilder(
                processor=self.processor_two)
        self.builds = []
        self.createBuilds()

    def createBuilds(self):
        for i in range(5):
            # Create some test builds.
            spph = self.publisher.getPubSource(
                sourcename=self.factory.getUniqueString(),
                version="%s.%s" % (self.factory.getUniqueInteger(), i),
                distroseries=self.distroseries, architecturehintlist='any')
            builds = spph.createMissingBuilds()
            for b in builds:
                b.updateStatus(BuildStatus.BUILDING)
                if i == 4:
                    b.updateStatus(BuildStatus.FAILEDTOBUILD)
                else:
                    b.updateStatus(BuildStatus.FULLYBUILT)
                b.buildqueue_record.destroySelf()
            self.builds += builds

    def test_get_build_records(self):
        # A Distribution also implements IHasBuildRecords.
        builds = self.distribution.getBuildRecords().count()
        self.assertEquals(10, builds)
Ejemplo n.º 18
0
 def test_composeBuildRequest(self):
     job = self.makeJob(with_builder=True)
     test_publisher = SoyuzTestPublisher()
     test_publisher.addFakeChroots(job.build.distroseries)
     das = job.build.distroseries.nominatedarchindep
     build_request = yield job.composeBuildRequest(None)
     extra_args = yield job.extraBuildArgs()
     self.assertEqual(
         ('sourcepackagerecipe', das, job.build.pocket, {}, extra_args),
         build_request)
 def setUp(self):
     super(TestSourcesList, self).setUp()
     self.publisher = SoyuzTestPublisher()
     self.ubuntu = getUtility(IDistributionSet).getByName("ubuntu")
     self.hoary = self.ubuntu.getSeries("hoary")
     self.publisher.addFakeChroots(self.hoary)
     self.publisher.setUpDefaultDistroSeries(self.hoary)
     for component_name in self.ubuntu_components:
         component = getUtility(IComponentSet)[component_name]
         if component not in self.hoary.components:
             self.factory.makeComponentSelection(self.hoary, component)
Ejemplo n.º 20
0
 def setUp(self):
     # Log in as an admin, so that we can create distributions.
     super(CurrentSourceReleasesMixin, self).setUp()
     login('*****@*****.**')
     self.publisher = SoyuzTestPublisher()
     self.factory = self.publisher.factory
     self.development_series = self.publisher.setUpDefaultDistroSeries()
     self.distribution = self.development_series.distribution
     self.published_package = self.target.getSourcePackage(
         self.publisher.default_package_name)
     login(ANONYMOUS)
    def _makePublishedSourcePackage(self):
        test_publisher = SoyuzTestPublisher()
        test_data = test_publisher.makeSourcePackageSummaryData()
        source_package_name = test_data["source_package"].sourcepackagename.name
        distroseries_id = test_data["distroseries"].id
        test_publisher.updateDistroSeriesPackageCache(test_data["distroseries"])

        # updateDistroSeriesPackageCache reconnects the db, so the
        # objects need to be reloaded.
        distroseries = getUtility(IDistroSeriesSet).get(distroseries_id)
        return distroseries.getSourcePackage(source_package_name)
Ejemplo n.º 22
0
    def _makePublishedSourcePackage(self):
        test_publisher = SoyuzTestPublisher()
        test_data = test_publisher.makeSourcePackageSummaryData()
        source_package_name = (
            test_data['source_package'].sourcepackagename.name)
        distroseries_id = test_data['distroseries'].id
        test_publisher.updatePackageCache(test_data['distroseries'])

        # updatePackageCache reconnects the db, so the objects need to be
        # reloaded.
        distroseries = getUtility(IDistroSeriesSet).get(distroseries_id)
        return distroseries.getSourcePackage(source_package_name)
Ejemplo n.º 23
0
    def setUp(self):
        """Set up some test publications."""
        super(ArchiveExpiryTestBase, self).setUp()
        # Configure the test publisher.
        switch_dbuser("launchpad")
        self.stp = SoyuzTestPublisher()
        self.stp.prepareBreezyAutotest()

        # Prepare some date properties for the tests to use.
        self.now = datetime.now(pytz.UTC)
        self.under_threshold_date = self.now - timedelta(days=29)
        self.over_threshold_date = self.now - timedelta(days=31)
    def test_can_run_twice(self):
        test_publisher = SoyuzTestPublisher()
        distroseries = test_publisher.setUpDefaultDistroSeries()
        distro = distroseries.distribution
        self.factory.makeComponentSelection(
            distroseries=distroseries, component="main")
        self.factory.makeArchive(
            distribution=distro, purpose=ArchivePurpose.PARTNER)
        test_publisher.getPubSource()

        self.setUpForScriptRun(distro)
        self.makeScript(distro).main()
        self.makeScript(distro).main()
Ejemplo n.º 25
0
    def test_can_run_twice(self):
        test_publisher = SoyuzTestPublisher()
        distroseries = test_publisher.setUpDefaultDistroSeries()
        distro = distroseries.distribution
        self.factory.makeComponentSelection(distroseries=distroseries,
                                            component="main")
        self.factory.makeArchive(distribution=distro,
                                 purpose=ArchivePurpose.PARTNER)
        test_publisher.getPubSource()

        self.setUpForScriptRun(distro)
        self.makeScript(distro).main()
        self.makeScript(distro).main()
Ejemplo n.º 26
0
    def test_publishes_package(self):
        test_publisher = SoyuzTestPublisher()
        distroseries = test_publisher.setUpDefaultDistroSeries()
        distro = distroseries.distribution
        pub_config = get_pub_config(distro)
        self.factory.makeComponentSelection(distroseries=distroseries,
                                            component="main")
        self.factory.makeArchive(distribution=distro,
                                 purpose=ArchivePurpose.PARTNER)
        test_publisher.getPubSource()

        self.setUpForScriptRun(distro)
        self.makeScript(distro).main()

        archive_root = get_archive_root(pub_config)
        dists_root = get_dists_root(pub_config)

        dsc = os.path.join(archive_root, 'pool', 'main', 'f', 'foo',
                           'foo_666.dsc')
        self.assertEqual("I do not care about sources.", file(dsc).read())
        overrides = os.path.join(archive_root + '-overrides',
                                 distroseries.name + '_main_source')
        self.assertEqual(dsc, file(overrides).read().rstrip())
        self.assertTrue(
            path_exists(dists_root, distroseries.name, 'main', 'source',
                        'Sources.gz'))
        self.assertTrue(
            path_exists(dists_root, distroseries.name, 'main', 'source',
                        'Sources.bz2'))

        distcopyseries = os.path.join(dists_root, distroseries.name)
        release = self.readReleaseFile(os.path.join(distcopyseries, "Release"))
        self.assertEqual(distro.displayname, release['Origin'])
        self.assertEqual(distro.displayname, release['Label'])
        self.assertEqual(distroseries.name, release['Suite'])
        self.assertEqual(distroseries.name, release['Codename'])
        self.assertEqual("main", release['Components'])
        self.assertEqual("", release["Architectures"])
        self.assertIn("Date", release)
        self.assertIn("Description", release)
        self.assertNotEqual("", release["MD5Sum"])
        self.assertNotEqual("", release["SHA1"])
        self.assertNotEqual("", release["SHA256"])

        main_release = self.readReleaseFile(
            os.path.join(distcopyseries, 'main', 'source', "Release"))
        self.assertEqual(distroseries.name, main_release["Archive"])
        self.assertEqual("main", main_release["Component"])
        self.assertEqual(distro.displayname, main_release["Origin"])
        self.assertEqual(distro.displayname, main_release["Label"])
        self.assertEqual("source", main_release["Architecture"])
 def setUp(self):
     """Create a distroseriesbinarypackage to play with."""
     super(TestDistroSeriesBinaryPackage, self).setUp()
     self.publisher = SoyuzTestPublisher()
     self.publisher.prepareBreezyAutotest()
     self.distroseries = self.publisher.distroseries
     self.distribution = self.distroseries.distribution
     binaries = self.publisher.getPubBinaries(binaryname='foo-bin',
                                              summary='Foo is the best')
     binary_pub = binaries[0]
     self.binary_package_name = (
         binary_pub.binarypackagerelease.binarypackagename)
     self.distroseries_binary_package = DistroSeriesBinaryPackage(
         self.distroseries, self.binary_package_name)
    def test_publishes_package(self):
        test_publisher = SoyuzTestPublisher()
        distroseries = test_publisher.setUpDefaultDistroSeries()
        distro = distroseries.distribution
        pub_config = get_pub_config(distro)
        self.factory.makeComponentSelection(
            distroseries=distroseries, component="main")
        self.factory.makeArchive(
            distribution=distro, purpose=ArchivePurpose.PARTNER)
        test_publisher.getPubSource()

        self.setUpForScriptRun(distro)
        self.makeScript(distro).main()

        archive_root = get_archive_root(pub_config)
        dists_root = get_dists_root(pub_config)

        dsc = os.path.join(
            archive_root, 'pool', 'main', 'f', 'foo', 'foo_666.dsc')
        self.assertEqual("I do not care about sources.", file(dsc).read())
        overrides = os.path.join(
            archive_root + '-overrides', distroseries.name + '_main_source')
        self.assertEqual(dsc, file(overrides).read().rstrip())
        self.assertTrue(path_exists(
            dists_root, distroseries.name, 'main', 'source', 'Sources.gz'))
        self.assertTrue(path_exists(
            dists_root, distroseries.name, 'main', 'source', 'Sources.bz2'))

        distcopyseries = os.path.join(dists_root, distroseries.name)
        release = self.readReleaseFile(
            os.path.join(distcopyseries, "Release"))
        self.assertEqual(distro.displayname, release['Origin'])
        self.assertEqual(distro.displayname, release['Label'])
        self.assertEqual(distroseries.name, release['Suite'])
        self.assertEqual(distroseries.name, release['Codename'])
        self.assertEqual("main", release['Components'])
        self.assertEqual("", release["Architectures"])
        self.assertIn("Date", release)
        self.assertIn("Description", release)
        self.assertNotEqual("", release["MD5Sum"])
        self.assertNotEqual("", release["SHA1"])
        self.assertNotEqual("", release["SHA256"])

        main_release = self.readReleaseFile(
            os.path.join(distcopyseries, 'main', 'source', "Release"))
        self.assertEqual(distroseries.name, main_release["Archive"])
        self.assertEqual("main", main_release["Component"])
        self.assertEqual(distro.displayname, main_release["Origin"])
        self.assertEqual(distro.displayname, main_release["Label"])
        self.assertEqual("source", main_release["Architecture"])
Ejemplo n.º 29
0
 def setUp(self):
     super(TestBuildPrivacy, self).setUp()
     # Add everything we need to create builds.
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     processor = self.factory.makeProcessor(supports_virtualized=True)
     distroseries = self.factory.makeDistroSeries()
     das = self.factory.makeDistroArchSeries(
         distroseries=distroseries, processor=processor)
     with person_logged_in(self.admin):
         publisher = SoyuzTestPublisher()
         publisher.prepareBreezyAutotest()
         distroseries.nominatedarchindep = das
         publisher.addFakeChroots(distroseries=distroseries)
         self.factory.makeBuilder(processors=[processor])
     self.public_archive = self.factory.makeArchive()
     self.private_archive = self.factory.makeArchive(private=True)
     # Create one public and one private build.
     public_spph = publisher.getPubSource(
         sourcename=self.factory.getUniqueString(),
         version="%s.1" % self.factory.getUniqueInteger(),
         distroseries=distroseries, archive=self.public_archive)
     [public_build] = public_spph.createMissingBuilds()
     private_spph = publisher.getPubSource(
         sourcename=self.factory.getUniqueString(),
         version="%s.1" % self.factory.getUniqueInteger(),
         distroseries=distroseries, archive=self.private_archive)
     with person_logged_in(self.admin):
         [private_build] = private_spph.createMissingBuilds()
     self.expected_title = '%s build of %s %s in %s %s RELEASE' % (
         das.architecturetag, private_spph.source_package_name,
         private_spph.source_package_version,
         distroseries.distribution.name, distroseries.name)
Ejemplo n.º 30
0
 def setUp(self):
     super(TestBuild, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     self.processor = self.factory.makeProcessor(supports_virtualized=True)
     self.distroseries = self.factory.makeDistroSeries()
     self.das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder = self.factory.makeBuilder(
             processors=[self.processor])
     self.now = datetime.now(pytz.UTC)
 def setUp(self):
     """Create the Soyuz test publisher."""
     TestCaseWithFactory.setUp(self)
     self.stp = SoyuzTestPublisher()
     self.stp.prepareBreezyAutotest()
     self.test_package_name = u"accept-test"
     self.distro = self.factory.makeDistribution()
Ejemplo n.º 32
0
 def setUp(self):
     super(TestBuildNotify, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Create all of the items we need to create builds
     self.processor = self.factory.makeProcessor()
     self.distroseries = self.factory.makeDistroSeries()
     self.das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor,
         supports_virtualized=True)
     self.creator = self.factory.makePerson(email='*****@*****.**')
     self.gpgkey = self.factory.makeGPGKey(owner=self.creator)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PRIMARY)
     self.ppa = self.factory.makeArchive()
     buildd_admins = getUtility(IPersonSet).getByName(
         'launchpad-buildd-admins')
     self.buildd_admins_email = []
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder = self.factory.makeBuilder(processor=self.processor)
         for member in buildd_admins.activemembers:
             self.buildd_admins_email.append(member.preferredemail.email)
     self.builds = []
 def setUp(self):
     super(TestDistributionHasBuildRecords, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Create the machinery we need to create builds, such as
     # DistroArchSeries and builders.
     self.processor_one = self.factory.makeProcessor()
     self.processor_two = self.factory.makeProcessor()
     self.distroseries = self.factory.makeDistroSeries()
     self.distribution = self.distroseries.distribution
     self.das_one = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor_one,
         supports_virtualized=True)
     self.das_two = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor_two,
         supports_virtualized=True)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PRIMARY)
     self.arch_ids = [arch.id for arch in self.distroseries.architectures]
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das_one
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder_one = self.factory.makeBuilder(
             processor=self.processor_one)
         self.builder_two = self.factory.makeBuilder(
             processor=self.processor_two)
     self.builds = []
     self.createBuilds()
Ejemplo n.º 34
0
 def setUp(self):
     super(TestBuildSet, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     self.processor_one = self.factory.makeProcessor()
     self.processor_two = self.factory.makeProcessor()
     self.distroseries = self.factory.makeDistroSeries()
     self.distribution = self.distroseries.distribution
     self.das_one = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor_one,
         supports_virtualized=True)
     self.das_two = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor_two,
         supports_virtualized=True)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution,
         purpose=ArchivePurpose.PRIMARY)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das_one
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder_one = self.factory.makeBuilder(
             processor=self.processor_one)
         self.builder_two = self.factory.makeBuilder(
             processor=self.processor_two)
     self.builds = []
     self.spphs = []
Ejemplo n.º 35
0
 def setUp(self):
     super(TestBuildStartEstimation, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         for buildd in getUtility(IBuilderSet):
             buildd.builderok = True
     self.distroseries = self.factory.makeDistroSeries()
     self.bob = getUtility(IBuilderSet).getByName(BOB_THE_BUILDER_NAME)
     das = self.factory.makeDistroArchSeries(distroseries=self.distroseries,
                                             processor=self.bob.processor,
                                             architecturetag='i386')
     with person_logged_in(self.admin):
         self.distroseries.nominatedarchindep = das
     self.publisher.addFakeChroots(distroseries=self.distroseries)
Ejemplo n.º 36
0
 def setUp(self):
     super(TestDistroSourcePackageReleaseFiles, self).setUp()
     # The package must be published for the page to render.
     stp = SoyuzTestPublisher()
     distroseries = stp.setUpDefaultDistroSeries()
     naked_distroseries = remove_security_proxy_and_shout_at_engineer(
         distroseries)
     # XXX Abel Deuring, 2010-07-21, bug 608240. This is scary. But
     # if we use distroseries.distribution instead,
     # test_spr_files_deleted() and test_spr_files_one() fail.
     distro = naked_distroseries.distribution
     source_package_release = stp.getPubSource().sourcepackagerelease
     self.dspr = DistributionSourcePackageRelease(distro,
                                                  source_package_release)
     self.library_file = self.factory.makeLibraryFileAlias(
         filename='test_file.dsc', content='0123456789')
     source_package_release.addFile(self.library_file)
Ejemplo n.º 37
0
 def test_script_creates_indexes(self):
     # End-to-end test: the script creates indexes for distroseries
     # that need them.
     test_publisher = SoyuzTestPublisher()
     series = test_publisher.setUpDefaultDistroSeries()
     series.status = SeriesStatus.FROZEN
     self.factory.makeComponentSelection(distroseries=series,
                                         component="main")
     self.layer.txn.commit()
     self.setUpForScriptRun(series.distribution)
     script = self.makeScript(series.distribution)
     script.main()
     self.assertEqual([], script.listSuitesNeedingIndexes(series))
     sources = os.path.join(
         getPubConfig(series.main_archive).distsroot, series.name, "main",
         "source", "Sources")
     self.assertTrue(file_exists(sources))
 def setUp(self):
     super(TestDistroSourcePackageReleaseFiles, self).setUp()
     # The package must be published for the page to render.
     stp = SoyuzTestPublisher()
     distroseries = stp.setUpDefaultDistroSeries()
     naked_distroseries = remove_security_proxy_and_shout_at_engineer(
         distroseries)
     # XXX Abel Deuring, 2010-07-21, bug 608240. This is scary. But
     # if we use distroseries.distribution instead,
     # test_spr_files_deleted() and test_spr_files_one() fail.
     distro = naked_distroseries.distribution
     source_package_release = stp.getPubSource().sourcepackagerelease
     self.dspr = DistributionSourcePackageRelease(
         distro, source_package_release)
     self.library_file = self.factory.makeLibraryFileAlias(
         filename='test_file.dsc', content='0123456789')
     source_package_release.addFile(self.library_file)
 def test_script_creates_indexes(self):
     # End-to-end test: the script creates indexes for distroseries
     # that need them.
     test_publisher = SoyuzTestPublisher()
     series = test_publisher.setUpDefaultDistroSeries()
     series.status = SeriesStatus.FROZEN
     self.factory.makeComponentSelection(
         distroseries=series, component="main")
     self.layer.txn.commit()
     self.setUpForScriptRun(series.distribution)
     script = self.makeScript(series.distribution)
     script.main()
     self.assertEqual([], script.listSuitesNeedingIndexes(series))
     sources = os.path.join(
         getPubConfig(series.main_archive).distsroot,
         series.name, "main", "source", "Sources")
     self.assertTrue(file_exists(sources))
Ejemplo n.º 40
0
    def setUp(self):
        """Publish some gedit sources in main and PPAs."""
        super(TestDistributionSourcePackageFindRelatedArchives, self).setUp()

        self.distribution = getUtility(IDistributionSet)['ubuntutest']

        # Create two PPAs for gedit.
        self.archives = {}
        self.archives['ubuntu-main'] = self.distribution.main_archive
        self.archives['gedit-nightly'] = self.factory.makeArchive(
            name="gedit-nightly", distribution=self.distribution)
        self.archives['gedit-beta'] = self.factory.makeArchive(
            name="gedit-beta", distribution=self.distribution)

        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        # Publish gedit in all three archives.
        self.person_nightly = self.factory.makePerson()
        self.gedit_nightly_src_hist = self.publisher.getPubSource(
            sourcename="gedit",
            archive=self.archives['gedit-nightly'],
            creator=self.person_nightly,
            status=PackagePublishingStatus.PUBLISHED)

        self.person_beta = self.factory.makePerson()
        self.gedit_beta_src_hist = self.publisher.getPubSource(
            sourcename="gedit",
            archive=self.archives['gedit-beta'],
            creator=self.person_beta,
            status=PackagePublishingStatus.PUBLISHED)
        self.gedit_main_src_hist = self.publisher.getPubSource(
            sourcename="gedit",
            archive=self.archives['ubuntu-main'],
            status=PackagePublishingStatus.PUBLISHED)

        # Save the gedit source package for easy access.
        self.source_package = self.distribution.getSourcePackage('gedit')

        # Add slightly more soyuz karma for person_nightly for this package.
        switch_dbuser('karma')
        self.person_beta_karma = KarmaTotalCache(person=self.person_beta,
                                                 karma_total=200)
        self.person_nightly_karma = KarmaTotalCache(person=self.person_nightly,
                                                    karma_total=201)
        switch_dbuser('launchpad')
Ejemplo n.º 41
0
 def setUp(self):
     super(TestBuildPrivacy, self).setUp()
     # Add everything we need to create builds.
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     processor = self.factory.makeProcessor()
     distroseries = self.factory.makeDistroSeries()
     das = self.factory.makeDistroArchSeries(
         distroseries=distroseries, processor=processor,
         supports_virtualized=True)
     with person_logged_in(self.admin):
         publisher = SoyuzTestPublisher()
         publisher.prepareBreezyAutotest()
         distroseries.nominatedarchindep = das
         publisher.addFakeChroots(distroseries=distroseries)
         self.factory.makeBuilder(processor=processor)
     self.public_archive = self.factory.makeArchive()
     self.private_archive = self.factory.makeArchive(private=True)
     # Create one public and one private build.
     public_spph = publisher.getPubSource(
         sourcename=self.factory.getUniqueString(),
         version="%s.1" % self.factory.getUniqueInteger(),
         distroseries=distroseries, archive=self.public_archive)
     [public_build] = public_spph.createMissingBuilds()
     private_spph = publisher.getPubSource(
         sourcename=self.factory.getUniqueString(),
         version="%s.1" % self.factory.getUniqueInteger(),
         distroseries=distroseries, archive=self.private_archive)
     with person_logged_in(self.admin):
         [private_build] = private_spph.createMissingBuilds()
     self.expected_title = '%s build of %s %s in %s %s RELEASE' % (
         das.architecturetag, private_spph.source_package_name,
         private_spph.source_package_version,
         distroseries.distribution.name, distroseries.name)
Ejemplo n.º 42
0
class TestBuildStartEstimation(TestCaseWithFactory):

    layer = LaunchpadFunctionalLayer

    def setUp(self):
        super(TestBuildStartEstimation, self).setUp()
        self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
        with person_logged_in(self.admin):
            self.publisher = SoyuzTestPublisher()
            self.publisher.prepareBreezyAutotest()
            for buildd in getUtility(IBuilderSet):
                buildd.builderok = True
        self.distroseries = self.factory.makeDistroSeries()
        self.bob = getUtility(IBuilderSet).getByName(BOB_THE_BUILDER_NAME)
        das = self.factory.makeDistroArchSeries(distroseries=self.distroseries,
                                                processor=self.bob.processor,
                                                architecturetag='i386')
        with person_logged_in(self.admin):
            self.distroseries.nominatedarchindep = das
        self.publisher.addFakeChroots(distroseries=self.distroseries)

    def job_start_estimate(self, build):
        return build.buildqueue_record.getEstimatedJobStartTime()

    def test_estimation(self):
        pkg = self.publisher.getPubSource(
            sourcename=self.factory.getUniqueString(),
            distroseries=self.distroseries)
        build = pkg.createMissingBuilds()[0]
        now = datetime.now(pytz.UTC)
        estimate = self.job_start_estimate(build)
        self.assertTrue(estimate > now)

    def test_disabled_archives(self):
        pkg1 = self.publisher.getPubSource(
            sourcename=self.factory.getUniqueString(),
            distroseries=self.distroseries)
        [build1] = pkg1.createMissingBuilds()
        build1.buildqueue_record.lastscore = 1000
        # No user-serviceable parts inside
        removeSecurityProxy(
            build1.buildqueue_record).estimated_duration = (timedelta(
                minutes=10))
        pkg2 = self.publisher.getPubSource(
            sourcename=self.factory.getUniqueString(),
            distroseries=self.distroseries)
        [build2] = pkg2.createMissingBuilds()
        build2.buildqueue_record.lastscore = 100
        now = datetime.now(pytz.UTC)
        # Since build1 is higher priority, it's estimated dispatch time is now
        estimate = self.job_start_estimate(build1)
        self.assertEqual(5, (estimate - now).seconds)
        # And build2 is next, so must take build1's duration into account
        estimate = self.job_start_estimate(build2)
        self.assertEqual(600, (estimate - now).seconds)
        # If we disable build1's archive, build2 is next
        with person_logged_in(self.admin):
            build1.archive.disable()
        estimate = self.job_start_estimate(build2)
        self.assertEqual(5, (estimate - now).seconds)
class TestBuildStartEstimation(TestCaseWithFactory):

    layer = LaunchpadFunctionalLayer

    def setUp(self):
        super(TestBuildStartEstimation, self).setUp()
        self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
        with person_logged_in(self.admin):
            self.publisher = SoyuzTestPublisher()
            self.publisher.prepareBreezyAutotest()
            for buildd in getUtility(IBuilderSet):
                buildd.builderok = True
        self.distroseries = self.factory.makeDistroSeries()
        self.bob = getUtility(IBuilderSet).getByName(BOB_THE_BUILDER_NAME)
        das = self.factory.makeDistroArchSeries(
            distroseries=self.distroseries, processor=self.bob.processor,
            architecturetag='i386', supports_virtualized=True)
        with person_logged_in(self.admin):
            self.distroseries.nominatedarchindep = das
        self.publisher.addFakeChroots(distroseries=self.distroseries)

    def job_start_estimate(self, build):
        return build.buildqueue_record.getEstimatedJobStartTime()

    def test_estimation(self):
        pkg = self.publisher.getPubSource(
            sourcename=self.factory.getUniqueString(),
            distroseries=self.distroseries)
        build = pkg.createMissingBuilds()[0]
        now = datetime.now(pytz.UTC)
        estimate = self.job_start_estimate(build)
        self.assertTrue(estimate > now)

    def test_disabled_archives(self):
        pkg1 = self.publisher.getPubSource(
            sourcename=self.factory.getUniqueString(),
            distroseries=self.distroseries)
        [build1] = pkg1.createMissingBuilds()
        build1.buildqueue_record.lastscore = 1000
        # No user-serviceable parts inside
        removeSecurityProxy(build1.buildqueue_record).estimated_duration = (
            timedelta(minutes=10))
        pkg2 = self.publisher.getPubSource(
            sourcename=self.factory.getUniqueString(),
            distroseries=self.distroseries)
        [build2] = pkg2.createMissingBuilds()
        build2.buildqueue_record.lastscore = 100
        now = datetime.now(pytz.UTC)
        # Since build1 is higher priority, it's estimated dispatch time is now
        estimate = self.job_start_estimate(build1)
        self.assertEquals(5, (estimate - now).seconds)
        # And build2 is next, so must take build1's duration into account
        estimate = self.job_start_estimate(build2)
        self.assertEquals(600, (estimate - now).seconds)
        # If we disable build1's archive, build2 is next
        with person_logged_in(self.admin):
            build1.archive.disable()
        estimate = self.job_start_estimate(build2)
        self.assertEquals(5, (estimate - now).seconds)
Ejemplo n.º 44
0
 def setUp(self):
     super(TestSourcePublicationListingExtra, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Create everything we need to create builds, such as a
     # DistroArchSeries and a builder.
     self.processor = self.factory.makeProcessor(supports_virtualized=True)
     self.distroseries = self.factory.makeDistroSeries(
         distribution=getUtility(IDistributionSet)['ubuntu'])
     self.das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder = self.factory.makeBuilder(
             processors=[self.processor])
Ejemplo n.º 45
0
class TestPlatformData(TestCaseWithFactory):
    """Tests covering the processor/virtualized properties."""

    layer = LaunchpadZopelessLayer

    def setUp(self):
        """Set up a native x86 build for the test archive."""
        super(TestPlatformData, self).setUp()

        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        # First mark all builds in the sample data as already built.
        sample_data = IStore(BinaryPackageBuild).find(BinaryPackageBuild)
        for build in sample_data:
            build.buildstate = BuildStatus.FULLYBUILT
        IStore(BinaryPackageBuild).flush()

        # We test builds that target a primary archive.
        self.non_ppa = self.factory.makeArchive(
            name="primary", purpose=ArchivePurpose.PRIMARY)
        self.non_ppa.require_virtualized = False

        self.builds = []
        self.builds.extend(
            self.publisher.getPubSource(
                sourcename="gedit", status=PackagePublishingStatus.PUBLISHED,
                archive=self.non_ppa).createMissingBuilds())

    def test_JobPlatformSettings(self):
        """The `BuildQueue` instance shares the processor/virtualized
        properties with the associated `Build`."""
        build, bq = find_job(self, 'gedit')

        # Make sure the 'processor' properties are the same.
        self.assertEqual(
            bq.processor, build.processor,
            "The 'processor' property deviates.")

        # Make sure the 'virtualized' properties are the same.
        self.assertEqual(
            bq.virtualized, build.virtualized,
            "The 'virtualized' property deviates.")
 def updatePackageCache(self):
     # Create package cache records for new binary packages.
     #
     # SoyuzTestPublisher.updatePackageCache() creates a
     # DistroSeriesPackageCache record for the new binary package.
     # The method closes the current DB connection, making references
     # to DB objects in other DB objects unusable. Starting with
     # the distroarchseries, we can create new, valid, instances of
     # objects required later in the test again.
     # of the objects we need later.
     sourcepackagename = self.sourcepackagerelease.sourcepackagename
     publisher = SoyuzTestPublisher()
     publisher.updatePackageCache(self.distroarchseries.distroseries)
     self.distroarchseries = DistroArchSeries.get(self.distroarchseries.id)
     distribution = self.distroarchseries.distroseries.distribution
     releases = distribution.getCurrentSourceReleases([sourcepackagename])
     [(distribution_sourcepackage, dsp_release)] = releases.items()
     self.dsp_release = dsp_release
     self.sourcepackagerelease = dsp_release.sourcepackagerelease
    def setUp(self):
        super(TestScriptRunning, self).setUp()
        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        self.store = IStore(BinaryPackageReleaseDownloadCount)

        self.archive = getUtility(IPersonSet).getByName('cprov').archive
        self.archive.require_virtualized = False

        self.foo_i386, self.foo_hppa = self.publisher.getPubBinaries(
            archive=self.archive, architecturespecific=True)
        self.bar_i386, self.bar_hppa = self.publisher.getPubBinaries(
            binaryname='bar-bin',
            archive=self.archive,
            architecturespecific=False)

        # Commit so the script can see our changes.
        import transaction
        transaction.commit()
Ejemplo n.º 48
0
 def setUp(self):
     # Log in as an admin, so that we can create distributions.
     super(CurrentSourceReleasesMixin, self).setUp()
     login('*****@*****.**')
     self.publisher = SoyuzTestPublisher()
     self.factory = self.publisher.factory
     self.development_series = self.publisher.setUpDefaultDistroSeries()
     self.distribution = self.development_series.distribution
     self.published_package = self.target.getSourcePackage(
         self.publisher.default_package_name)
     login(ANONYMOUS)
 def updateDistroSeriesPackageCache(self):
     # Create DistroSeriesPackageCache records for new binary
     # packages.
     #
     # SoyuzTestPublisher.updateDistroSeriesPackageCache() creates
     # a DistroSeriesPackageCache record for the new binary package.
     # The method closes the current DB connection, making references
     # to DB objects in other DB objects unusable. Starting with
     # the distroarchseries, we can create new, valid, instances of
     # objects required later in the test again.
     # of the objects we need later.
     sourcepackagename = self.sourcepackagerelease.sourcepackagename
     publisher = SoyuzTestPublisher()
     publisher.updateDistroSeriesPackageCache(
         self.distroarchseries.distroseries)
     self.distroarchseries = DistroArchSeries.get(self.distroarchseries.id)
     distribution = self.distroarchseries.distroseries.distribution
     releases = distribution.getCurrentSourceReleases([sourcepackagename])
     [(distribution_sourcepackage, dsp_release)] = releases.items()
     self.dsp_release = dsp_release
     self.sourcepackagerelease = dsp_release.sourcepackagerelease
 def setUp(self):
     """Create a distroseriesbinarypackage to play with."""
     super(TestDistroSeriesBinaryPackage, self).setUp()
     self.publisher = SoyuzTestPublisher()
     self.publisher.prepareBreezyAutotest()
     self.distroseries = self.publisher.distroseries
     self.distribution = self.distroseries.distribution
     binaries = self.publisher.getPubBinaries(
         binaryname='foo-bin', summary='Foo is the best')
     binary_pub = binaries[0]
     self.binary_package_name = (
         binary_pub.binarypackagerelease.binarypackagename)
     self.distroseries_binary_package = DistroSeriesBinaryPackage(
         self.distroseries, self.binary_package_name)
Ejemplo n.º 51
0
 def setUp(self):
     super(TestBuild, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     self.processor = self.factory.makeProcessor()
     self.distroseries = self.factory.makeDistroSeries()
     self.das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor,
         supports_virtualized=True)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder = self.factory.makeBuilder(processor=self.processor)
     self.now = datetime.now(pytz.UTC)
 def setUp(self):
     super(TestBuildStartEstimation, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         for buildd in getUtility(IBuilderSet):
             buildd.builderok = True
     self.distroseries = self.factory.makeDistroSeries()
     self.bob = getUtility(IBuilderSet).getByName(BOB_THE_BUILDER_NAME)
     das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.bob.processor,
         architecturetag='i386', supports_virtualized=True)
     with person_logged_in(self.admin):
         self.distroseries.nominatedarchindep = das
     self.publisher.addFakeChroots(distroseries=self.distroseries)
    def _prepareMergeCopy(self):
        """Add a fresher and a new package to ubuntu/hoary.

        This is used to test merge copy functionality."""
        test_publisher = SoyuzTestPublisher()
        ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
        hoary = ubuntu.getSeries('hoary')
        test_publisher.addFakeChroots(hoary)
        test_publisher.setUpDefaultDistroSeries(hoary)
        test_publisher.getPubSource(
            sourcename="new-in-second-round", version="1.0",
            distroseries=hoary, archive=ubuntu.main_archive)
        test_publisher.getPubSource(
            sourcename="alsa-utils", version="2.0", distroseries=hoary,
            archive=ubuntu.main_archive)
        sources = ubuntu.main_archive.getPublishedSources(
            distroseries=hoary, status=self.pending_statuses,
            name=u'alsa-utils')
        for src in sources:
            if src.source_package_version != '2.0':
                src.supersede()
        LaunchpadZopelessLayer.txn.commit()
    def test_switch_privacy_with_pubs_fails(self):
        # Changing the privacy is not possible when the archive already
        # has published sources.
        public_ppa = self.factory.makeArchive(private=False)
        publisher = SoyuzTestPublisher()
        publisher.prepareBreezyAutotest()

        private_ppa = self.factory.makeArchive(private=True)
        publisher.getPubSource(archive=public_ppa)
        publisher.getPubSource(archive=private_ppa)

        self.assertRaises(
            CannotSwitchPrivacy, setattr, public_ppa, 'private', True)

        self.assertRaises(
            CannotSwitchPrivacy, setattr, private_ppa, 'private', False)
Ejemplo n.º 55
0
 def setUp(self):
     super(TestSourcePublicationListingExtra, self).setUp()
     self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Create everything we need to create builds, such as a
     # DistroArchSeries and a builder.
     self.processor = self.factory.makeProcessor()
     self.distroseries = self.factory.makeDistroSeries()
     self.das = self.factory.makeDistroArchSeries(
         distroseries=self.distroseries, processor=self.processor,
         supports_virtualized=True)
     self.archive = self.factory.makeArchive(
         distribution=self.distroseries.distribution)
     with person_logged_in(self.admin):
         self.publisher = SoyuzTestPublisher()
         self.publisher.prepareBreezyAutotest()
         self.distroseries.nominatedarchindep = self.das
         self.publisher.addFakeChroots(distroseries=self.distroseries)
         self.builder = self.factory.makeBuilder(processor=self.processor)
    def setUp(self):
        super(TestScriptRunning, self).setUp()
        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        self.store = IStore(BinaryPackageReleaseDownloadCount)

        self.archive = getUtility(IPersonSet).getByName('cprov').archive
        self.archive.require_virtualized = False

        self.foo_i386, self.foo_hppa = self.publisher.getPubBinaries(
                archive=self.archive, architecturespecific=True)
        self.bar_i386, self.bar_hppa = self.publisher.getPubBinaries(
                binaryname='bar-bin', archive=self.archive,
                architecturespecific=False)

        # Commit so the script can see our changes.
        import transaction
        transaction.commit()
    def setUp(self):
        """Publish some gedit sources in main and PPAs."""
        super(TestDistributionSourcePackageFindRelatedArchives, self).setUp()

        self.distribution = getUtility(IDistributionSet)['ubuntutest']

        # Create two PPAs for gedit.
        self.archives = {}
        self.archives['ubuntu-main'] = self.distribution.main_archive
        self.archives['gedit-nightly'] = self.factory.makeArchive(
            name="gedit-nightly", distribution=self.distribution)
        self.archives['gedit-beta'] = self.factory.makeArchive(
            name="gedit-beta", distribution=self.distribution)

        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        # Publish gedit in all three archives.
        self.person_nightly = self.factory.makePerson()
        self.gedit_nightly_src_hist = self.publisher.getPubSource(
            sourcename="gedit", archive=self.archives['gedit-nightly'],
            creator=self.person_nightly,
            status=PackagePublishingStatus.PUBLISHED)

        self.person_beta = self.factory.makePerson()
        self.gedit_beta_src_hist = self.publisher.getPubSource(
            sourcename="gedit", archive=self.archives['gedit-beta'],
            creator=self.person_beta,
            status=PackagePublishingStatus.PUBLISHED)
        self.gedit_main_src_hist = self.publisher.getPubSource(
            sourcename="gedit", archive=self.archives['ubuntu-main'],
            status=PackagePublishingStatus.PUBLISHED)

        # Save the gedit source package for easy access.
        self.source_package = self.distribution.getSourcePackage('gedit')

        # Add slightly more soyuz karma for person_nightly for this package.
        switch_dbuser('karma')
        self.person_beta_karma = KarmaTotalCache(
            person=self.person_beta, karma_total=200)
        self.person_nightly_karma = KarmaTotalCache(
            person=self.person_nightly, karma_total=201)
        switch_dbuser('launchpad')
    def _setupSimpleDepwaitContext(self):
        """Use `SoyuzTestPublisher` to setup a simple depwait context.

        Return an `IBinaryPackageBuild` in MANUALDEWAIT state and depending
        on a binary that exists and is reachable.
        """
        self.publisher = SoyuzTestPublisher()
        self.publisher.prepareBreezyAutotest()

        depwait_source = self.publisher.getPubSource(
            sourcename='depwait-source')

        self.publisher.getPubBinaries(
            binaryname='dep-bin', status=PackagePublishingStatus.PUBLISHED)

        [depwait_build] = depwait_source.createMissingBuilds()
        depwait_build.updateStatus(
            BuildStatus.MANUALDEPWAIT,
            slave_status={'dependencies': u'dep-bin'})
        return depwait_build