def testDummy(self):
        basedir = "test_slave_commands_base.dummy.dummy"
        b = FakeSlaveBuilder(False, basedir)
        c = DummyCommand(b, 1, {})
        c._reactor = task.Clock()
        d = c.doStart()
        def _check(ign):
            self.failUnless({'rc': 0} in b.updates, b.updates)
            self.failUnless({'stdout': 'data'} in b.updates, b.updates)
        d.addCallback(_check)

        # Advance by 2 seconds so that doStatus gets fired
        c._reactor.advance(2)
        # Now advance by 5 seconds so that finished gets fired
        c._reactor.advance(5)

        return d
    def testDummyInterrupt(self):
        basedir = "test_slave_commands_base.dummy.interrupt"
        b = FakeSlaveBuilder(False, basedir)
        c = DummyCommand(b, 1, {})
        c._reactor = task.Clock()
        d = c.doStart()
        def _check(ign):
            self.failUnlessEqual(c.interrupted, True)
            self.failUnless({'rc': 1} in b.updates, b.updates)
            self.failUnless({'stdout': 'data'} in b.updates, b.updates)
        d.addCallback(_check)

        # Advance by 2 seconds so that doStatus gets fired
        c._reactor.advance(2)
        # Now interrupt it
        c.interrupt()

        return d
Example #3
0
    def testDummy(self):
        basedir = "test_slave_commands_base.dummy.dummy"
        b = FakeSlaveBuilder(False, basedir)
        c = DummyCommand(b, 1, {})
        c._reactor = task.Clock()
        d = c.doStart()

        def _check(ign):
            self.failUnless({'rc': 0} in b.updates, b.updates)
            self.failUnless({'stdout': 'data'} in b.updates, b.updates)

        d.addCallback(_check)

        # Advance by 2 seconds so that doStatus gets fired
        c._reactor.advance(2)
        # Now advance by 5 seconds so that finished gets fired
        c._reactor.advance(5)

        return d
Example #4
0
    def testDummyInterrupt(self):
        basedir = "test_slave_commands_base.dummy.interrupt"
        b = FakeSlaveBuilder(False, basedir)
        c = DummyCommand(b, 1, {})
        c._reactor = task.Clock()
        d = c.doStart()

        def _check(ign):
            self.failUnlessEqual(c.interrupted, True)
            self.failUnless({'rc': 1} in b.updates, b.updates)
            self.failUnless({'stdout': 'data'} in b.updates, b.updates)

        d.addCallback(_check)

        # Advance by 2 seconds so that doStatus gets fired
        c._reactor.advance(2)
        # Now interrupt it
        c.interrupt()

        return d
    def testDummyInterruptTwice(self):
        basedir = "test_slave_commands_base.dummy.interruptTwice"
        b = FakeSlaveBuilder(False, basedir)
        c = DummyCommand(b, 1, {})
        c._reactor = task.Clock()
        d = c.doStart()
        def _check(ign):
            self.failUnlessEqual(c.interrupted, True)
            self.failUnless({'rc': 1} in b.updates, b.updates)
            self.failUnless({'stdout': 'data'} not in b.updates, b.updates)
        d.addCallback(_check)

        # Don't advance the clock to precent doStatus from being fired

        # Now interrupt it, twice!
        c.interrupt()
        c._reactor.advance(1)
        c.interrupt()

        return d
Example #6
0
    def testDummyInterruptTwice(self):
        basedir = "test_slave_commands_base.dummy.interruptTwice"
        b = FakeSlaveBuilder(False, basedir)
        c = DummyCommand(b, 1, {})
        c._reactor = task.Clock()
        d = c.doStart()

        def _check(ign):
            self.failUnlessEqual(c.interrupted, True)
            self.failUnless({'rc': 1} in b.updates, b.updates)
            self.failUnless({'stdout': 'data'} not in b.updates, b.updates)

        d.addCallback(_check)

        # Don't advance the clock to precent doStatus from being fired

        # Now interrupt it, twice!
        c.interrupt()
        c._reactor.advance(1)
        c.interrupt()

        return d