diff --git a/ironic/tests/unit/api/test_acl.py b/ironic/tests/unit/api/test_acl.py index 121b7144ba..3c85f3d0ea 100644 --- a/ironic/tests/unit/api/test_acl.py +++ b/ironic/tests/unit/api/test_acl.py @@ -249,6 +249,7 @@ class TestRBACModelBeforeScopesBase(TestACLBase): resource_class="CUSTOM_TEST") fake_db_node = db_utils.create_test_node( chassis_id=None, + uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123', driver='fake-driverz', owner='z') fake_db_node_alloced = db_utils.create_test_node( @@ -262,12 +263,14 @@ class TestRBACModelBeforeScopesBase(TestACLBase): dict(node_id=allocated_node_id)) fake_vif_port_id = "ee21d58f-5de2-4956-85ff-33935ea1ca00" fake_db_port = db_utils.create_test_port( + uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c781', node_id=fake_db_node['id'], internal_info={'tenant_vif_port_id': fake_vif_port_id}) fake_db_portgroup = db_utils.create_test_portgroup( uuid="6eb02b44-18a3-4659-8c0b-8d2802581ae4", node_id=fake_db_node['id']) fake_db_chassis = db_utils.create_test_chassis( + uuid='e74c40e0-d825-11e2-a28f-0800200c9a66', drivers=['fake-hardware', 'fake-driverz', 'fake-driver']) fake_db_deploy_template = db_utils.create_test_deploy_template() fake_db_conductor = db_utils.create_test_conductor() diff --git a/ironic/tests/unit/db/test_nodes.py b/ironic/tests/unit/db/test_nodes.py index 5d5489f5f5..82d6e45167 100644 --- a/ironic/tests/unit/db/test_nodes.py +++ b/ironic/tests/unit/db/test_nodes.py @@ -59,9 +59,9 @@ class DbNodeTestCase(base.DbTestCase): traits=['trait1', 'trait2']) def test_create_node_already_exists(self): - utils.create_test_node() + node = utils.create_test_node() self.assertRaises(exception.NodeAlreadyExists, - utils.create_test_node) + utils.create_test_node, uuid=node.uuid) def test_create_node_instance_already_associated(self): instance = uuidutils.generate_uuid() diff --git a/ironic/tests/unit/db/utils.py b/ironic/tests/unit/db/utils.py index 8e72608cb8..c36e9add06 100644 --- a/ironic/tests/unit/db/utils.py +++ b/ironic/tests/unit/db/utils.py @@ -262,7 +262,7 @@ def create_test_node(**kw): # Let DB generate an ID if one isn't specified explicitly. # Creating a node with tags or traits will raise an exception. If tags or # traits are not specified explicitly just delete them. - for field in {'id', 'tags', 'traits'}: + for field in {'id', 'uuid', 'tags', 'traits'}: if field not in kw: del node[field] dbapi = db_api.get_instance() @@ -305,8 +305,9 @@ def create_test_port(**kw): """ port = get_test_port(**kw) # Let DB generate ID if it isn't specified explicitly - if 'id' not in kw: - del port['id'] + for field in ('id', 'uuid'): + if field not in kw: + del port[field] dbapi = db_api.get_instance() return dbapi.create_port(port) @@ -337,8 +338,9 @@ def create_test_volume_connector(**kw): """ connector = get_test_volume_connector(**kw) # Let DB generate ID if it isn't specified explicitly - if 'id' not in kw: - del connector['id'] + for field in ('id', 'uuid'): + if field not in kw: + del connector[field] dbapi = db_api.get_instance() return dbapi.create_volume_connector(connector) @@ -371,8 +373,9 @@ def create_test_volume_target(**kw): """ target = get_test_volume_target(**kw) # Let DB generate ID if it isn't specified explicitly - if 'id' not in kw: - del target['id'] + for field in ('id', 'uuid'): + if field not in kw: + del target[field] dbapi = db_api.get_instance() return dbapi.create_volume_target(target) @@ -400,8 +403,9 @@ def create_test_chassis(**kw): """ chassis = get_test_chassis(**kw) # Let DB generate ID if it isn't specified explicitly - if 'id' not in kw: - del chassis['id'] + for field in ('id', 'uuid'): + if field not in kw: + del chassis[field] dbapi = db_api.get_instance() return dbapi.create_chassis(chassis) @@ -476,8 +480,9 @@ def create_test_portgroup(**kw): """ portgroup = get_test_portgroup(**kw) # Let DB generate ID if it isn't specified explicitly - if 'id' not in kw: - del portgroup['id'] + for field in ('id', 'uuid'): + if field not in kw: + del portgroup[field] dbapi = db_api.get_instance() return dbapi.create_portgroup(portgroup)