def testCorrectScript(self): self.__ensureValidGoodService() path = os.path.join(modulePath(),'testservices','GoodService.py') good = ServiceTask(path,1,"NewFlag","0.0.0.0",None) good.start() self.assert_(good.status() == ServiceTask.OK) self.assert_(good.getPrevFlag() == "TestFlag")
def testSimpleInsert(self): test = ServiceTaskRunner() test.start() script = modulePath()+"/testservices/HangService.py" task = ServiceTask(script,2,"Flag","10.0.0.1",None) test.insert(task,-1,-1) test.terminateOnEmpty() self.assert_(task.status() == ServiceTask.KILLED)
def testSimpleInsert(self): test = ServiceTaskRunner() test.start() script = modulePath() + "/testservices/HangService.py" task = ServiceTask(script, 2, "Flag", "10.0.0.1", None) test.insert(task, -1, -1) test.terminateOnEmpty() self.assert_(task.status() == ServiceTask.KILLED)
def testErrorInsert(self): test = ServiceTaskRunner() test.start() script = modulePath()+"/testservices/ErrorService.py" tasks = [] for i in range(0,10): task = ServiceTask(script,1,"Flag","10.0.0.1",None) tasks.append(task) test.insert(task,-1,-1) test.terminateOnEmpty() for task in tasks: self.assert_(task.status() == ServiceTask.ERROR)
def testErrorInsert(self): test = ServiceTaskRunner() test.start() script = modulePath() + "/testservices/ErrorService.py" tasks = [] for i in range(0, 10): task = ServiceTask(script, 1, "Flag", "10.0.0.1", None) tasks.append(task) test.insert(task, -1, -1) test.terminateOnEmpty() for task in tasks: self.assert_(task.status() == ServiceTask.ERROR)
def testCorrectScript(self): self.__ensureValidGoodService() path = os.path.join(modulePath(), 'testservices', 'GoodService.py') good = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None) good.start() self.assert_(good.status() == ServiceTask.OK) self.assert_(good.getPrevFlag() == "TestFlag")
def build(self,teamId,serviceId,round): team = self.conf.getTeamInfoById(teamId) service = self.servicebot_conf.getServiceInfoById(serviceId) flag = Flag(teamId,serviceId,round,time.time()) task = ServiceTask( service.script, service.timeout, self.flag_manager.toTxt(flag), team.host, self.storage[teamId][serviceId], self.service_loggers[service.name]) return task
def testPastTimeout(self): path = os.path.join(modulePath(),'testservices','GoodService.py') good = ServiceTask(path,1,"NewFlag","0.0.0.0",None) good.start() time.sleep(2) self.assert_(good.status() == ServiceTask.OK)
def testPastTimeout(self): path = os.path.join(modulePath(), 'testservices', 'GoodService.py') good = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None) good.start() time.sleep(2) self.assert_(good.status() == ServiceTask.OK)
def testStoreScript(self): path = os.path.join(modulePath(), 'testservices', 'StoreService.py') store = ServiceTask(path, 0.5, "NewFlag", "0.0.0.0", None) store.start() self.assert_(store.status() == ServiceTask.INVALID_FLAG) self.assert_(store.store() == "Store Text")
def testHangScript(self): path = os.path.join(modulePath(), 'testservices', 'HangService.py') hang = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None) hang.start() self.assert_(hang.status() == ServiceTask.KILLED)
def testErrorScript(self): path = os.path.join(modulePath(), 'testservices', 'ErrorService.py') err = ServiceTask(path, 1, "NewFlag", "0.0.0.0", None) err.start() self.assert_(err.status() == ServiceTask.ERROR) self.assert_(err.error() == "An Error")
def testBrokenScript(self): path = os.path.join(modulePath(), 'testservices', 'BrokenService.py') err = ServiceTask(path, 2, "NewFlag", "0.0.0.0", None) err.start() self.assert_(err.status() == ServiceTask.INVALID_FLAG)
def testStoreScript(self): path = os.path.join(modulePath(),'testservices','StoreService.py') store = ServiceTask(path,0.5,"NewFlag","0.0.0.0",None) store.start() self.assert_(store.status() == ServiceTask.INVALID_FLAG) self.assert_(store.store() == "Store Text")
def testHangScript(self): path = os.path.join(modulePath(),'testservices','HangService.py') hang = ServiceTask(path,1,"NewFlag","0.0.0.0",None) hang.start() self.assert_(hang.status() == ServiceTask.KILLED)
def testErrorScript(self): path = os.path.join(modulePath(),'testservices','ErrorService.py') err = ServiceTask(path,1,"NewFlag","0.0.0.0",None) err.start() self.assert_(err.status() == ServiceTask.ERROR) self.assert_(err.error() == "An Error")
def testBrokenScript(self): path = os.path.join(modulePath(),'testservices','BrokenService.py') err = ServiceTask(path,2,"NewFlag","0.0.0.0",None) err.start() self.assert_(err.status() == ServiceTask.INVALID_FLAG)