[autotest] Make global scheduler not execute hqes of shards

The scheduler today just executes all hqes that are in the database.
With shards this behaviour is not wanted, it should only execute
the hqes that are not meant to be executed by a shard.

This changes adds a condition, so the scheduler won't pick up hqes
with meta_hosts, that have an entry in afe_shards_labels.

TEST=Ran suites + Ran dummy, ensured only hostless job is executed.
DEPLOY=scheduler,host_scheduler
CQ-DEPEND=CL:211214

Change-Id: I85b14acb24bb24e9a14d5db2d42c6611fd15fc02
Reviewed-on: https://chromium-review.googlesource.com/214656
Reviewed-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Jakob Jülich <jakobjuelich@chromium.org>
Tested-by: Jakob Jülich <jakobjuelich@chromium.org>
diff --git a/scheduler/host_scheduler_unittests.py b/scheduler/host_scheduler_unittests.py
index a9a854c..566098b 100644
--- a/scheduler/host_scheduler_unittests.py
+++ b/scheduler/host_scheduler_unittests.py
@@ -44,6 +44,20 @@
                         jobs_without_hosts[0].host_id is None)
 
 
+    def testPendingQueueEntriesForShard(self):
+        """Test queue entries for shards aren't executed by master scheduler"""
+        job1 = self.create_job(deps=set(['a']))
+        job2 = self.create_job(deps=set(['b']))
+        shard = models.Shard.objects.create()
+        # Assign the job's label to a shard
+        shard.labels.add(job1.dependency_labels.all()[0])
+
+        # Check that we only pull jobs which are not assigned to a shard.
+        jobs_with_hosts = self.job_query_manager.get_pending_queue_entries()
+        self.assertTrue(len(jobs_with_hosts) == 1)
+        self.assertEqual(jobs_with_hosts[0].id, job2.id)
+
+
     def testHostQueries(self):
         """Verify that the host query manager maintains its data structures."""
         # Create a job and use the host_query_managers internal datastructures