예제 #1
0
    def testStopBuildWaitingForLocks(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())
        b.builder.botmaster = FakeMaster()
        slavebuilder = Mock()
        status = Mock()

        l = SlaveLock('lock')
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(slavebuilder)
        b.setLocks([l])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([(step, {})])

        real_lock.claim(Mock(), l.access('counting'))

        def acquireLocks(res=None):
            retval = Build.acquireLocks(b, res)
            b.stopBuild('stop it')
            return retval
        b.acquireLocks = acquireLocks

        b.startBuild(status, None, slavebuilder)

        self.assert_( ('startStep', (b.remote,), {}) not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.result, EXCEPTION)
        self.assert_( ('interrupt', ('stop it',), {}) not in step.method_calls)
예제 #2
0
    def testBuildLocksAcquired(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())
        b.builder.botmaster = FakeMaster()
        slavebuilder = Mock()
        status = Mock()

        l = SlaveLock('lock')
        claimCount = [0]
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(slavebuilder)

        def claim(owner, access):
            claimCount[0] += 1
            return real_lock.old_claim(owner, access)

        real_lock.old_claim = real_lock.claim
        real_lock.claim = claim
        b.setLocks([l])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([(step, {})])

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(b.result, SUCCESS)
        self.assert_(('startStep', (b.remote, ), {}) in step.method_calls)
        self.assertEquals(claimCount[0], 1)
