X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a22d6e6bf03c6f274237f775a4c02122c9ce38ef..f87bda0e69ec38a7485f250328c32643c5587fd8:/services/nodemanager/tests/test_jobqueue.py diff --git a/services/nodemanager/tests/test_jobqueue.py b/services/nodemanager/tests/test_jobqueue.py index b27f69f15c..d4dc42f139 100644 --- a/services/nodemanager/tests/test_jobqueue.py +++ b/services/nodemanager/tests/test_jobqueue.py @@ -14,7 +14,9 @@ class ServerCalculatorTestCase(unittest.TestCase): def calculate(self, servcalc, *constraints): return servcalc.servers_for_queue( - [{'runtime_constraints': cdict} for cdict in constraints]) + [{'uuid': 'zzzzz-jjjjj-{:015x}'.format(index), + 'runtime_constraints': cdict} + for index, cdict in enumerate(constraints)]) def test_empty_queue_needs_no_servers(self): servcalc = self.make_calculator([1]) @@ -46,6 +48,64 @@ class ServerCalculatorTestCase(unittest.TestCase): {'min_scratch_mb_per_node': 200}) self.assertEqual(6, len(servlist)) + def test_ignore_too_expensive_jobs(self): + servcalc = self.make_calculator([1, 2], max_nodes=12, max_price=6) + servlist = self.calculate(servcalc, + {'min_cores_per_node': 1, 'min_nodes': 6}) + self.assertEqual(6, len(servlist)) + + servlist = self.calculate(servcalc, + {'min_cores_per_node': 2, 'min_nodes': 6}) + self.assertEqual(0, len(servlist)) + + def test_job_requesting_max_nodes_accepted(self): + servcalc = self.make_calculator([1], max_nodes=4) + servlist = self.calculate(servcalc, {'min_nodes': 4}) + self.assertEqual(4, len(servlist)) + + def test_cheapest_size(self): + servcalc = self.make_calculator([2, 4, 1, 3]) + self.assertEqual(testutil.MockSize(1), servcalc.cheapest_size()) + + def test_next_biggest(self): + servcalc = self.make_calculator([1, 2, 4, 8]) + servlist = self.calculate(servcalc, + {'min_cores_per_node': 3}, + {'min_cores_per_node': 6}) + self.assertEqual([servcalc.cloud_sizes[2].id, + servcalc.cloud_sizes[3].id], + [s.id for s in servlist]) + + def test_multiple_sizes(self): + servcalc = self.make_calculator([1, 2]) + servlist = self.calculate(servcalc, + {'min_cores_per_node': 2}, + {'min_cores_per_node': 1}, + {'min_cores_per_node': 1}) + self.assertEqual([servcalc.cloud_sizes[1].id, + servcalc.cloud_sizes[0].id, + servcalc.cloud_sizes[0].id], + [s.id for s in servlist]) + + servlist = self.calculate(servcalc, + {'min_cores_per_node': 1}, + {'min_cores_per_node': 2}, + {'min_cores_per_node': 1}) + self.assertEqual([servcalc.cloud_sizes[0].id, + servcalc.cloud_sizes[1].id, + servcalc.cloud_sizes[0].id], + [s.id for s in servlist]) + + servlist = self.calculate(servcalc, + {'min_cores_per_node': 1}, + {'min_cores_per_node': 1}, + {'min_cores_per_node': 2}) + self.assertEqual([servcalc.cloud_sizes[0].id, + servcalc.cloud_sizes[0].id, + servcalc.cloud_sizes[1].id], + [s.id for s in servlist]) + + class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin, unittest.TestCase): @@ -71,4 +131,3 @@ class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin, if __name__ == '__main__': unittest.main() -