[autotest] Sanity check host assignments.
Check that we haven't violated any correctness constraints by
assigning the same host to 2 simultaneously active jobs. These
changes are in preperation for eventually breaking host assignment
out of the scheduler. The performance degradation should be negligable
since we're only querying for the host_ids of currently active jobs,
every 5 minutes.
TEST=Ran suites, unittests.
BUG=None
DEPLOY=Scheduler
Change-Id: Ie560a67861f9e4d1d59cda9828fb9d2ef433e5f4
Reviewed-on: https://chromium-review.googlesource.com/198196
Reviewed-by: Prashanth B <beeps@chromium.org>
Tested-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Prashanth B <beeps@chromium.org>
diff --git a/scheduler/monitor_db_unittest.py b/scheduler/monitor_db_unittest.py
index 3ca8f50..5b12c91 100755
--- a/scheduler/monitor_db_unittest.py
+++ b/scheduler/monitor_db_unittest.py
@@ -13,6 +13,7 @@
from autotest_lib.scheduler import monitor_db, drone_manager, email_manager
from autotest_lib.scheduler import pidfile_monitor
from autotest_lib.scheduler import scheduler_config, gc_stats, host_scheduler
+from autotest_lib.scheduler import monitor_db_cleanup
from autotest_lib.scheduler import monitor_db_functional_test
from autotest_lib.scheduler import scheduler_models
@@ -428,6 +429,17 @@
self._dispatcher._garbage_collection()
+ def test_overlapping_jobs(self):
+ """Test that we can detect overlapping jobs."""
+ self._create_job_simple([1], True)
+ self._run_scheduler()
+ self._do_query('UPDATE afe_hosts SET leased=0 where id=1')
+ self._create_job_simple([1], True)
+ self._run_scheduler()
+ jobs = monitor_db_cleanup.UserCleanup.get_overlapping_jobs()
+ self.assertTrue(jobs[0]['job_id'] == 1 and jobs[0]['host_id'] == 1 and
+ jobs[1]['job_id'] == 2 and jobs[1]['host_id'] == 1)
+
class DispatcherThrottlingTest(BaseSchedulerTest):
"""