def __init__(self, queue_entries, suite_min_duts=None):
        """Initialize.

        @param queue_entries: A list of HostQueueEntry objects.
        @param suite_min_duts: A dictionary where the key is suite job id,
                and the value is the value of 'suite_min_dut' in the suite's
                job keyvals. It should cover all the suite jobs which
                the jobs (associated with the queue_entries) belong to.
        """
        # TODO(beeps): Break this dependency on the host_query_manager,
        # crbug.com/336934.
        from autotest_lib.scheduler import query_managers
        self.query_manager = query_managers.AFEHostQueryManager()
        jobs = [queue_entry.job_id for queue_entry in queue_entries]
        self._job_acls = self.query_manager._get_job_acl_groups(jobs)
        self._job_deps = self.query_manager._get_job_dependencies(jobs)
        self._labels = self.query_manager._get_labels(self._job_deps)
        self._suite_min_duts = suite_min_duts or {}
Esempio n. 2
0
    def setUp(self, inline_host_acquisition=True, setup_tables=True):
        """Common setup module for tests that need a jobs/host database.

        @param inline_host_acquisition: If True, the dispatcher tries to acquire
            hosts inline with the rest of the tick.
        """
        self.db_helper = DBHelper()
        self._database = self.db_helper.database
        # Runs syncdb setting up initial database conditions
        self._frontend_common_setup(setup_tables=setup_tables)
        connection_manager = scheduler_lib.ConnectionManager(autocommit=False)
        self.god.stub_with(connection_manager, 'db_connection', self._database)
        self.god.stub_with(monitor_db, '_db_manager', connection_manager)
        self.god.stub_with(scheduler_models, '_db', self._database)
        self.god.stub_with(monitor_db, '_inline_host_acquisition',
                           inline_host_acquisition)
        self._dispatcher = monitor_db.Dispatcher()
        self.host_scheduler = self._dispatcher._host_scheduler
        self.host_query_manager = query_managers.AFEHostQueryManager()
        self.job_query_manager = self._dispatcher._job_query_manager
        self._release_unused_hosts()
Esempio n. 3
0
 def __init__(self):
     self.host_query_manager = query_managers.AFEHostQueryManager()