OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import gc, logging, time | 3 import gc, logging, time |
4 import common | 4 import common |
5 from autotest_lib.frontend import setup_django_environment | 5 from autotest_lib.frontend import setup_django_environment |
6 from autotest_lib.frontend.afe import frontend_test_utils | 6 from autotest_lib.frontend.afe import frontend_test_utils |
7 from autotest_lib.client.common_lib.test_utils import mock | 7 from autotest_lib.client.common_lib.test_utils import mock |
8 from autotest_lib.client.common_lib.test_utils import unittest | 8 from autotest_lib.client.common_lib.test_utils import unittest |
9 from autotest_lib.database import database_connection | 9 from autotest_lib.database import database_connection |
10 from autotest_lib.frontend.afe import models | 10 from autotest_lib.frontend.afe import models |
11 from autotest_lib.scheduler import monitor_db, drone_manager, email_manager | 11 from autotest_lib.scheduler import monitor_db, drone_manager, email_manager |
12 from autotest_lib.scheduler import scheduler_config, gc_stats | 12 from autotest_lib.scheduler import scheduler_config, gc_stats, host_scheduler |
13 from autotest_lib.scheduler import monitor_db_functional_test | 13 from autotest_lib.scheduler import monitor_db_functional_test |
14 from autotest_lib.scheduler import scheduler_models | 14 from autotest_lib.scheduler import scheduler_models |
15 | 15 |
16 _DEBUG = False | 16 _DEBUG = False |
17 | 17 |
18 | 18 |
19 class DummyAgentTask(object): | 19 class DummyAgentTask(object): |
20 num_processes = 1 | 20 num_processes = 1 |
21 owner_username = 'my_user' | 21 owner_username = 'my_user' |
22 | 22 |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 self.assert_(queue_entry.execution_subdir) | 1291 self.assert_(queue_entry.execution_subdir) |
1292 self.god.check_playback() | 1292 self.god.check_playback() |
1293 | 1293 |
1294 class dummy_test_agent(object): | 1294 class dummy_test_agent(object): |
1295 task = 'dummy_test_agent' | 1295 task = 'dummy_test_agent' |
1296 self._dispatcher._register_agent_for_ids( | 1296 self._dispatcher._register_agent_for_ids( |
1297 self._dispatcher._host_agents, [queue_entry.host.id], | 1297 self._dispatcher._host_agents, [queue_entry.host.id], |
1298 dummy_test_agent) | 1298 dummy_test_agent) |
1299 | 1299 |
1300 # Attempted to schedule on a host that already has an agent. | 1300 # Attempted to schedule on a host that already has an agent. |
1301 self.assertRaises(monitor_db.SchedulerError, | 1301 self.assertRaises(host_scheduler.SchedulerError, |
1302 self._dispatcher._schedule_running_host_queue_entries) | 1302 self._dispatcher._schedule_running_host_queue_entries) |
1303 | 1303 |
1304 | 1304 |
1305 def test_schedule_hostless_job(self): | 1305 def test_schedule_hostless_job(self): |
1306 job = self._create_job(hostless=True) | 1306 job = self._create_job(hostless=True) |
1307 self.assertEqual(1, job.hostqueueentry_set.count()) | 1307 self.assertEqual(1, job.hostqueueentry_set.count()) |
1308 hqe_query = scheduler_models.HostQueueEntry.fetch( | 1308 hqe_query = scheduler_models.HostQueueEntry.fetch( |
1309 'id = %s' % job.hostqueueentry_set.all()[0].id) | 1309 'id = %s' % job.hostqueueentry_set.all()[0].id) |
1310 self.assertEqual(1, len(hqe_query)) | 1310 self.assertEqual(1, len(hqe_query)) |
1311 hqe = hqe_query[0] | 1311 hqe = hqe_query[0] |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 expected = self._setup_test_user_or_global_default_drone_set() | 1510 expected = self._setup_test_user_or_global_default_drone_set() |
1511 actual = monitor_db.AgentTask()._user_or_global_default_drone_set( | 1511 actual = monitor_db.AgentTask()._user_or_global_default_drone_set( |
1512 None, MockUser()) | 1512 None, MockUser()) |
1513 | 1513 |
1514 self.assertEqual(expected, actual) | 1514 self.assertEqual(expected, actual) |
1515 self.god.check_playback() | 1515 self.god.check_playback() |
1516 | 1516 |
1517 | 1517 |
1518 if __name__ == '__main__': | 1518 if __name__ == '__main__': |
1519 unittest.main() | 1519 unittest.main() |
OLD | NEW |