summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/db/test_nodes.py
diff options
context:
space:
mode:
authorMark Goddard <mark@stackhpc.com>2017-12-15 11:29:00 +0000
committerRuby Loo <ruby.loo@intel.com>2018-01-11 15:20:43 +0000
commitbbff319f0226af11af3c2864ad8f678abef6dcdb (patch)
treea6c1a93b012ccb178bd5d274120dd04add217edc /ironic/tests/unit/db/test_nodes.py
parentc31b22887f82e72666f127ec798e25b29c6a99ea (diff)
downloadironic-bbff319f0226af11af3c2864ad8f678abef6dcdb.tar.gz
Node traits: Add DB API & model
Adds a NodeTrait model to the DB and DBAPI methods for the following: * Set/unset node traits * Get node traits * Add/remove a single trait * Check for existence of a node trait All node traits are deleted when their owner node is deleted. Traits cannot be specified on node creation currently. Change-Id: I8b375a33dcb94d2cc73eaa93a5cc5aed86c27178 Partial-Bug: #1722194
Diffstat (limited to 'ironic/tests/unit/db/test_nodes.py')
-rw-r--r--ironic/tests/unit/db/test_nodes.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/ironic/tests/unit/db/test_nodes.py b/ironic/tests/unit/db/test_nodes.py
index 5f975b2f2..ff09b62d9 100644
--- a/ironic/tests/unit/db/test_nodes.py
+++ b/ironic/tests/unit/db/test_nodes.py
@@ -38,6 +38,11 @@ class DbNodeTestCase(base.DbTestCase):
utils.create_test_node,
tags=['tag1', 'tag2'])
+ def test_create_node_with_traits(self):
+ self.assertRaises(exception.InvalidParameterValue,
+ utils.create_test_node,
+ traits=['trait1', 'trait2'])
+
def test_create_node_already_exists(self):
utils.create_test_node()
self.assertRaises(exception.NodeAlreadyExists,
@@ -399,6 +404,26 @@ class DbNodeTestCase(base.DbTestCase):
self.assertRaises(exception.VolumeTargetNotFound,
self.dbapi.get_volume_target_by_id, target.id)
+ def test_traits_get_destroyed_after_destroying_a_node(self):
+ node = utils.create_test_node()
+
+ trait = utils.create_test_node_trait(node_id=node.id)
+
+ self.assertTrue(self.dbapi.node_trait_exists(node.id, trait.trait))
+ self.dbapi.destroy_node(node.id)
+ self.assertRaises(exception.NodeNotFound,
+ self.dbapi.node_trait_exists, node.id, trait.trait)
+
+ def test_traits_get_destroyed_after_destroying_a_node_by_uuid(self):
+ node = utils.create_test_node()
+
+ trait = utils.create_test_node_trait(node_id=node.id)
+
+ self.assertTrue(self.dbapi.node_trait_exists(node.id, trait.trait))
+ self.dbapi.destroy_node(node.uuid)
+ self.assertRaises(exception.NodeNotFound,
+ self.dbapi.node_trait_exists, node.id, trait.trait)
+
def test_update_node(self):
node = utils.create_test_node()