Exemple #1
0
    def _monitorJob(self, jobId):
        """
        Monitor job status, block until complete.
        @param jobId: rMake job ID
        @type jobId: integer
        """

        # Watch build, wait for completion
        monitor.monitorJob(self._helper.client, jobId,
            exitOnFinish=True, displayClass=StatusOnlyDisplay)
Exemple #2
0
    def watch(self, jobId, showTroveLogs = False, showBuildLogs = False,
              commit = False, message = None, exitOnFinish = None):
        """
            Displays information about a currently running job.  Always displays
            high-level information like "Job building", "Job stopped".  Displays
            state and log information for troves based on options.

            @param jobId: jobId or uuid for a given job.
            @type jobId: int or uuid
            @param showTroveLogs: If True, display trove state log information
            @param showBuildLogs: If True, display build log for troves.
            @param commit: If True, commit job upon completion.
            @return: True if watch returns normally (and commit succeeds, if
            commit requested).
            @rtype: bool
        """
        if not exitOnFinish:
            exitOnFinish = commit

        try:
            jobMonitor = monitor.monitorJob(self.client, jobId,
                                            showTroveDetails = showTroveLogs,
                                            showBuildLogs = showBuildLogs,
                                            exitOnFinish=exitOnFinish)
        except Exception, err:
            if commit:
                print "Poll interrupted, not committing"
                print "You can restart commit by running 'rmake watch %s --commit'" % jobId
            raise
Exemple #3
0
    def watch(self, jobId, showTroveLogs = False, showBuildLogs = False,
              commit = False, message = None, exitOnFinish = None):
        """
            Displays information about a currently running job.  Always displays
            high-level information like "Job building", "Job stopped".  Displays
            state and log information for troves based on options.

            @param jobId: jobId or uuid for a given job.
            @type jobId: int or uuid
            @param showTroveLogs: If True, display trove state log information
            @param showBuildLogs: If True, display build log for troves.
            @param commit: If True, commit job upon completion.
            @return: True if watch returns normally (and commit succeeds, if
            commit requested).
            @rtype: bool
        """
        if not exitOnFinish:
            exitOnFinish = commit

        try:
            jobMonitor = monitor.monitorJob(self.client, jobId,
                                            showTroveDetails = showTroveLogs,
                                            showBuildLogs = showBuildLogs,
                                            exitOnFinish=exitOnFinish)
        except Exception, err:
            if commit:
                print "Poll interrupted, not committing"
                print "You can restart commit by running 'rmake watch %s --commit'" % jobId
            raise
Exemple #4
0
    def _testPrimingMonitorOutput(self, multinode):
        db = self.openRmakeDatabase()
        self.openRmakeRepository()
        repos = self.openRepository()
        client = self.startRmakeServer(multinode=multinode)
        if multinode:
            self.startNode()

        atrv = self.Component('a:source')[0]

        port = testsuite.findPorts()[0]
        monitorUri = 'http://localhost:%s/conary' % port
        job = self.newJob(atrv)
        m = monitor.monitorJob(client, job.jobId, serve=False,
                               showBuildLogs=True, showTroveDetails=True,
                               uri=monitorUri)
        a, = buildTroves = self.makeBuildTroves(job)

        self._subscribeServer(client, job, multinode)

        job.setBuildTroves(buildTroves)
        dh = self.getDependencyHandler(job, repos)
        job.log('foo1')
        job.log('foo2')


        logPath = self.workDir + '/logPath'
        log = open(logPath, 'w')

        a.logPath = logPath
        a.troveBuilding()

        if multinode:
            rc, txt = self.captureOutput(m.listener._primeOutput, job.jobId)
        else:
            rc, txt = self.captureOutput(m.subscribe, job.jobId)
        assert('foo1' in txt)
        assert('foo2' in txt)
        rc, txt = self.captureOutput(m._serveLoopHook)
        assert(txt == '')
        rc, txt = self.captureOutput(m._serveLoopHook)
        assert(txt == '')
        log.write('bar\nbam\n')
        log.close()
        rc, txt = self.captureOutput(m._serveLoopHook)
        assert(txt == 'bar\nbam\n')
