def testStopBuildWaitingForLocks(self):
        b = self.build

        slavebuilder = 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
        step.alwaysRun = False
        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(FakeBuildStatus(), 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)
    def testStopBuildWaitingForStepLocks(self):
        b = self.build

        slavebuilder = 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])
        b.setStepFactories([FakeStepFactory(step)])

        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(FakeBuildStatus(), None, slavebuilder)

        self.assertEqual(gotLocks, [True])
        self.assert_(('stepStarted', (), {}) in step.step_status.method_calls)
        self.assertEqual(b.result, EXCEPTION)
    def testStopBuildWaitingForLocks(self):
        b = self.build

        l = SlaveLock("lock")
        lock_access = l.access("counting")
        l.access = lambda mode: lock_access
        real_lock = b.builder.botmaster.getLockByID(l).getLock(self.slavebuilder.slave)
        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.slavebuilder)

        self.assert_(("startStep", (self.slavebuilder.slave.conn,), {}) not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.result, CANCELLED)
        self.assert_(("interrupt", ("stop it",), {}) not in step.method_calls)
    def testBuildLocksAcquired(self):
        b = self.build

        slavebuilder = 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(FakeBuildStatus(), None, slavebuilder)

        self.assertEqual(b.result, SUCCESS)
        self.assert_( ('startStep', (slavebuilder.remote,), {})
                                in step.method_calls)
        self.assertEquals(claimCount[0], 1)
    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)
Exemple #6
0
    def test_locks_released_after_interrupt(self):
        l = SlaveLock('lock')
        lock_access = l.access('exclusive')
        l.access = lambda mode: lock_access

        class InterruptBuildStep(buildstep.BuildStep):
            def __init__(self,unit_test_obj,*args,**kw):
                self.unit_test_obj = unit_test_obj
                buildstep.BuildStep.__init__(self,*args,**kw)

            def start(self):
                self.interrupt("stop")

            def interrupt(self,arg):
                slavebuilder = self.build.slavebuilder.slave
                getLockByID = self.build.builder.botmaster.getLockByID
                real_lock = getLockByID(lock_access.lockid)
                l = real_lock.getLock(slavebuilder)
                self.unit_test_obj.assert_(not l.isAvailable(self,lock_access))
                buildstep.BuildStep.interrupt(self,arg)
                self.unit_test_obj.assert_(l.isAvailable(self,lock_access))
                buildstep.BuildStep.finished(self,EXCEPTION)
        step=InterruptBuildStep(self,locks=[l])
        self.setupStep(step)
        self.setupLockEnv()
        self.expectOutcome(result=EXCEPTION,
                           status_text=['generic','interrupted'])
        return self.runStep()
    def testStopBuildWaitingForStepLocks(self):
        b = self.build

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

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

        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

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

        self.assertEqual(gotLocks, [True])
        self.assertEqual(b.result, CANCELLED)
    def testBuildWaitingForLocks(self):
        b = self.build

        slavebuilder = 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.slave)

        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, slavebuilder)

        self.assert_(('startStep', (slavebuilder.remote,), {})
                     not in step.method_calls)
        self.assertEquals(claimCount[0], 1)
        self.assert_(b.currentStep is None)
        self.assert_(b._acquiringLock is not None)
    def testStopBuildWaitingForLocks_lostRemote(self):
        b = self.build

        slavebuilder = 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([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, slavebuilder)

        self.assert_(('startStep', (slavebuilder.remote,), {})
                     not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.result, RETRY)
        self.assert_(('interrupt', ('stop it',), {}) not in step.method_calls)
        self.build.build_status.setText.assert_called_with(["retry", "lost", "remote"])
        self.build.build_status.setResults.assert_called_with(RETRY)
Exemple #10
0
    def testBuildLocksAcquired(self):
        b = self.build

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

        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(), None, self.slavebuilder)

        self.assertEqual(b.result, SUCCESS)
        self.assertIn(("startStep", (self.slavebuilder.slave.conn,), {}), step.method_calls)
        self.assertEquals(claimCount[0], 1)
    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.assert_("Interrupted" in b.text, b.text)
        self.assertEqual(b.result, FAILURE)
        self.assert_( ('interrupt', ('stop it',), {}) not in step.method_calls)