예제 #3
0
 def testStepDoneWarnings(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(WARNINGS, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, WARNINGS)
예제 #4
0
 def testStepDoneFail(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #5
0
 def testStepDoneFailOverridesWarnings(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS, WARNINGS]
     b.result = WARNINGS
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #6
0
 def testStepDoneWarningsDontOverrideFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [FAILURE]
     b.result = FAILURE
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(WARNINGS, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #7
0
    def testBuildLocksAcquired(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())
        b.builder.botmaster = FakeMaster()
        slavebuilder = Mock()
        status = Mock()

        l = SlaveLock('lock')
        claimCount = [0]
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(slavebuilder)
        def claim(owner, access):
            claimCount[0] += 1
            return real_lock.old_claim(owner, access)
        real_lock.old_claim = real_lock.claim
        real_lock.claim = claim
        b.setLocks([l])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([(step, {})])

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(b.result, SUCCESS)
        self.assert_( ('startStep', (b.remote,), {}) in step.method_calls)
        self.assertEquals(claimCount[0], 1)
예제 #8
0
 def testStepDoneHaltOnFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = []
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     step.haltOnFailure = True
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, True)
     self.assertEqual(b.result, FAILURE)
예제 #9
0
 def testStepDoneWarnOnFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     step.warnOnFailure = True
     step.flunkOnFailure = False
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, WARNINGS)
예제 #10
0
 def testStepDoneHaltOnFailureFlunkOnWarnings(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     step.flunkOnWarnings = True
     self.haltOnFailure = True
     terminate = b.stepDone(WARNINGS, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #11
0
    def testStopBuild(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())

        step = Mock()
        step.return_value = step
        b.setStepFactories([(step, {})])

        slavebuilder = Mock()
        status = Mock()

        def startStep(*args, **kw):
            # Now interrupt the build
            b.stopBuild("stop it")
            return defer.Deferred()

        step.startStep = startStep

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(b.result, EXCEPTION)

        self.assert_(('interrupt', ('stop it', ), {}) in step.method_calls)
예제 #12
0
 def testStepDoneRetryOverridesAnythingElse(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [RETRY]
     b.result = RETRY
     b.remote = Mock()
     step = FakeBuildStep()
     step.alwaysRun = True
     b.stepDone(WARNINGS, step)
     b.stepDone(FAILURE, step)
     b.stepDone(SUCCESS, step)
     terminate = b.stepDone(EXCEPTION, step)
     self.assertEqual(terminate, True)
     self.assertEqual(b.result, RETRY)
예제 #13
0
def makeBuildStep(basedir, step_class=BuildStep, **kwargs):
    bss = setupBuildStepStatus(basedir)

    ss = SourceStamp()
    setup = {'name': "builder1", "slavename": "bot1",
             'builddir': "builddir", 'factory': None}
    b0 = Builder(setup, bss.getBuild().getBuilder())
    br = BuildRequest("reason", ss)
    b = Build([br])
    b.setBuilder(b0)
    s = step_class(**kwargs)
    s.setBuild(b)
    s.setStepStatus(bss)
    b.setupStatus(bss.getBuild())
    s.slaveVersion = fake_slaveVersion
    return s
예제 #14
0
 def testStepDoneRetryOverridesAnythingElse(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [RETRY]
     b.result = RETRY
     b.remote = Mock()
     step = FakeBuildStep()
     step.alwaysRun = True
     b.stepDone(WARNINGS, step)
     b.stepDone(FAILURE, step)
     b.stepDone(SUCCESS, step)
     terminate = b.stepDone(EXCEPTION, step)
     self.assertEqual(terminate, True)
     self.assertEqual(b.result, RETRY)
예제 #15
0
    def testStopBuild(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())

        step = Mock()
        step.return_value = step
        b.setStepFactories([(step, {})])

        slavebuilder = Mock()
        status = Mock()

        def startStep(*args, **kw):
            # Now interrupt the build
            b.stopBuild("stop it")
            return defer.Deferred()
        step.startStep = startStep

        b.startBuild(status, None, slavebuilder)

        self.assert_("Interrupted" in b.text)
        self.assertEqual(b.result, FAILURE)

        self.assert_( ('interrupt', ('stop it',), {}) in step.method_calls)
예제 #16
0
 def testStepDoneFlunkOnWarningsFlunkOnFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = []
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     step.flunkOnFailure = True
     step.flunkOnWarnings = True
     b.stepDone(WARNINGS, step)
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #17
0
 def testStepDoneWarnings(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(WARNINGS, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, WARNINGS)
예제 #18
0
 def testStepDoneFail(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #19
0
 def testStepDoneFailOverridesWarnings(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS, WARNINGS]
     b.result = WARNINGS
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #20
0
 def testStepDoneWarningsDontOverrideFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [FAILURE]
     b.result = FAILURE
     b.remote = Mock()
     step = FakeBuildStep()
     terminate = b.stepDone(WARNINGS, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, FAILURE)
예제 #21
0
    def testRunSuccessfulBuild(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([(step, {})])

        slavebuilder = Mock()
        status = Mock()

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(b.result, SUCCESS)
        self.assert_(('startStep', (b.remote, ), {}) in step.method_calls)
예제 #22
0
 def testStepDoneHaltOnFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = []
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     step.haltOnFailure = True
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, True)
     self.assertEqual(b.result, FAILURE)
예제 #23
0
    def testStopBuildWaitingForStepLocks(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())
        b.builder.botmaster = FakeMaster()
        slavebuilder = Mock()
        status = Mock()

        l = SlaveLock('lock')
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(slavebuilder)

        step = LoggingBuildStep(locks=[lock_access])

        def factory(*args):
            return step

        b.setStepFactories([(factory, {})])

        real_lock.claim(Mock(), l.access('counting'))

        gotLocks = [False]

        def acquireLocks(res=None):
            gotLocks[0] = True
            retval = LoggingBuildStep.acquireLocks(step, res)
            self.assert_(b.currentStep is step)
            b.stopBuild('stop it')
            return retval

        step.acquireLocks = acquireLocks
        step.setStepStatus = Mock()
        step.step_status = Mock()
        step.step_status.addLog().chunkSize = 10
        step.step_status.getLogs.return_value = []

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(gotLocks, [True])
        self.assert_(('stepStarted', (), {}) in step.step_status.method_calls)
        self.assertEqual(b.result, EXCEPTION)
예제 #24
0
 def testStepDoneWarnOnFailure(self):
     r = FakeRequest()
     b = Build([r])
     b.results = [SUCCESS]
     b.result = SUCCESS
     b.remote = Mock()
     step = FakeBuildStep()
     step.warnOnFailure = True
     step.flunkOnFailure = False
     terminate = b.stepDone(FAILURE, step)
     self.assertEqual(terminate, False)
     self.assertEqual(b.result, WARNINGS)
예제 #25
0
    def testRunSuccessfulBuild(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([(step, {})])

        slavebuilder = Mock()
        status = Mock()

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(b.result, SUCCESS)
        self.assert_( ('startStep', (b.remote,), {}) in step.method_calls)
예제 #26
0
    def testStopBuildWaitingForStepLocks(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())
        b.builder.botmaster = FakeMaster()
        slavebuilder = Mock()
        status = Mock()

        l = SlaveLock('lock')
        claimCount = [0]
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(slavebuilder)

        step = LoggingBuildStep(locks=[lock_access])
        def factory(*args):
            return step
        b.setStepFactories([(factory, {})])

        real_lock.claim(Mock(), l.access('counting'))

        gotLocks = [False]

        def acquireLocks(res=None):
            gotLocks[0] = True
            retval = LoggingBuildStep.acquireLocks(step, res)
            self.assert_(b.currentStep is step)
            b.stopBuild('stop it')
            return retval
        step.acquireLocks = acquireLocks
        step.setStepStatus = Mock()
        step.step_status = Mock()
        step.step_status.addLog().chunkSize = 10
        step.step_status.getLogs.return_value = []

        b.startBuild(status, None, slavebuilder)

        self.assertEqual(gotLocks, [True])
        self.assert_(('stepStarted', (), {}) in step.step_status.method_calls)
        self.assert_("Interrupted" in b.text, b.text)
        self.assertEqual(b.result, FAILURE)
예제 #27
0
def makeBuildStep(basedir, step_class=BuildStep, **kwargs):
    bss = setupBuildStepStatus(basedir)

    ss = SourceStamp()
    setup = {"name": "builder1", "slavename": "bot1", "builddir": "builddir", "factory": None}
    b0 = Builder(setup, bss.getBuild().getBuilder())
    b0.botmaster = FakeBotMaster()
    br = BuildRequest("reason", ss, "test_builder")
    b = Build([br])
    b.setBuilder(b0)
    s = step_class(**kwargs)
    s.setBuild(b)
    s.setStepStatus(bss)
    b.build_status = bss.getBuild()
    b.setupProperties()
    s.slaveVersion = fake_slaveVersion
    return s
예제 #28
0
def makeBuildStep(basedir, step_class=BuildStep, **kwargs):
    bss = setupBuildStepStatus(basedir)

    ss = SourceStamp()
    setup = {
        'name': "builder1",
        "slavename": "bot1",
        'builddir': "builddir",
        'factory': None
    }
    b0 = Builder(setup, bss.getBuild().getBuilder())
    b0.botmaster = FakeBotMaster()
    br = BuildRequest("reason", ss)
    b = Build([br])
    b.setBuilder(b0)
    s = step_class(**kwargs)
    s.setBuild(b)
    s.setStepStatus(bss)
    b.build_status = bss.getBuild()
    b.setupProperties()
    s.slaveVersion = fake_slaveVersion
    return s
예제 #29
0
파일: runutils.py 프로젝트: cmip/buildbot
def makeBuildStep(basedir, step_class=BuildStep, **kwargs):
    bss = setupBuildStepStatus(basedir)

    ss = SourceStamp()
    setup = {'name': "builder1", "slavename": "bot1",
             'builddir': "builddir", 'slavebuilddir': "slavebuilddir", 'factory': None}
    b0 = Builder(setup, bss.getBuild().getBuilder())
    b0.botmaster = FakeBotMaster()
    br = BuildRequest("reason", ss, 'test_builder')
    b = Build([br])
    b.setBuilder(b0)
    s = step_class(**kwargs)
    s.setBuild(b)
    s.setStepStatus(bss)
    b.build_status = bss.getBuild()
    b.setupProperties()
    s.slaveVersion = fake_slaveVersion
    s.step_status.setText(s.describe(False))
    return s
예제 #30
0
    def testStopBuildWaitingForLocks(self):
        r = FakeRequest()

        b = Build([r])
        b.setBuilder(Mock())
        b.builder.botmaster = FakeMaster()
        slavebuilder = Mock()
        status = Mock()

        l = SlaveLock('lock')
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(slavebuilder)
        b.setLocks([l])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([(step, {})])

        real_lock.claim(Mock(), l.access('counting'))

        def acquireLocks(res=None):
            retval = Build.acquireLocks(b, res)
            b.stopBuild('stop it')
            return retval

        b.acquireLocks = acquireLocks

        b.startBuild(status, None, slavebuilder)

        self.assert_(('startStep', (b.remote, ), {}) not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.result, EXCEPTION)
        self.assert_(('interrupt', ('stop it', ), {}) not in step.method_calls)
예제 #31
0
 def acquireLocks(res=None):
     retval = Build.acquireLocks(b, res)
     b.stopBuild('stop it')
     return retval
예제 #32
0
 def acquireLocks(res=None):
     retval = Build.acquireLocks(b, res)
     b.stopBuild('stop it')
     return retval