def test_reschedule_id(self): id, sample = self.add_task() task = Task() newid = task.reschedule(task_id=id) oldtask = self.db.view_task(id) newtask = self.db.view_task(newid) assert newid is not None assert oldtask.status == "recovered" assert newtask.targets[0].category == "file"
def init_tasks(): """Check tasks and reschedule uncompleted ones.""" db = Database() log.debug("Checking for locked tasks..") for task in db.list_tasks(status=TASK_RUNNING): if config("cuckoo:cuckoo:reschedule"): new_task = Task(task) new_task.reschedule() log.info("Rescheduled task with ID %s and target %s: task #%s", task.id, new_task.target, new_task.id) else: db.set_status(task.id, TASK_FAILED_ANALYSIS) log.info("Updated running task ID %s status to failed_analysis", task.id) log.debug("Checking for pending service tasks..") for task in db.list_tasks(status=TASK_PENDING, type="service"): db.set_status(task.id, TASK_FAILED_ANALYSIS)
def test_reschedule_file(self): id, sample = self.add_task() task = Task() task.load_from_db(id) newid = task.reschedule(priority=3) oldtask = self.db.view_task(id) newtask = self.db.view_task(newid) assert newid is not None assert oldtask.status == "recovered" assert newtask.targets[0].category == "file" assert newtask.targets[0].target == sample assert newtask.priority == 3
def test_reschedule_url(self): id, sample = self.add_task( url="http://example.com/42", category="url" ) task = Task() task.load_from_db(id) newid = task.reschedule(priority=2) oldtask = self.db.view_task(id) newtask = self.db.view_task(newid) assert newid is not None assert oldtask.status == "recovered" assert newtask.targets[0].category == "url" assert newtask.priority == 2 assert newtask.targets[0].target == "http://example.com/42"