Exemple #5
0
    def _testPrimingMonitorOutput(self, multinode):
        db = self.openRmakeDatabase()
        self.openRmakeRepository()
        repos = self.openRepository()
        client = self.startRmakeServer(multinode=multinode)
        if multinode:
            self.startNode()

        atrv = self.Component("a:source")[0]

        port = testsuite.findPorts()[0]
        monitorUri = "http://localhost:%s/conary" % port
        job = self.newJob(atrv)
        m = monitor.monitorJob(
            client, job.jobId, serve=False, showBuildLogs=True, showTroveDetails=True, uri=monitorUri
        )
        a, = buildTroves = self.makeBuildTroves(job)

        self._subscribeServer(client, job, multinode)

        job.setBuildTroves(buildTroves)
        dh = self.getDependencyHandler(job, repos)
        job.log("foo1")
        job.log("foo2")

        logPath = self.workDir + "/logPath"
        log = open(logPath, "w")

        a.logPath = logPath
        a.troveBuilding()

        if multinode:
            rc, txt = self.captureOutput(m.listener._primeOutput, job.jobId)
        else:
            rc, txt = self.captureOutput(m.subscribe, job.jobId)
        assert "foo1" in txt
        assert "foo2" in txt
        rc, txt = self.captureOutput(m._serveLoopHook)
        assert txt == ""
        rc, txt = self.captureOutput(m._serveLoopHook)
        assert txt == ""
        log.write("bar\nbam\n")
        log.close()
        rc, txt = self.captureOutput(m._serveLoopHook)
        assert txt == "bar\nbam\n"
Exemple #6
0
    def run(self, main):
        '''
        Create and run a rMake build job from the set of added troves,
        process the resulting artifacts, and commit if no errors or
        failed tests were encountered.
        '''

        troveNames = sorted(set(x[0].split(':')[0] for x in self._troves))
        log.info('Creating build job: %s', ' '.join(troveNames))

        # Create rMake job
        cfg = self._helper.cfg
        # If there's only one unique package being built, tell rmake not to do
        # dep ordering. This speeds up builds of core packages like Conary,
        # because otherwise rmake would wait for one flavor to build before
        # starting the other flavor due to dep confusion.
        cfg.isolateTroves = len(set(x[0] for x in self._troves)) == 1
        job = self._helper.getrMakeHelper().createBuildJob(list(self._troves),
                buildConfig=cfg)
        jobId = self._helper.getrMakeClient().buildJob(job)
        log.info('Job %d started with these sources:', jobId)
        for trove in self._bobTroves:
            version = trove.getDownstreamVersion()
            log.info(' %s=%s/%s', trove.getName(),
                    version.trailingLabel(), version.trailingRevision())

        # Set a signal handler so we can stop the job if we get
        # interrupted
        self._jobId = jobId
        pushStopHandler(partial(stopJob, self))

        # Watch build (to stdout)
        self._helper.callClientHook('client_preCommand', main,
            None, (self._helper.cfg, self._helper.cfg),
            None, None)
        self._helper.callClientHook('client_preCommand2', main,
            self._helper.getrMakeHelper(), None)
        monitor.monitorJob(self._helper.getrMakeClient(), jobId,
            exitOnFinish=True, displayClass=StatusOnlyDisplay,
            showBuildLogs=self._helper.plan.showBuildLogs)

        # Remove the signal handler now that the job is done
        self._jobId = None
        popStopHandler()

        # Pull out logs
        job = self._helper.getrMakeClient().getJob(jobId)
        self.writeLogs(job)

        # Check for error condition
        if job.isFailed():
            log.error('Job %d failed', jobId)
            raise JobFailedError(jobId=jobId, why='Job failed')
        elif not job.isFinished():
            log.error('Job %d is not done, yet watch returned early!', jobId)
            raise JobFailedError(jobId=jobId, why='Job not done')
        elif not list(job.iterBuiltTroves()):
            log.error('Job %d has no built troves', jobId)
            raise JobFailedError(jobId=jobId, why='Job built no troves')

        # Fetch test/coverage output and report results
        self._testSuite, self._coverageData = test.processTests(self._helper,
            job)
        print 'Batch results:', self._testSuite.describe()

        # Bail out without committing if tests failed
        if not self._testSuite.isSuccessful():
            log.error('Some tests failed, aborting')
            raise TestFailureError()

        # Commit to target repository
        if job.isCommitting():
            log.error('Job %d is already committing ' \
                '(probably to the wrong place)', jobId)
            raise JobFailedError(jobId=jobId, why='Job already committing')

        startTime = time.time()
        log.info('Starting commit of job %d', jobId)
        self._helper.getrMakeClient().startCommit([jobId])

        try:
            mapping = commit.commit(self._helper, job)
        except Exception, e_value:
            self._helper.getrMakeClient().commitFailed([jobId], str(e_value))
            raise
