def test_create_allocation_resource_class_mismatch(self): _, body = self.create_allocation(self.resource_class + 'foo') _, body = waiters.wait_for_allocation(self.client, body['uuid'], expect_error=True) self.assertEqual('error', body['state']) self.assertTrue(body['last_error'])
def test_create_allocation_traits_mismatch(self): _, body = self.create_allocation( self.resource_class, traits=['CUSTOM_DOES_NOT_EXIST']) _, body = waiters.wait_for_allocation(self.client, body['uuid'], expect_error=True) self.assertEqual('error', body['state']) self.assertTrue(body['last_error'])
def test_create_allocation_node_mismatch(self): _, node2 = self.create_node(self.chassis['uuid'], resource_class=self.resource_class + 'alt') # Mismatch between the resource class and the candidate node _, body = self.create_allocation( self.resource_class, candidate_nodes=[node2['uuid']]) _, body = waiters.wait_for_allocation(self.client, body['uuid'], expect_error=True) self.assertEqual('error', body['state']) self.assertTrue(body['last_error'])
def test_list_allocations_by_state(self): _, body = self.create_allocation(self.resource_class) _, body2 = self.create_allocation(self.resource_class + 'foo2') waiters.wait_for_allocation(self.client, body['uuid']) waiters.wait_for_allocation(self.client, body2['uuid'], expect_error=True) _, listing = self.client.list_allocations(state='active') uuids = [i['uuid'] for i in listing['allocations']] self.assertIn(body['uuid'], uuids) self.assertNotIn(body2['uuid'], uuids) _, listing = self.client.list_allocations(state='error') uuids = [i['uuid'] for i in listing['allocations']] self.assertNotIn(body['uuid'], uuids) self.assertIn(body2['uuid'], uuids) _, listing = self.client.list_allocations(state='allocating') uuids = [i['uuid'] for i in listing['allocations']] self.assertNotIn(body['uuid'], uuids) self.assertNotIn(body2['uuid'], uuids)
def test_create_allocation_with_traits(self): _, node2 = self.create_node(self.chassis['uuid'], resource_class=self.resource_class) self.client.set_node_traits(node2['uuid'], ['CUSTOM_MEOW']) self.provide_and_power_off_node(node2['uuid']) _, body = self.create_allocation(self.resource_class, traits=['CUSTOM_MEOW']) uuid = body['uuid'] self.assertTrue(uuid) self.assertEqual('allocating', body['state']) self.assertEqual(['CUSTOM_MEOW'], body['traits']) self.assertIsNone(body['last_error']) _, body = waiters.wait_for_allocation(self.client, uuid) self.assertEqual('active', body['state']) self.assertEqual(['CUSTOM_MEOW'], body['traits']) self.assertIsNone(body['last_error']) self.assertEqual(node2['uuid'], body['node_uuid'])
def test_create_allocation_candidate_node(self): node_name = 'allocation-test-1' _, node2 = self.create_node(self.chassis['uuid'], resource_class=self.resource_class, name=node_name) self.provide_and_power_off_node(node2['uuid']) _, body = self.create_allocation(self.resource_class, candidate_nodes=[node_name]) uuid = body['uuid'] self.assertTrue(uuid) self.assertEqual('allocating', body['state']) self.assertEqual([node2['uuid']], body['candidate_nodes']) self.assertIsNone(body['last_error']) _, body = waiters.wait_for_allocation(self.client, uuid) self.assertEqual('active', body['state']) self.assertEqual([node2['uuid']], body['candidate_nodes']) self.assertIsNone(body['last_error']) self.assertEqual(node2['uuid'], body['node_uuid'])
def test_create_show_allocation(self): self.assertIsNone(self.node['allocation_uuid']) _, body = self.create_allocation(self.resource_class) uuid = body['uuid'] self.assertTrue(uuid) self.assertEqual('allocating', body['state']) self.assertEqual(self.resource_class, body['resource_class']) self.assertIsNone(body['last_error']) self.assertIsNone(body['node_uuid']) _, body = waiters.wait_for_allocation(self.client, uuid) self.assertEqual('active', body['state']) self.assertEqual(self.resource_class, body['resource_class']) self.assertIsNone(body['last_error']) self.assertEqual(self.node['uuid'], body['node_uuid']) _, body2 = self.client.show_node_allocation(body['node_uuid']) self.assertEqual(body, body2) _, node = self.client.show_node(self.node['uuid']) self.assertEqual(uuid, node['allocation_uuid'])