示例#1
0
    def run(self):
        """
        Sends the Tasks to the queue
        Wait for the results to come back
        Close the connection
        """
        if self._is_run:
            raise TaskRunnerException("This TaskRunner has already been run")
        self._is_run = True 

        if not queue_exists(self._host, 
                            self._username, 
                            self._password, 
                            self._vhost, 
                            self._routing_key):
            raise OtsQueueDoesNotExistError("No queue for %s" %\
                                                (self._routing_key))
        LOGGER.debug("Sending Tasks")
        try:
            self._dispatch_tasks()
            self._wait_for_all_tasks()
            LOGGER.info("All Tasks completed")
        finally:
            send_monitor_event(MonitorType.TESTRUN_ENDED, __name__)
            LOGGER.debug("stopping...")
            self.timeout_handler.stop()
            self._close()
示例#2
0
 def _dispatch_tasks(self):
     """
     Publish the Tasks to the RabbitMQ
     """
     self.timeout_handler.start_queue_timeout()
     for task in self._tasks:
         log_msg = "Sending command '%s' with key '%s'" \
                       % (task.command, self._routing_key)
         LOGGER.debug(log_msg)
         
         #Send task in queue event with task id
         send_monitor_event(MonitorType.TASK_INQUEUE,
                            __name__,
                            task.task_id)
         
         cmd_msg = CommandMessage(task.command, 
                                  self._testrun_queue,
                                  task.task_id,
                                  timeout = self._execution_timeout,
                                  xml_file = task.xml_file,
                                  min_worker_version = 
                                    self._min_worker_version)
         message = pack_message(cmd_msg)
         self._channel.basic_publish(message, 
                                     exchange = self._services_exchange,
                                     routing_key = self._routing_key)
示例#3
0
    def _dispatch_tasks(self):
        """
        Publish the Tasks to the RabbitMQ
        """
        self.timeout_handler.start_queue_timeout()
        for task in self._tasks:
            log_msg = "Sending command '%s' with key '%s'" \
                          % (task.command, self._routing_key)
            LOGGER.debug(log_msg)

            #Send task in queue event with task id
            send_monitor_event(MonitorType.TASK_INQUEUE, __name__,
                               task.task_id)

            cmd_msg = CommandMessage(
                task.command,
                self._testrun_queue,
                task.task_id,
                timeout=self._execution_timeout,
                xml_file=task.xml_file,
                min_worker_version=self._min_worker_version)
            message = pack_message(cmd_msg)
            self._channel.basic_publish(message,
                                        exchange=self._services_exchange,
                                        routing_key=self._routing_key)
示例#4
0
    def __init__(self, sw_product, request_id, **kwargs):
        """
        The kwargs are the dictionary of arguments provided by the 
        request.
        Note. That these must contain an 'image'

        @type sw_product: C{str}
        @param sw_product: Name of the sw product this testrun belongs to

        @type request_id: C{str}
        @param request_id: An identifier for the request from the client
        """
        sandbox.is_on = True
        self._sw_product = sw_product
        self._request_id = request_id
        self._testrun_uuid = None

        self._options_factory = OptionsFactory(self.sw_product, kwargs)
        self._taskrunner = None

        self._options = None
        
        self._filehandler = None
        self._initialize_logger()

        LOG.debug(Options.format_dict(self._options_factory.all_options_dict))
        self._publishers = Publishers(self.request_id, 
                                      self.testrun_uuid, 
                                      self.sw_product,
                                      **self._options_factory.all_options_dict)
        
        LOG.debug("Publishers initilialised... sandbox switched off...")
        LOG.info("OTS Server. version '%s'" % (__VERSION__))

        # Log incoming options to help testrun debugging.
        # These need to match the xmlrpc interface options!
        try:
            incoming_options = deepcopy(kwargs)
            notify_list = ""
            if "notify_list" in incoming_options.keys():
                notify_list = incoming_options["notify_list"]
                del incoming_options["notify_list"]
            incoming_options = Options.format_dict(incoming_options)
            LOG.info(("Incoming request: program: %s, request: %s, " \
                          "notify_list: %s, options: %s")\
                         % (sw_product,
                            request_id,
                            notify_list,
                            incoming_options))
            # Send first monitor event
            send_monitor_event(MonitorType.TESTRUN_REQUESTED, __name__)
        except ValueError:
            pass
示例#5
0
    def __init__(self, sw_product, request_id, **kwargs):
        """
        The kwargs are the dictionary of arguments provided by the 
        request.
        Note. That these must contain an 'image'

        @type sw_product: C{str}
        @param sw_product: Name of the sw product this testrun belongs to

        @type request_id: C{str}
        @param request_id: An identifier for the request from the client
        """
        sandbox.is_on = True
        self._sw_product = sw_product
        self._request_id = request_id
        self._testrun_uuid = None

        self._options_factory = OptionsFactory(self.sw_product, kwargs)
        self._taskrunner = None

        self._options = None

        self._filehandler = None
        self._initialize_logger()

        LOG.debug(Options.format_dict(self._options_factory.all_options_dict))
        self._publishers = Publishers(self.request_id, self.testrun_uuid,
                                      self.sw_product,
                                      **self._options_factory.all_options_dict)

        LOG.debug("Publishers initilialised... sandbox switched off...")
        LOG.info("OTS Server. version '%s'" % (__VERSION__))

        # Log incoming options to help testrun debugging.
        # These need to match the xmlrpc interface options!
        try:
            incoming_options = deepcopy(kwargs)
            notify_list = ""
            if "notify_list" in incoming_options.keys():
                notify_list = incoming_options["notify_list"]
                del incoming_options["notify_list"]
            incoming_options = Options.format_dict(incoming_options)
            LOG.info(("Incoming request: program: %s, request: %s, " \
                          "notify_list: %s, options: %s")\
                         % (sw_product,
                            request_id,
                            notify_list,
                            incoming_options))
            # Send first monitor event
            send_monitor_event(MonitorType.TESTRUN_REQUESTED, __name__)
        except ValueError:
            pass
示例#6
0
    def run(self):
        """
        Sends the Tasks to the queue
        Wait for the results to come back
        Close the connection
        """
        if self._is_run:
            raise TaskRunnerException("This TaskRunner has already been run")
        self._is_run = True

        if not queue_exists(self._host, self._username, self._password,
                            self._vhost, self._routing_key):
            raise OtsQueueDoesNotExistError("No queue for %s" %\
                                                (self._routing_key))
        LOGGER.debug("Sending Tasks")
        try:
            self._dispatch_tasks()
            self._wait_for_all_tasks()
            LOGGER.info("All Tasks completed")
        finally:
            send_monitor_event(MonitorType.TESTRUN_ENDED, __name__)
            LOGGER.debug("stopping...")
            self.timeout_handler.stop()
            self._close()