当前位置: 首页>>代码示例>>Python>>正文


Python WorkerLock.access方法代码示例

本文整理汇总了Python中buildbot.locks.WorkerLock.access方法的典型用法代码示例。如果您正苦于以下问题:Python WorkerLock.access方法的具体用法?Python WorkerLock.access怎么用?Python WorkerLock.access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在buildbot.locks.WorkerLock的用法示例。


在下文中一共展示了WorkerLock.access方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testStopBuildWaitingForStepLocks

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testStopBuildWaitingForStepLocks(self):
        b = self.build

        lock = WorkerLock('lock')
        lock_access = lock.access('counting')
        lock.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(lock) \
            .getLock(self.workerforbuilder.worker)

        step = LoggingBuildStep(locks=[lock_access])
        b.setStepFactories([FakeStepFactory(step)])

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

        gotLocks = [False]

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

        b.startBuild(FakeBuildStatus(), self.workerforbuilder)

        self.assertEqual(gotLocks, [True])
        self.assertEqual(b.results, CANCELLED)
开发者ID:s0undt3ch,项目名称:buildbot,代码行数:30,代码来源:test_process_build.py

示例2: testStopBuildWaitingForLocks

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testStopBuildWaitingForLocks(self):
        b = self.build

        lock = WorkerLock('lock')
        lock_access = lock.access('counting')
        lock.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(lock) \
            .getLock(self.workerforbuilder.worker)
        b.setLocks([lock_access])

        step = FakeBuildStep()
        step.alwaysRun = False
        b.setStepFactories([FakeStepFactory(step)])

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

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

        b.startBuild(FakeBuildStatus(), self.workerforbuilder)

        self.assertTrue(b.currentStep is None)
        self.assertEqual(b.results, CANCELLED)
开发者ID:s0undt3ch,项目名称:buildbot,代码行数:28,代码来源:test_process_build.py

示例3: testStopBuildWaitingForLocks_lostRemote

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testStopBuildWaitingForLocks_lostRemote(self):
        b = self.build

        lock = WorkerLock('lock')
        lock_access = lock.access('counting')
        lock.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(lock) \
            .getLock(self.workerforbuilder.worker)
        b.setLocks([lock_access])

        step = FakeBuildStep()
        step.alwaysRun = False
        b.setStepFactories([FakeStepFactory(step)])

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

        def acquireLocks(res=None):
            retval = Build.acquireLocks(b, res)
            b.lostRemote()
            return retval
        b.acquireLocks = acquireLocks

        b.startBuild(FakeBuildStatus(), self.workerforbuilder)

        self.assertTrue(b.currentStep is None)
        self.assertEqual(b.results, RETRY)
        self.build.build_status.setText.assert_called_with(
            ["retry", "lost", "connection"])
        self.build.build_status.setResults.assert_called_with(RETRY)
开发者ID:s0undt3ch,项目名称:buildbot,代码行数:31,代码来源:test_process_build.py

示例4: testBuildWaitingForLocks

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testBuildWaitingForLocks(self):
        b = self.build

        l = WorkerLock('lock')
        claimCount = [0]
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l) \
            .getLock(self.workerforbuilder.worker)

        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([lock_access])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([FakeStepFactory(step)])

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

        b.startBuild(FakeBuildStatus(), None, self.workerforbuilder)

        self.assert_(('startStep', (self.workerforbuilder.worker.conn,), {})
                     not in step.method_calls)
        self.assertEquals(claimCount[0], 1)
        self.assert_(b.currentStep is None)
        self.assert_(b._acquiringLock is not None)
开发者ID:CapdinGames,项目名称:katana,代码行数:33,代码来源:test_process_build.py

示例5: testBuildWaitingForLocks

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testBuildWaitingForLocks(self):
        b = self.build

        lock = WorkerLock('lock')
        claimCount = [0]
        lock_access = lock.access('counting')
        lock.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(lock) \
            .getLock(self.workerforbuilder.worker)

        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([lock_access])

        step = FakeBuildStep()
        b.setStepFactories([FakeStepFactory(step)])

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

        b.startBuild(FakeBuildStatus(), self.workerforbuilder)

        self.assertEqual(claimCount[0], 1)
        self.assertTrue(b.currentStep is None)
        self.assertTrue(b._acquiringLock is not None)
