def testStore(self): conf = Config() servicebot_conf = ServiceBotConfig() servicebot_conf.min_duration_seconds = 2 servicebot_conf.max_duration_seconds = 2 servicebot_conf.addServiceInfo( "Service", modulePath() + "/testservices/StoreService.py", 1, 1, 1) conf.addSection("SERVICE_BOT", servicebot_conf) conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") gamestate = GameStateServerInfo("localhost", 4242, "0123456789012345", "ABCDEFGH") conf.setGameStateServerInfo(gamestate) scheduler = ServiceTaskScheduler(conf, True) scheduler.execute(0) results = scheduler.execute(1) scheduler.terminateAtRoundEnd() for i in range(0, conf.numTeams()): for j in range(0, servicebot_conf.numServices()): self.assert_(results[i][j].store() == "Worked")
def testStore(self): conf = Config() servicebot_conf = ServiceBotConfig() servicebot_conf.min_duration_seconds = 2 servicebot_conf.max_duration_seconds = 2 servicebot_conf.addServiceInfo("Service", modulePath() + "/testservices/StoreService.py", 1, 1, 1) conf.addSection("SERVICE_BOT", servicebot_conf) conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") gamestate = GameStateServerInfo("localhost", 4242, "0123456789012345", "ABCDEFGH") conf.setGameStateServerInfo(gamestate) scheduler = ServiceTaskScheduler(conf, True) scheduler.execute(0) results = scheduler.execute(1) scheduler.terminateAtRoundEnd() for i in range(0, conf.numTeams()): for j in range(0, servicebot_conf.numServices()): self.assert_(results[i][j].store() == "Worked")
class TestServiceTaskScheduler(unittest.TestCase): def setUp(self): # Building a fake config timeout = 1 self.conf = Config() self.conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") self.conf.addTeamInfo("Team2", "127.0.1.1", "127.0.1.0/24") self.servicebot_conf = ServiceBotConfig() self.servicebot_conf.min_duration_seconds = 5 self.servicebot_conf.max_duration_seconds = 5 self.servicebot_conf.addServiceInfo("Service1", modulePath() + "/testservices/ErrorService.py", timeout, 1, 1) self.servicebot_conf.addServiceInfo("Service2", modulePath() + "/testservices/ErrorService.py", timeout, 1, 1) self.servicebot_conf.addServiceInfo("Service3", modulePath() + "/testservices/ErrorService.py", timeout, 1, 1) gamestate = GameStateServerInfo("localhost", 4242, "0123456789012345", "ABCDEFGH") self.conf.setGameStateServerInfo(gamestate) self.conf.addSection("SERVICE_BOT", self.servicebot_conf) def testSimpleSchedule(self): round = 0 scheduler = ServiceTaskScheduler(self.conf, True) start = time.time() results = scheduler.execute(round) scheduler.terminateAtRoundEnd() end = time.time() run_time = end - start self.assert_(4.0 < run_time and run_time < 6.0) for i in range(0, self.conf.numTeams()): for j in range(0, self.servicebot_conf.numServices()): self.assert_(results[i][j].status() == ServiceTask.ERROR) def testStore(self): conf = Config() servicebot_conf = ServiceBotConfig() servicebot_conf.min_duration_seconds = 2 servicebot_conf.max_duration_seconds = 2 servicebot_conf.addServiceInfo("Service", modulePath() + "/testservices/StoreService.py", 1, 1, 1) conf.addSection("SERVICE_BOT", servicebot_conf) conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") gamestate = GameStateServerInfo("localhost", 4242, "0123456789012345", "ABCDEFGH") conf.setGameStateServerInfo(gamestate) scheduler = ServiceTaskScheduler(conf, True) scheduler.execute(0) results = scheduler.execute(1) scheduler.terminateAtRoundEnd() for i in range(0, conf.numTeams()): for j in range(0, servicebot_conf.numServices()): self.assert_(results[i][j].store() == "Worked")
class TestServiceTaskScheduler(unittest.TestCase): def setUp(self): #Building a fake config timeout = 1 self.conf = Config() self.conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") self.conf.addTeamInfo("Team2", "127.0.1.1", "127.0.1.0/24") self.servicebot_conf = ServiceBotConfig() self.servicebot_conf.min_duration_seconds = 5 self.servicebot_conf.max_duration_seconds = 5 self.servicebot_conf.addServiceInfo( "Service1", modulePath() + "/testservices/ErrorService.py", timeout, 1, 1) self.servicebot_conf.addServiceInfo( "Service2", modulePath() + "/testservices/ErrorService.py", timeout, 1, 1) self.servicebot_conf.addServiceInfo( "Service3", modulePath() + "/testservices/ErrorService.py", timeout, 1, 1) gamestate = GameStateServerInfo("localhost", 4242, "0123456789012345", "ABCDEFGH") self.conf.setGameStateServerInfo(gamestate) self.conf.addSection("SERVICE_BOT", self.servicebot_conf) def testSimpleSchedule(self): round = 0 scheduler = ServiceTaskScheduler(self.conf, True) start = time.time() results = scheduler.execute(round) scheduler.terminateAtRoundEnd() end = time.time() run_time = end - start self.assert_(4.0 < run_time and run_time < 6.0) for i in range(0, self.conf.numTeams()): for j in range(0, self.servicebot_conf.numServices()): self.assert_(results[i][j].status() == ServiceTask.ERROR) def testStore(self): conf = Config() servicebot_conf = ServiceBotConfig() servicebot_conf.min_duration_seconds = 2 servicebot_conf.max_duration_seconds = 2 servicebot_conf.addServiceInfo( "Service", modulePath() + "/testservices/StoreService.py", 1, 1, 1) conf.addSection("SERVICE_BOT", servicebot_conf) conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") conf.addTeamInfo("Team1", "127.0.0.1", "127.0.0.0/24") gamestate = GameStateServerInfo("localhost", 4242, "0123456789012345", "ABCDEFGH") conf.setGameStateServerInfo(gamestate) scheduler = ServiceTaskScheduler(conf, True) scheduler.execute(0) results = scheduler.execute(1) scheduler.terminateAtRoundEnd() for i in range(0, conf.numTeams()): for j in range(0, servicebot_conf.numServices()): self.assert_(results[i][j].store() == "Worked")