Exemple #12
0
    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)

        eSlavebuilder = Mock()
        cSlavebuilder = Mock()

        eSlavebuilder.slave = self.slave
        cSlavebuilder.slave = self.slave

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

        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(), None, eSlavebuilder)
        c = cBuild.startBuild(FakeBuildStatus(), None, cSlavebuilder)
        d = defer.DeferredList([e, c])

        realLock.release(fakeBuild, fakeBuildAccess)

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

        d.addCallback(check)
        return d
    def testBuildcanStartWithSlavebuilder(self):
        b = self.build

        slavebuilder1 = Mock()
        slavebuilder2 = Mock()

        l = SlaveLock('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.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder2))

        slave_lock_1 = real_lock.getLock(slavebuilder1.slave)
        slave_lock_2 = real_lock.getLock(slavebuilder2.slave)

        # then have slavebuilder2 claim its lock:
        slave_lock_2.claim(slavebuilder2, counting_access)
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertFalse(Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        self.assertFalse(Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        slave_lock_2.release(slavebuilder2, counting_access)

        # then have slavebuilder1 claim its lock:
        slave_lock_1.claim(slavebuilder1, counting_access)
        self.assertFalse(Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertFalse(Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        self.assertTrue(Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        slave_lock_1.release(slavebuilder1, counting_access)
Exemple #14
0
    def test_locks_released_after_success(self):
        l = SlaveLock('lock')
        lock_access = l.access('exclusive')

        class FakeBuildStepCheckLock(buildstep.BuildStep):
            def __init__(self,unit_test_obj,*args,**kw):
                self.unit_test_obj = unit_test_obj
                buildstep.BuildStep.__init__(self,*args,**kw)

            def start(self):
                return self.finished(SUCCESS)

            def finished(self,res):
                slavebuilder = self.build.slavebuilder.slave
                getLockByID=self.build.builder.botmaster.getLockByID
                real_lock = getLockByID(lock_access.lockid)
                l = real_lock.getLock(slavebuilder)
                self.unit_test_obj.assert_(not l.isAvailable(self,lock_access))
                buildstep.BuildStep.finished(self,res)
                self.unit_test_obj.assert_(l.isAvailable(self,lock_access))

        step=FakeBuildStepCheckLock(self,locks=[lock_access])
        self.setupStep(step)
        self.setupLockEnv()
        self.expectOutcome(result=SUCCESS,
                           status_text=['generic'])
        return self.runStep()
    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)
Exemple #16
0
    def testStopBuildWaitingForStepLocks(self):
        b = self.build

        slavebuilder = 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(FakeBuildStatus(), None, slavebuilder)

        self.assertEqual(gotLocks, [True])
        self.assert_(('stepStarted', (), {}) in step.step_status.method_calls)
        self.assertEqual(b.result, EXCEPTION)
    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
        step.alwaysRun = False
        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)
    def testBuildWaitingForLocks(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, {})])

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

        b.startBuild(status, None, slavebuilder)

        self.assert_(('startStep', (b.remote, ), {}) not in step.method_calls)
        self.assertEquals(claimCount[0], 1)
        self.assert_(b.currentStep is None)
        self.assert_(b._acquiringLock is not None)
Exemple #19
0
    def testStopBuildWaitingForLocks_lostRemote(self):
        b = self.build

        slavebuilder = 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([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, slavebuilder)

        self.assert_(('startStep', (slavebuilder.remote, ),
                      {}) not in step.method_calls)
        self.assert_(b.currentStep is None)
        self.assertEqual(b.result, RETRY)
        self.assert_(('interrupt', ('stop it', ), {}) not in step.method_calls)
        self.build.build_status.setText.assert_called_with(
            ["retry", "lost", "remote"])
        self.build.build_status.setResults.assert_called_with(RETRY)
Exemple #20
0
    def testBuildcanStartWithSlavebuilder(self):
        b = self.build

        slavebuilder1 = Mock()
        slavebuilder2 = Mock()

        l = SlaveLock('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.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder2))

        slave_lock_1 = real_lock.getLock(slavebuilder1.slave)
        slave_lock_2 = real_lock.getLock(slavebuilder2.slave)

        # then have slavebuilder2 claim its lock:
        slave_lock_2.claim(slavebuilder2, counting_access)
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertFalse(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        self.assertFalse(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        slave_lock_2.release(slavebuilder2, counting_access)

        # then have slavebuilder1 claim its lock:
        slave_lock_1.claim(slavebuilder1, counting_access)
        self.assertFalse(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertFalse(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder1))
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        self.assertTrue(
            Build.canStartWithSlavebuilder(lock_list, slavebuilder2))
        slave_lock_1.release(slavebuilder1, counting_access)
Exemple #21
0
    def test_release_build_Lock_step(self):
        b = self.build
        slavebuilder = Mock()

        l = SlaveLock("slave_builds", maxCount=1)

        step = artifact.AcquireBuildLocks(locks=[l.access('exclusive')])
        step2 = artifact.ReleaseBuildLocks()
        b.setStepFactories([FakeStepFactory(step), FakeStepFactory(step2)])
        self.assertEqual(len(b.locks), 0)

        b.startBuild(self.build_status, None, slavebuilder)
        b.currentStep.start()
        self.assertTrue(b.locks[0][0].owners[0][0], step)

        b.currentStep.start()
        self.assertEqual(len(b.locks[0][0].owners), 0)
Exemple #22
0
    def __init__(self, Environ):
        # Max number of running builds
        build_lock = SlaveLock('build',
                               maxCount=1,
                               maxCountForSlave={
                                   'farmer-slave1': 1,
                               })

        # All repo
        all_repos = {
            'quantum_espresso': {
                'repository': 'https://gitlab.com/QEF/q-e.git',
                'branch': 'develop',
            },
            'sternheimer_gw': {
                'repository':
                'https://github.com/mmdg-oxford/SternheimerGW.git',
                'branch': 'develop',
            },
            'wannier90': {
                'repository':
                'https://github.com/wannier-developers/wannier90.git',
                'branch': 'develop',
            },
        }

        ############################################################################
        # QE code
        ############################################################################

        self.checkout_qe = [
            steps.Git(
                name="checkout_qe",
                method="copy",
                repourl=all_repos["quantum_espresso"]["repository"],
                branch=all_repos["quantum_espresso"]["branch"],
                haltOnFailure=True,
                alwaysUseLatest=True,
            )
        ]

        self.configure_qe = [
            ShellCommand(name="configure_qe",
                         command=["./configure"],
                         env=Environ,
                         workdir="build",
                         locks=[build_lock.access('counting')],
                         haltOnFailure=True,
                         descriptionDone=["configure_qe"])
        ]

        self.dep_qe = [
            ShellCommand(
                name="dep_qe",
                #command=["make","depend"],
                # DBSP: Temporary until QE 6.2 is release
                command=["ls"],
                env=Environ,
                workdir="build",
                locks=[build_lock.access('counting')],
                haltOnFailure=True,
                descriptionDone=["dep_qe"])
        ]

        self.make_pw = [
            ShellCommand(name="make_pw",
                         command=["make", "pwall", "cp", "ld1", "upf"],
                         env=Environ,
                         workdir="build",
                         haltOnFailure=True,
                         descriptionDone=["make_pw"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_ph = [
            ShellCommand(name="make_ph",
                         command=["make", "ph"],
                         env=Environ,
                         workdir="build",
                         haltOnFailure=True,
                         descriptionDone=["make_ph"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_epw0 = [
            ShellCommand(name="make_epw0",
                         command=["make"],
                         env=Environ,
                         workdir="build/EPW/src/",
                         haltOnFailure=True,
                         descriptionDone=["make_epw"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_epw = [
            ShellCommand(name="make_epw",
                         command=["make", "epw"],
                         env=Environ,
                         workdir="build",
                         haltOnFailure=True,
                         descriptionDone=["make_epw"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_lr = [
            ShellCommand(
                name="make_lr",
                command=["make", "-j", "8", "lrmods"],
                env=Environ,
                workdir="build",
                haltOnFailure=True,
                descriptionDone=["make_lr"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_clean = [
            ShellCommand(
                name="test_clean",
                command=["make", "clean"],
                env=Environ,
                workdir="build/test-suite",
                descriptionDone=["test_clean"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.clean = [
            ShellCommand(command=["make", "veryclean"],
                         alwaysRun=True,
                         flunkOnFailure=False,
                         workdir="build")
        ]

        self.test0 = [
            ShellCommand(name="test_prolog",
                         command=["make", "prolog"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["make prolog"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_PW = [
            ShellCommand(name="PW_para",
                         command=["make", "run-tests-pw-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PW para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_PW = [
            ShellCommand(name="PW_serial",
                         command=["make", "run-tests-pw-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PW serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_CP = [
            ShellCommand(name="CP_para",
                         command=["make", "run-tests-cp-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["CP para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_CP = [
            ShellCommand(name="CP_serial",
                         command=["make", "run-tests-cp-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["CP serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_PH = [
            ShellCommand(name="PH_para",
                         command=["make", "run-tests-ph-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PH para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_PH = [
            ShellCommand(name="PH_serial",
                         command=["make", "run-tests-ph-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PH serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_EPW = [
            ShellCommand(name="EPW_para",
                         command=["make", "run-tests-epw-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["EPW para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_EPW = [
            ShellCommand(name="EPW_serial",
                         command=["make", "run-tests-epw-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["EPW serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        ############################################################################
        # SGW code
        ############################################################################
        self.configure_qe2 = [
            ShellCommand(name="configure_qe",
                         command=["./configure"],
                         env=Environ,
                         workdir="build",
                         locks=[build_lock.access('counting')],
                         haltOnFailure=True,
                         descriptionDone=["configure_qe"])
        ]

        self.make_pw2 = [
            ShellCommand(name="make_pw",
                         command=["make", "pw", "lrmods"],
                         env=Environ,
                         workdir="build",
                         haltOnFailure=True,
                         descriptionDone=["make_pw"],
                         locks=[build_lock.access('counting')])
        ]

        self.checkout_sgw = [
            steps.Git(
                name="checkout_sgw",
                repourl=all_repos["sternheimer_gw"]["repository"],
                branch=all_repos["sternheimer_gw"]["branch"],
                workdir="build/SGW",
                haltOnFailure=True,
                alwaysUseLatest=True,
            )
        ]

        self.make_sgw = [
            ShellCommand(
                name="make_sgw",
                command=["make"],
                env=Environ,
                workdir="build/SGW",
                haltOnFailure=True,
                descriptionDone=["make_sgw"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_sgw = [
            ShellCommand(
                name="test_sgw",
                command=["make", "run-tests"],
                env=Environ,
                workdir="build/SGW/test-suite",
                haltOnFailure=True,
                descriptionDone=["test_sgw"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_clean_sgw = [
            ShellCommand(
                name="test_clean",
                command=["make", "clean"],
                env=Environ,
                workdir="build/SGW/test-suite",
                descriptionDone=["test_clean"],
                locks=[build_lock.access('counting')],
            )
        ]

        ############################################################################
        # Wannier code
        ############################################################################

        self.checkout_wannier = [
            steps.Git(
                name="checkout_wannier",
                method="copy",
                workdir="build/WAN",
                repourl=all_repos["wannier90"]["repository"],
                branch=all_repos["wannier90"]["branch"],
                haltOnFailure=True,
                alwaysUseLatest=True,
            )
        ]

        self.cpconfig = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp", "test-suite/config/EPW_testfarm/farmer_gcc485.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.clean_wannier = [
            ShellCommand(
                name="clean_wannier",
                command=["python", "clean_tests"],
                env=Environ,
                workdir="build/WAN/test-suite",
                haltOnFailure=True,
                descriptionDone=["clean_wannier"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.make_wannier = [
            ShellCommand(
                name="make_wannier",
                command=["make"],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["make_wannier"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.make_wannier2 = [
            ShellCommand(
                name="make_wannier2",
                command=["make", "default", "w90chk2chk"],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["make_wannier2"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_wannier_serial = [
            ShellCommand(
                name="test_wannier_seq",
                command=["./run_tests", "--category=default"],
                env=Environ,
                workdir="build/WAN/test-suite",
                haltOnFailure=True,
                descriptionDone=["test_wannier_seq"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_wannier_para = [
            ShellCommand(
                name="test_wannier_para",
                command=["./run_tests", "--category=default", "--numprocs=4"],
                env=Environ,
                workdir="build/WAN/test-suite",
                haltOnFailure=True,
                descriptionDone=["test_wannier_para"],
                locks=[build_lock.access('counting')],
            )
        ]
    def __init__(self, Environ):
        # Max number of running builds
        build_lock = SlaveLock('build',
                               maxCount=2,
                               maxCountForSlave={
                                   'farmer-slave1': 2,
                               })

        # All repo
        all_repos = {
            'quantum_espresso': {
                'repository': 'https://gitlab.com/QEF/q-e.git',
                'branch': 'develop',
            },
            #        'sternheimer_gw': {
            #            'repository': 'https://github.com/mmdg-oxford/SternheimerGW.git',
            #            'branch': 'develop',
            #        },
            'wannier90': {
                'repository':
                'https://github.com/wannier-developers/wannier90.git',
                #            'repository': 'https://github.com/sponce24/wannier90.git',
                'branch': 'develop',
            },
        }

        ############################################################################
        # QE code
        ############################################################################

        self.checkout_qe = [
            steps.Git(
                name="checkout_qe",
                method="copy",
                repourl=all_repos["quantum_espresso"]["repository"],
                branch=all_repos["quantum_espresso"]["branch"],
                haltOnFailure=True,
                alwaysUseLatest=True,
            )
        ]

        self.configure_qe = [
            ShellCommand(name="configure_qe",
                         command=["./configure"],
                         env=Environ,
                         workdir="build",
                         locks=[build_lock.access('counting')],
                         haltOnFailure=True,
                         descriptionDone=["configure_qe"])
        ]

        self.configure_qe_mp = [
            ShellCommand(name="configure_qe",
                         command=[
                             "./configure", "--enable-openmp",
                             "--enable-parallel"
                         ],
                         env=Environ,
                         workdir="build",
                         locks=[build_lock.access('counting')],
                         haltOnFailure=True,
                         descriptionDone=["configure_qe_mp"])
        ]

        self.dep_qe = [
            ShellCommand(
                name="dep_qe",
                #command=["make","depend"],
                # DBSP: Temporary until QE 6.2 is release
                command=["ls"],
                env=Environ,
                workdir="build",
                locks=[build_lock.access('counting')],
                haltOnFailure=True,
                descriptionDone=["dep_qe"])
        ]

        self.env_qe1 = [
            ShellCommand(
                name="env_qe1",
                command=Interpolate(
                    'sed -i "s/TESTCODE_NPROCS=4/TESTCODE_NPROCS=2/g" ENVIRONMENT'
                ),
                env=Environ,
                workdir="build/test-suite/",
                locks=[build_lock.access('counting')],
                haltOnFailure=True,
                descriptionDone=["env_qe1"])
        ]

        self.env_qe2 = [
            ShellCommand(
                name="env_qe2",
                command=Interpolate(
                    'echo "export OMP_NUM_THREADS=2" >> ENVIRONMENT'),
                #command=["cat","'export OMP_NUM_THREADS=2'",">>", "ENVIRONMENT"],
                env=Environ,
                workdir="build/test-suite/",
                locks=[build_lock.access('counting')],
                haltOnFailure=True,
                descriptionDone=["env_qe2"])
        ]

        self.make_pw = [
            ShellCommand(
                name="make_pw",
                command=["make", "-j", "4", "pwall", "cp", "ld1", "upf"],
                env=Environ,
                workdir="build",
                haltOnFailure=True,
                descriptionDone=["make_pw"],
                locks=[build_lock.access('counting')])
        ]

        self.make_ph = [
            ShellCommand(name="make_ph",
                         command=["make", "ph"],
                         env=Environ,
                         workdir="build",
                         haltOnFailure=True,
                         descriptionDone=["make_ph"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_epw0 = [
            ShellCommand(name="make_epw0",
                         command=["make"],
                         env=Environ,
                         workdir="build/EPW/src/",
                         haltOnFailure=True,
                         descriptionDone=["make_epw"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_epw = [
            ShellCommand(name="make_epw",
                         command=["make", "epw"],
                         env=Environ,
                         workdir="build",
                         haltOnFailure=True,
                         descriptionDone=["make_epw"],
                         locks=[build_lock.access('counting')])
        ]

        self.make_lr = [
            ShellCommand(
                name="make_lr",
                command=["make", "-j", "8", "lrmods"],
                env=Environ,
                workdir="build",
                haltOnFailure=True,
                descriptionDone=["make_lr"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_clean = [
            ShellCommand(
                name="test_clean",
                command=["make", "clean"],
                env=Environ,
                workdir="build/test-suite",
                descriptionDone=["test_clean"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.clean = [
            ShellCommand(command=["make", "veryclean"],
                         alwaysRun=True,
                         flunkOnFailure=False,
                         workdir="build")
        ]

        self.test0 = [
            ShellCommand(name="test_prolog",
                         command=["make", "prolog"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["make prolog"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_PW = [
            ShellCommand(name="PW_para",
                         command=["make", "run-tests-pw-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PW para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_PW = [
            ShellCommand(name="PW_serial",
                         command=["make", "run-tests-pw-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PW serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_CP = [
            ShellCommand(name="CP_para",
                         command=["make", "run-tests-cp-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["CP para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_CP = [
            ShellCommand(name="CP_serial",
                         command=["make", "run-tests-cp-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["CP serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_PH = [
            ShellCommand(name="PH_para",
                         command=["make", "run-tests-ph-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PH para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_PH = [
            ShellCommand(name="PH_serial",
                         command=["make", "run-tests-ph-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["PH serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        self.test_para_EPW = [
            ShellCommand(name="EPW_para",
                         command=["make", "run-tests-epw-parallel"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["EPW para tests"],
                         locks=[build_lock.access('counting')])
        ]
        self.test_serial_EPW = [
            ShellCommand(name="EPW_serial",
                         command=["make", "run-tests-epw-serial"],
                         env=Environ,
                         workdir="build/test-suite",
                         haltOnFailure=False,
                         descriptionDone=["EPW serial tests"],
                         locks=[build_lock.access('counting')])
        ]

        ############################################################################
        # SGW code
        ############################################################################
        #    self.configure_qe2 = [ShellCommand(
        #                   name="configure_qe",
        #                   command=["./configure"],
        #                   env=Environ,
        #                   workdir="build",
        #                   locks=[build_lock.access('counting')],
        #                   haltOnFailure = True,descriptionDone=["configure_qe"]
        #               )]
        #
        #    self.make_pw2   = [ShellCommand(
        #                   name="make_pw",
        #                   command=["make","pw","lrmods"],
        #                   env=Environ,
        #                   workdir="build",
        #                   haltOnFailure=True, descriptionDone=["make_pw"],
        #                   locks=[build_lock.access('counting')]
        #                )]
        #
        #    self.checkout_sgw = [steps.Git(
        #                   name="checkout_sgw",
        #                   repourl=all_repos["sternheimer_gw"]["repository"],
        #                   branch=all_repos["sternheimer_gw"]["branch"],
        #                   workdir="build/SGW",
        #                   haltOnFailure = True,
        #                   alwaysUseLatest = True,
        #                )]
        #
        #    self.make_clean = [ShellCommand(
        #                  name="make_clean",
        #                  command=["make", "clean"],
        #                  env=Environ,
        #                  workdir="build/SGW",
        #                  haltOnFailure = True,
        #                  descriptionDone = ["make_clean"],
        #                  locks=[build_lock.access('counting')],
        #                )]
        #
        #    self.make_sgw   = [ShellCommand(
        #                  name="make_sgw",
        #                  command=["make"],
        #                  env=Environ,
        #                  workdir="build/SGW",
        #                  haltOnFailure = True,
        #                  descriptionDone = ["make_sgw"],
        #                  locks=[build_lock.access('counting')],
        #                )]
        #
        #    self.test_sgw   = [ShellCommand(
        #                  name="test_sgw",
        #                  command=["make", "run-tests"],
        #                  env=Environ,
        #                  workdir="build/SGW/test-suite",
        #                  haltOnFailure = True,
        #                  descriptionDone = ["test_sgw"],
        #                  locks=[build_lock.access('counting')],
        #                )]
        #
        #    self.test_clean_sgw = [ShellCommand(
        #                  name="test_clean",
        #                  command=["make", "clean"],
        #                  env=Environ,
        #                  workdir="build/SGW/test-suite",
        #                  descriptionDone = ["test_clean"],
        #                  locks=[build_lock.access('counting')],
        #                )]

        ############################################################################
        # Wannier code
        ############################################################################

        self.checkout_wannier = [
            steps.Git(
                name="checkout_wannier",
                method="copy",
                workdir="build/WAN",
                repourl=all_repos["wannier90"]["repository"],
                branch=all_repos["wannier90"]["branch"],
                haltOnFailure=True,
                alwaysUseLatest=True,
            )
        ]

        self.cpconfig = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp",
                    "test-suite/config/TestFarm/farmer_gcc640_serial.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.cpgcc730 = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp",
                    "test-suite/config/TestFarm/farmer_gcc730_openmpi1107.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.cpintel17 = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp",
                    "test-suite/config/TestFarm/farmer_intel17_openmpi313.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.cpintel17i = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp", "test-suite/config/TestFarm/farmer_intel17_impi.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.cpintel18 = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp",
                    "test-suite/config/TestFarm/farmer_intel18_openmpi313.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.cppgi18 = [
            ShellCommand(
                name="cp_config",
                command=[
                    "cp",
                    "test-suite/config/TestFarm/farmer_pgi18_mvapich23b.inc",
                    "make.inc"
                ],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["cp_config"],
                locks=[build_lock.access('counting')])
        ]

        self.clean_wannier = [
            ShellCommand(
                name="clean_wannier",
                command=["make", "clean"],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["clean_wannier"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.clean_tests = [
            ShellCommand(
                name="clean_tests",
                command=["python", "clean_tests"],
                env=Environ,
                workdir="build/WAN/test-suite",
                haltOnFailure=True,
                descriptionDone=["clean_tests"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.make_wannier = [
            ShellCommand(
                name="make_wannier",
                command=["make"],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["make_wannier"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.make_wannier2 = [
            ShellCommand(
                name="make_wannier2",
                command=["make", "default", "w90chk2chk"],
                env=Environ,
                workdir="build/WAN",
                haltOnFailure=True,
                descriptionDone=["make_wannier2"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_wannier_serial = [
            ShellCommand(
                name="test_wannier_seq",
                command=["./run_tests", "--category=default"],
                env=Environ,
                workdir="build/WAN/test-suite",
                haltOnFailure=True,
                descriptionDone=["test_wannier_seq"],
                locks=[build_lock.access('counting')],
            )
        ]

        self.test_wannier_para = [
            ShellCommand(
                name="test_wannier_para",
                command=["./run_tests", "--category=default", "--numprocs=4"],
                env=Environ,
                workdir="build/WAN/test-suite",
                haltOnFailure=True,
                descriptionDone=["test_wannier_para"],
                locks=[build_lock.access('counting')],
            )
        ]