开发者ID:s0undt3ch,项目名称:buildbot,代码行数:29,代码来源:test_process_build.py

示例6: testStopBuildWaitingForLocks_lostRemote

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testStopBuildWaitingForLocks_lostRemote(self):
        b = self.build

        l = WorkerLock('lock')
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l) \
            .getLock(self.workerforbuilder.worker)
        b.setLocks([lock_access])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        step.alwaysRun = False
        b.setStepFactories([FakeStepFactory(step)])

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

        def acquireLocks(res=None):
            retval = Build.acquireLocks(b, res)
            b.lostRemote()
            return retval
        b.acquireLocks = acquireLocks

        b.startBuild(FakeBuildStatus(), None, self.workerforbuilder)

        self.assert_(('startStep', (self.workerforbuilder.worker.conn,), {})
                     not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.results, RETRY)
        self.assert_(('interrupt', ('stop it',), {}) not in step.method_calls)
        self.build.build_status.setText.assert_called_with(["retry", "lost", "connection"])
        self.build.build_status.setResults.assert_called_with(RETRY)
开发者ID:CapdinGames,项目名称:katana,代码行数:35,代码来源:test_process_build.py

示例7: testStopBuildWaitingForLocks

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testStopBuildWaitingForLocks(self):
        b = self.build

        l = WorkerLock('lock')
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l) \
            .getLock(self.workerforbuilder.worker)
        b.setLocks([lock_access])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        step.alwaysRun = False
        b.setStepFactories([FakeStepFactory(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(FakeBuildStatus(), self.workerforbuilder)

        self.assertNotIn(('startStep', (self.workerforbuilder.worker.conn,), {}),
                         step.method_calls)
        self.assertTrue(b.currentStep is None)
        self.assertEqual(b.results, CANCELLED)
        self.assertNotIn(('interrupt', ('stop it',), {}), step.method_calls)
开发者ID:GuoJianzhu,项目名称:buildbot,代码行数:33,代码来源:test_process_build.py

示例8: testBuildLocksAcquired

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testBuildLocksAcquired(self):
        b = self.build

        l = WorkerLock('lock')
        claimCount = [0]
        lock_access = l.access('counting')
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l) \
            .getLock(self.workerforbuilder.worker)

        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([lock_access])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        b.setStepFactories([FakeStepFactory(step)])

        b.startBuild(FakeBuildStatus(), self.workerforbuilder)

        self.assertEqual(b.results, SUCCESS)
        self.assertIn(('startStep', (self.workerforbuilder.worker.conn,), {}),
                      step.method_calls)
        self.assertEquals(claimCount[0], 1)
开发者ID:GuoJianzhu,项目名称:buildbot,代码行数:30,代码来源:test_process_build.py

示例9: testStopBuildWaitingForLocks

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testStopBuildWaitingForLocks(self):
        b = self.build

        l = WorkerLock("lock")
        lock_access = l.access("counting")
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(self.workerbuilder.worker)
        b.setLocks([lock_access])

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        step.alwaysRun = False
        b.setStepFactories([FakeStepFactory(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(FakeBuildStatus(), None, self.workerbuilder)

        self.assert_(("startStep", (self.workerbuilder.worker.conn,), {}) not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.results, CANCELLED)
        self.assert_(("interrupt", ("stop it",), {}) not in step.method_calls)
开发者ID:iskradelta,项目名称:buildbot,代码行数:32,代码来源:test_process_build.py

示例10: testBuildLocksOrder

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testBuildLocksOrder(self):
        """Test that locks are acquired in FIFO order; specifically that
        counting locks cannot jump ahead of exclusive locks"""
        eBuild = self.build

        cBuilder = FakeBuilder(self.master)
        cBuild = Build([self.request])
        cBuild.setBuilder(cBuilder)

        eWorker = Mock()
        cWorker = Mock()

        eWorker.worker = self.worker
        cWorker.worker = self.worker
        eWorker.prepare = cWorker.prepare = lambda _: True
        eWorker.ping = cWorker.ping = lambda: True

        l = WorkerLock("lock", 2)
        claimLog = []
        realLock = self.master.botmaster.getLockByID(l).getLock(self.worker)

        def claim(owner, access):
            claimLog.append(owner)
            return realLock.oldClaim(owner, access)

        realLock.oldClaim = realLock.claim
        realLock.claim = claim

        eBuild.setLocks([l.access("exclusive")])
        cBuild.setLocks([l.access("counting")])

        fakeBuild = Mock()
        fakeBuildAccess = l.access("counting")
        realLock.claim(fakeBuild, fakeBuildAccess)

        step = Mock()
        step.return_value = step
        step.startStep.return_value = SUCCESS
        eBuild.setStepFactories([FakeStepFactory(step)])
        cBuild.setStepFactories([FakeStepFactory(step)])

        e = eBuild.startBuild(FakeBuildStatus(), eWorker)
        c = cBuild.startBuild(FakeBuildStatus(), cWorker)
        d = defer.DeferredList([e, c])

        realLock.release(fakeBuild, fakeBuildAccess)

        def check(ign):
            self.assertEqual(eBuild.results, SUCCESS)
            self.assertEqual(cBuild.results, SUCCESS)
            self.assertEqual(claimLog, [fakeBuild, eBuild, cBuild])

        d.addCallback(check)
        return d
开发者ID:buildbot,项目名称:buildbot,代码行数:56,代码来源:test_process_build.py

示例11: testBuildcanStartWithWorkerForBuilder

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testBuildcanStartWithWorkerForBuilder(self):
        b = self.build

        workerforbuilder1 = Mock()
        workerforbuilder2 = Mock()

        l = WorkerLock('lock')
        counting_access = l.access('counting')
        real_lock = b.builder.botmaster.getLockByID(l)

        # no locks, so both these pass (call twice to verify there's no state/memory)
        lock_list = [(real_lock, counting_access)]
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder1))
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder1))
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder2))
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder2))

        worker_lock_1 = real_lock.getLock(workerforbuilder1.worker)
        worker_lock_2 = real_lock.getLock(workerforbuilder2.worker)

        # then have workerforbuilder2 claim its lock:
        worker_lock_2.claim(workerforbuilder2, counting_access)
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder1))
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder1))
        self.assertFalse(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder2))
        self.assertFalse(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder2))
        worker_lock_2.release(workerforbuilder2, counting_access)

        # then have workerforbuilder1 claim its lock:
        worker_lock_1.claim(workerforbuilder1, counting_access)
        self.assertFalse(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder1))
        self.assertFalse(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder1))
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder2))
        self.assertTrue(Build.canStartWithWorkerForBuilder(lock_list, workerforbuilder2))
        worker_lock_1.release(workerforbuilder1, counting_access)
开发者ID:CapdinGames,项目名称:katana,代码行数:37,代码来源:test_process_build.py

示例12: testBuildLocksAcquired

# 需要导入模块: from buildbot.locks import WorkerLock [as 别名]
# 或者: from buildbot.locks.WorkerLock import access [as 别名]
    def testBuildLocksAcquired(self):
        b = self.build

        lock = WorkerLock('lock')
        claimCount = [0]
        lock_access = lock.access('counting')
        lock.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(lock) \
            .getLock(self.workerforbuilder.worker)

        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([lock_access])

        step = FakeBuildStep()
        b.setStepFactories([FakeStepFactory(step)])

        b.startBuild(FakeBuildStatus(), self.workerforbuilder)

        self.assertEqual(b.results, SUCCESS)
        self.assertEqual(claimCount[0], 1)
开发者ID:s0undt3ch,项目名称:buildbot,代码行数:26,代码来源:test_process_build.py


注:本文中的buildbot.locks.WorkerLock.access方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。