def test_attached_slaveInfoUpdates(self): # put in stale info: self.master.db.insertTestData([ fakedb.Buildslave(name='bot', info={ 'admin': 'WrongAdmin', 'host': 'WrongHost', 'access_uri': 'WrongURI', 'version': 'WrongVersion' }) ]) slave = self.createBuildslave() yield slave.startService() conn = fakeprotocol.FakeConnection(slave.master, slave) conn.info = { 'admin': 'TheAdmin', 'host': 'TheHost', 'access_uri': 'TheURI', 'version': 'TheVersion', } yield slave.attached(conn) self.assertEqual(slave.slave_status.getAdmin(), 'TheAdmin') self.assertEqual(slave.slave_status.getHost(), 'TheHost') self.assertEqual(slave.slave_status.getAccessURI(), 'TheURI') self.assertEqual(slave.slave_status.getVersion(), 'TheVersion') # and the db is updated too: buildslave = yield self.master.db.buildslaves.getBuildslave(name="bot") self.assertEqual(buildslave['slaveinfo']['admin'], 'TheAdmin') self.assertEqual(buildslave['slaveinfo']['host'], 'TheHost') self.assertEqual(buildslave['slaveinfo']['access_uri'], 'TheURI') self.assertEqual(buildslave['slaveinfo']['version'], 'TheVersion')
def test_attached_remoteGetSlaveInfo(self): slave = self.createBuildslave() yield slave.startService() ENVIRON = {} COMMANDS = {'cmd1': '1', 'cmd2': '1'} conn = fakeprotocol.FakeConnection(slave.master, slave) conn.info = { 'admin': 'TheAdmin', 'host': 'TheHost', 'access_uri': 'TheURI', 'environ': ENVIRON, 'basedir': 'TheBaseDir', 'system': 'TheSlaveSystem', 'version': 'version', 'slave_commands': COMMANDS, } yield slave.attached(conn) # check the values get set right self.assertEqual(slave.slave_status.getAdmin(), "TheAdmin") self.assertEqual(slave.slave_status.getHost(), "TheHost") self.assertEqual(slave.slave_status.getAccessURI(), "TheURI") self.assertEqual(slave.slave_environ, ENVIRON) self.assertEqual(slave.slave_basedir, 'TheBaseDir') self.assertEqual(slave.slave_system, 'TheSlaveSystem') self.assertEqual(slave.slave_commands, COMMANDS)
def test_attached_callRemote_getSlaveInfo(self): slave = self.createBuildslave() yield slave.startService() ENVIRON = {} bot = createRemoteBot() bot.response['getSlaveInfo'] = mock.Mock( return_value=defer.succeed({ 'admin': 'TheAdmin', 'host': 'TheHost', 'access_uri': 'TheURI', 'environ': ENVIRON, 'basedir': 'TheBaseDir', 'system': 'TheSlaveSystem' })) yield slave.attached(bot) # check that things were all good self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands)) # check the values get set right self.assertEqual(slave.slave_status.getAdmin(), "TheAdmin") self.assertEqual(slave.slave_status.getHost(), "TheHost") self.assertEqual(slave.slave_status.getAccessURI(), "TheURI") self.assertEqual(slave.slave_environ, ENVIRON) self.assertEqual(slave.slave_basedir, 'TheBaseDir') self.assertEqual(slave.slave_system, 'TheSlaveSystem')
def test_attached_slaveInfoUpdates(self): # put in stale info: self.master.db.insertTestData([ fakedb.Buildslave(name='bot', info={ 'admin': 'WrongAdmin', 'host': 'WrongHost', 'access_uri': 'WrongURI', 'version': 'WrongVersion' }) ]) slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() bot.response['getVersion'] = mock.Mock( return_value=defer.succeed("TheVersion")) bot.response['getSlaveInfo'] = mock.Mock(return_value=defer.succeed({ 'admin': 'TheAdmin', 'host': 'TheHost', 'access_uri': 'TheURI', })) yield slave.attached(bot) self.assertEqual(slave.slave_status.getAdmin(), 'TheAdmin') self.assertEqual(slave.slave_status.getHost(), 'TheHost') self.assertEqual(slave.slave_status.getAccessURI(), 'TheURI') self.assertEqual(slave.slave_status.getVersion(), 'TheVersion') # and the db is updated too: buildslave = yield self.master.db.buildslaves.getBuildslaveByName("bot") self.assertEqual(buildslave['slaveinfo']['admin'], 'TheAdmin') self.assertEqual(buildslave['slaveinfo']['host'], 'TheHost') self.assertEqual(buildslave['slaveinfo']['access_uri'], 'TheURI') self.assertEqual(buildslave['slaveinfo']['version'], 'TheVersion')
def test_attached_callRemote_getSlaveInfo(self): slave = self.createBuildslave() yield slave.startService() ENVIRON = {} bot = createRemoteBot() bot.response['getSlaveInfo'] = mock.Mock(return_value=defer.succeed({ 'admin': 'TheAdmin', 'host': 'TheHost', 'access_uri': 'TheURI', 'environ': ENVIRON, 'basedir': 'TheBaseDir', 'system': 'TheSlaveSystem' })) yield slave.attached(bot) # check that things were all good self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands)) # check the values get set right self.assertEqual(slave.slave_status.getAdmin(), "TheAdmin") self.assertEqual(slave.slave_status.getHost(), "TheHost") self.assertEqual(slave.slave_status.getAccessURI(), "TheURI") self.assertEqual(slave.slave_environ, ENVIRON) self.assertEqual(slave.slave_basedir, 'TheBaseDir') self.assertEqual(slave.slave_system, 'TheSlaveSystem')
def test_attached_callsMaybeStartBuildsForSlave(self): slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() yield slave.attached(bot) self.assertEqual(self.botmaster.buildsStartedForSlaves, ["bot"])
def test_attached_callsMaybeStartBuildsForSlave(self): slave = self.createBuildslave() yield slave.startService() conn = fakeprotocol.FakeConnection(slave.master, slave) conn.info = {} yield slave.attached(conn) self.assertEqual(self.botmaster.buildsStartedForSlaves, ["bot"])
def test_attached_callRemote_print_raises(self): slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() bot.response['print'] = mock.Mock( return_value=defer.fail(ValueError())) yield slave.attached(bot) # just check that things still go on self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands))
def test_attached_checkRemoteCalls(self): slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() yield slave.attached(bot) self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands)) self.assertEqual(bot.commands[0], ('print', 'attached')) self.assertEqual(bot.commands[1], ('getSlaveInfo', )) self.assertEqual(bot.commands[2], ('getVersion', )) self.assertEqual(bot.commands[3], ('getCommands', )) self.assertEqual(bot.commands[4], ('setBuilderList', []))
def test_attached_checkRemoteCalls(self): slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() yield slave.attached(bot) self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands)) self.assertEqual(bot.commands[0], ('print', 'attached')) self.assertEqual(bot.commands[1], ('getSlaveInfo',)) self.assertEqual(bot.commands[2], ('getVersion',)) self.assertEqual(bot.commands[3], ('getCommands',)) self.assertEqual(bot.commands[4], ('setBuilderList', []))
def test_attached_callRemote_getVersion(self): slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() bot.response['getVersion'] = mock.Mock( return_value=defer.succeed("TheVersion")) yield slave.attached(bot) # check that things were all good self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands)) # check the values get set right self.assertEqual(slave.slave_status.getVersion(), "TheVersion")
def test_attached_callRemote_getCommands(self): slave = self.createBuildslave() yield slave.startService() COMMANDS = ['a', 'b'] bot = createRemoteBot() bot.response['getCommands'] = mock.Mock( return_value=defer.succeed(COMMANDS)) yield slave.attached(bot) # check that things were all good self.assertEqual(True, slave.slave_status.isConnected()) self.assertEqual(5, len(bot.commands)) # check the values get set right self.assertEqual(slave.slave_commands, COMMANDS)
def test_attached_slaveInfoUpdates(self): # put in stale info: self.master.db.insertTestData([ fakedb.Buildslave(name='bot', info={ 'admin': 'WrongAdmin', 'host': 'WrongHost', 'access_uri': 'WrongURI', 'version': 'WrongVersion', 'key': 'value', }) ]) slave = self.createBuildslave() yield slave.startService() bot = createRemoteBot() bot.response['getVersion'] = mock.Mock( return_value=defer.succeed("TheVersion")) bot.response['getSlaveInfo'] = mock.Mock( return_value=defer.succeed({ 'admin': 'TheAdmin', 'host': 'TheHost', 'access_uri': 'TheURI', })) yield slave.attached(bot) self.assertEqual(slave.slave_status.getAdmin(), 'TheAdmin') self.assertEqual(slave.slave_status.getHost(), 'TheHost') self.assertEqual(slave.slave_status.getAccessURI(), 'TheURI') self.assertEqual(slave.slave_status.getVersion(), 'TheVersion') self.assertEqual(slave.slave_status.getInfo('key'), 'value') self.clock.pump( [0]) # we overrode the reactor, so gotta force the calls yield eventual.flushEventualQueue() # and the db is updated too: buildslave = yield self.master.db.buildslaves.getBuildslaveByName( "bot") self.assertEqual(buildslave['slaveinfo']['admin'], 'TheAdmin') self.assertEqual(buildslave['slaveinfo']['host'], 'TheHost') self.assertEqual(buildslave['slaveinfo']['access_uri'], 'TheURI') self.assertEqual(buildslave['slaveinfo']['version'], 'TheVersion')