Set hostless queue entries to STARTING upon scheduling the agent. This fixes an issue where the scheduler created multiple HostlessQueueTask objects for a single hostless queue entry, causing several autoserv processes to be launched when the agents are run.
Signed-off-by: James Ren <[email protected]> --- autotest/scheduler/monitor_db.py 2010-03-08 15:45:53.000000000 -0800 +++ autotest/scheduler/monitor_db.py 2010-03-11 13:05:55.000000000 -0800 @@ -1077,6 +1077,7 @@ def _schedule_hostless_job(self, queue_entry): self.add_agent_task(HostlessQueueTask(queue_entry)) + queue_entry.set_status(models.HostQueueEntry.Status.STARTING) def _schedule_new_jobs(self): --- autotest/scheduler/monitor_db_unittest.py 2010-03-11 13:05:55.000000000 -0800 +++ autotest/scheduler/monitor_db_unittest.py 2010-03-11 13:05:55.000000000 -0800 @@ -1298,6 +1298,29 @@ self._dispatcher._schedule_running_host_queue_entries) + def test_schedule_hostless_job(self): + job = self._create_job(hostless=True) + self.assertEqual(1, job.hostqueueentry_set.count()) + hqe_query = scheduler_models.HostQueueEntry.fetch( + 'id = %s' % job.hostqueueentry_set.all()[0].id) + self.assertEqual(1, len(hqe_query)) + hqe = hqe_query[0] + + self.assertEqual(models.HostQueueEntry.Status.QUEUED, hqe.status) + self.assertEqual(0, len(self._dispatcher._agents)) + + self._dispatcher._schedule_new_jobs() + + self.assertEqual(models.HostQueueEntry.Status.STARTING, hqe.status) + self.assertEqual(1, len(self._dispatcher._agents)) + + self._dispatcher._schedule_new_jobs() + + # No change to previously schedule hostless job, and no additional agent + self.assertEqual(models.HostQueueEntry.Status.STARTING, hqe.status) + self.assertEqual(1, len(self._dispatcher._agents)) + + class TopLevelFunctionsTest(unittest.TestCase): def setUp(self): self.god = mock.mock_god() _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