Exemple #7
0
    def _testMonitor(self, multinode):
        _check = self.checkMonitor

        def _checkLog(m, log):
            rc, txt = self.captureOutput(m._serveLoopHook)
            assert log == txt

        self.openRmakeRepository()
        repos = self.openRepository()
        client = self.startRmakeServer(multinode=multinode)
        if multinode:
            self.startNode()

        atrv = self.Component("a:source")[0]
        self.addComponent("a:runtime")
        btrv = self.Component("b:source")[0]
        ctrv = self.Component("c:source")[0]
        dtrv = self.Component("d:source")[0]
        etrv = self.Component("e:source")[0]

        port = testsuite.findPorts()[0]
        monitorUri = "http://*****:*****@rpl:linux/1.0-1[]{}\n",
                "[TIME] [1] - a:source - State: Buildable\n",
                "[TIME] [1] - c:source - State: Initialized",
            ],
        )
        logPath = self.workDir + "/abuildlog"
        alog = open(logPath, "w")
        alog.write("Log1\n")
        alog.flush()
        a.logPath = logPath
        a.troveBuilding()
        _check(m, "[TIME] [1] - a:source - State: Building\n" "Tailing a:source build log:\n\n")

        # check to make sure tailing the log works as expected
        _checkLog(m, "Log1\n")
        alog.write("Log2\n")
        alog.flush()
        _checkLog(m, "Log2\n")
        u = unichr(40960) + u"abcd" + unichr(1972) + "\n"
        alog.write(u.encode("utf-8"))
        alog.flush()
        _checkLog(m, "\xea\x80\x80abcd\xde\xb4\n")
        alog.write('\xe9")')
        alog.flush()
        _checkLog(m, '\xe9")')
        a.troveFailed(failure.BuildFailed("foo", "bar"))

        _check(
            m,
            [
                "[TIME] [1] - a:source - State: Failed\n"
                "[TIME] [1] - a:source - Failed while building: foo\n"
                "[TIME] [1] - c:source - State: Unbuildable\n"
                "[TIME] [1] - c:source - Could not satisfy dependencies:\n"
                "    c:source=/localhost@rpl:linux/1.0-1[] requires:\n"
                "	trove: a:runtime\n"
                "[TIME] [1] - d:source - State: Unbuildable\n"
                "[TIME] [1] - d:source - Could not satisfy build requirements: a:runtime=[]\n"
                "[TIME] [1] - e:source - State: Unbuildable\n"
                "[TIME] [1] - e:source - Could not satisfy build requirements: d:runtime=[]\n"
            ],
            events=1,
        )
        _check(m, "", 0.1)
Exemple #8
0
    def _testMonitor(self, multinode):
        _check = self.checkMonitor

        def _checkLog(m, log):
            rc, txt = self.captureOutput(m._serveLoopHook)
            assert(log == txt)

        self.openRmakeRepository()
        repos = self.openRepository()
        client = self.startRmakeServer(multinode=multinode)
        if multinode:
            self.startNode()

        atrv = self.Component('a:source')[0]
        self.addComponent('a:runtime')
        btrv = self.Component('b:source')[0]
        ctrv = self.Component('c:source')[0]
        dtrv = self.Component('d:source')[0]
        etrv = self.Component('e:source')[0]


        port = testsuite.findPorts()[0]
        monitorUri = 'http://*****:*****@rpl:linux/1.0-1[]{}\n',
                   '[TIME] [1] - a:source - State: Buildable\n',
                   '[TIME] [1] - c:source - State: Initialized',])
        logPath = self.workDir + '/abuildlog'
        alog = open(logPath, 'w')
        alog.write('Log1\n')
        alog.flush()
        a.logPath = logPath
        a.troveBuilding()
        _check(m, '[TIME] [1] - a:source - State: Building\n'
                  'Tailing a:source build log:\n\n')

        # check to make sure tailing the log works as expected
        _checkLog(m, 'Log1\n')
        alog.write('Log2\n')
        alog.flush()
        _checkLog(m, 'Log2\n')
        u = unichr(40960) + u'abcd' + unichr(1972) + '\n'
        alog.write(u.encode('utf-8'))
        alog.flush()
        _checkLog(m, '\xea\x80\x80abcd\xde\xb4\n')
        alog.write('\xe9")')
        alog.flush()
        _checkLog(m, '\xe9")')
        a.troveFailed(failure.BuildFailed('foo', 'bar'))
        
        _check(m,[
  '[TIME] [1] - a:source - State: Failed\n'
  '[TIME] [1] - a:source - Failed while building: foo\n'
  '[TIME] [1] - c:source - State: Unbuildable\n'
  '[TIME] [1] - c:source - Could not satisfy dependencies:\n'
  '    c:source=/localhost@rpl:linux/1.0-1[] requires:\n'
  '	trove: a:runtime\n'
  '[TIME] [1] - d:source - State: Unbuildable\n'
  '[TIME] [1] - d:source - Could not satisfy build requirements: a:runtime=[]\n'
  '[TIME] [1] - e:source - State: Unbuildable\n'
  '[TIME] [1] - e:source - Could not satisfy build requirements: d:runtime=[]\n'],
  events=1)
        _check(m, '', .1)