From: Lucas Di Pentima Date: Mon, 26 Mar 2018 21:15:46 +0000 (-0300) Subject: 13166: Sort optimization & wishlist ordering testing. X-Git-Tag: 1.1.4~17^2~1 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/66aaa7d715eedd38265ee0987ef2a5cf7b623fd9?hp=-c 13166: Sort optimization & wishlist ordering testing. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- 66aaa7d715eedd38265ee0987ef2a5cf7b623fd9 diff --git a/services/nodemanager/arvnodeman/jobqueue.py b/services/nodemanager/arvnodeman/jobqueue.py index 8f3d7b97a8..90b32290b7 100644 --- a/services/nodemanager/arvnodeman/jobqueue.py +++ b/services/nodemanager/arvnodeman/jobqueue.py @@ -153,7 +153,7 @@ class JobQueueMonitorActor(clientactor.RemotePollLoopActor): def _send_request(self): queuelist = [] if self.slurm_queue: - # cpus, memory, tempory disk space, reason, job name, feature constraints + # cpus, memory, tempory disk space, reason, job name, feature constraints, priority squeue_out = subprocess.check_output(["squeue", "--state=PENDING", "--noheader", "--format=%c|%m|%d|%r|%j|%f|%Q"]) for out in squeue_out.splitlines(): try: @@ -193,7 +193,7 @@ class JobQueueMonitorActor(clientactor.RemotePollLoopActor): }, "priority": int(priority) }) - queuelist = sorted(queuelist, key=lambda x: x.get('priority', 1), reverse=True) + queuelist.sort(key=lambda x: x.get('priority', 1), reverse=True) if self.jobs_queue: queuelist.extend(self._client.jobs().queue().execute()['items']) diff --git a/services/nodemanager/tests/test_daemon.py b/services/nodemanager/tests/test_daemon.py index 614adbe83c..4b2b2d4bf8 100644 --- a/services/nodemanager/tests/test_daemon.py +++ b/services/nodemanager/tests/test_daemon.py @@ -714,6 +714,27 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, self.assertEqual(2, sizecounts[small.id]) self.assertEqual(1, sizecounts[big.id]) + def test_wishlist_ordering(self): + # Check that big nodes aren't prioritized; since #12199 containers are + # scheduled on specific node sizes. + small = testutil.MockSize(1) + big = testutil.MockSize(2) + avail_sizes = [(testutil.MockSize(1), {"cores":1}), + (testutil.MockSize(2), {"cores":2})] + self.make_daemon(want_sizes=[small, small, small, big], + avail_sizes=avail_sizes, max_nodes=3) + + # the daemon runs in another thread, so we need to wait and see + # if it does all the work we're expecting it to do before stopping it. + self.busywait(lambda: self.node_setup.start.call_count == 3) + booting = self.daemon.booting.get(self.TIMEOUT) + self.stop_proxy(self.daemon) + sizecounts = {a[0].id: 0 for a in avail_sizes} + for b in booting.itervalues(): + sizecounts[b.cloud_size.get().id] += 1 + self.assertEqual(3, sizecounts[small.id]) + self.assertEqual(0, sizecounts[big.id]) + def test_wishlist_reconfigure(self): small = testutil.MockSize(1) big = testutil.MockSize(2)