Catch errors thrown by sync_node() in Azure driver refs #7031.
[arvados.git] / services / nodemanager / tests / test_jobqueue.py
index 3814ba4610a3db416c01d5e3ddb2c5d31de435b2..4c97aed8b109a576843105bad7cf7f62b14426ce 100644 (file)
@@ -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,15 @@ class ServerCalculatorTestCase(unittest.TestCase):
                                   {'min_scratch_mb_per_node': 200})
         self.assertEqual(6, 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())
+
 
 class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin,
                                    unittest.TestCase):
@@ -63,8 +74,8 @@ class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin,
 
     def test_subscribers_get_server_lists(self):
         self.build_monitor([{'items': [1, 2]}], self.MockCalculator())
-        self.monitor.subscribe(self.subscriber)
-        self.wait_for_call(self.subscriber)
+        self.monitor.subscribe(self.subscriber).get(self.TIMEOUT)
+        self.stop_proxy(self.monitor)
         self.subscriber.assert_called_with([testutil.MockSize(1),
                                             testutil.MockSize(2)])