8953: shutdown_eligible() returns a tuple. Report reason for shutdown decision.
[arvados.git] / services / nodemanager / tests / test_computenode_driver_azure.py
index 3ef152ef874bb17c7a368c68827e665851c1e2f8..59fc503128aef69be02a6a45aabf86f80fde6540 100644 (file)
@@ -100,3 +100,37 @@ echo compute-000000000000063-zzzzz > /var/tmp/arv-node-data/meta-data/instance-i
 echo z1.test > /var/tmp/arv-node-data/meta-data/instance-type
 """,
                          driver.arvados_create_kwargs(testutil.MockSize(1), arv_node)['ex_customdata'])
+
+    def test_create_raises_but_actually_succeeded(self):
+        arv_node = testutil.arvados_node_mock(1, hostname=None)
+        driver = self.new_driver(create_kwargs={"tag_arvados-class": "dynamic-compute"})
+        nodelist = [testutil.cloud_node_mock(1, tags={"arvados-class": "dynamic-compute"})]
+        nodelist[0].name = 'compute-000000000000001-zzzzz'
+        self.driver_mock().list_nodes.return_value = nodelist
+        self.driver_mock().create_node.side_effect = IOError
+        n = driver.create_node(testutil.MockSize(1), arv_node)
+        self.assertEqual('compute-000000000000001-zzzzz', n.name)
+
+    def test_ex_fetch_nic_false(self):
+        arv_node = testutil.arvados_node_mock(1, hostname=None)
+        driver = self.new_driver(create_kwargs={"tag_arvados-class": "dynamic-compute"})
+        nodelist = [testutil.cloud_node_mock(1, tags={"arvados-class": "dynamic-compute"})]
+        nodelist[0].name = 'compute-000000000000001-zzzzz'
+        self.driver_mock().list_nodes.return_value = nodelist
+        n = driver.list_nodes()
+        self.assertEqual(nodelist, n)
+        self.driver_mock().list_nodes.assert_called_with(ex_fetch_nic=False, ex_resource_group='TestResourceGroup')
+
+    def test_create_can_find_node_after_timeout(self):
+        super(AzureComputeNodeDriverTestCase,
+              self).test_create_can_find_node_after_timeout(
+                  create_kwargs={'tag_arvados-class': 'test'},
+                  node_extra={'tags': {'arvados-class': 'test'}})
+
+    def test_node_found_after_timeout_has_fixed_size(self):
+        size = testutil.MockSize(4)
+        node_props = {'hardwareProfile': {'vmSize': size.id}}
+        cloud_node = testutil.cloud_node_mock(
+            size=None, tags={'arvados-class': 'test'}, properties=node_props)
+        self.check_node_found_after_timeout_has_fixed_size(
+            size, cloud_node, {'tag_arvados-class': 'test'})