def test_queue_timeout(self): taskrunner = TaskRunner("guest", "guest", "localhost", "/", "ots", 5672, "test_taskrunner", 1, 1, 1, 1) _init_queue(self.channel, "test_taskrunner", taskrunner._services_exchange, "test_taskrunner") taskrunner.add_task("dummycommand") self.assertRaises(OtsQueueTimeoutError, taskrunner.run)
def setUp(self): self.taskrunner = TaskRunner("guest", "guest", "localhost", "/", "ots", 5672, "test_taskrunner", 1, 60, 1, 1) self.connection = amqp.Connection(host="localhost", userid="guest", password="******", virtual_host="/", insist=False) self.channel = self.connection.channel() _init_queue(self.channel, "test_taskrunner", self.taskrunner._services_exchange, "test_taskrunner")
def test_server_side_global_timeout(self): # taskrunner with long enough queue timeout to get message processed # and very short global timeout to get hit after task started taskrunner = TaskRunner("guest", "guest", "localhost", "/", "ots", 5672, "test_taskrunner", 1, 1, 1, 1) _init_queue(self.channel, "test_taskrunner", taskrunner._services_exchange, "test_taskrunner") # Create a task task_1 = Task(["1", "2"], 10) # Create a "started" state change message taskrunner._tasks = [task_1] self._publish_message(task_1.task_id, taskrunner._testrun_queue) self.assertRaises(OtsExecutionTimeoutError, taskrunner.run)
def taskrunner_factory(routing_key, execution_timeout, testrun_id, config_file=None): """ Instantiate a Taskrunner from the config file @type routing_key : C{str} @param routing_key : The routing_key for the Task @type execution_timeout: C{int} @param execution_timeout: The timeout for the remote commands @type testrun_id: C{int} @param testrun_id: The Testrun id @type config_file: C{str} @param config_file: The fqname of the config file @rtype: L{TaskRunner} @return: The TaskRunner """ if not config_file: config_file = server_config_filename() config = configobj.ConfigObj(config_file).get("ots.server.distributor") taskrunner = TaskRunner(username = config["username"], password = config["password"], host = config["host"], vhost = config["vhost"], services_exchange = routing_key, port = config.as_int("port"), routing_key = routing_key, testrun_id = testrun_id, execution_timeout = execution_timeout, queue_timeout = config.as_int("timeout_task_start"), controller_timeout = \ config.as_int("timeout_for_preparation")) return taskrunner