summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/db/test_nodes.py
diff options
context:
space:
mode:
authorMark Goddard <mark@stackhpc.com>2018-01-24 20:11:59 +0000
committerMark Goddard <mark@stackhpc.com>2018-01-24 20:11:59 +0000
commitd8a291a1e1c84df2f5f164f292c4fa80ed034078 (patch)
tree45776d308bf53bfe54ca7275d15ecaacc19a5cc6 /ironic/tests/unit/db/test_nodes.py
parent6a1a8efb5f356efae959601235773bbe19240bee (diff)
downloadironic-d8a291a1e1c84df2f5f164f292c4fa80ed034078.tar.gz
Fix node update with PostgreSQL
In the node traits RPC object change [1], the _do_update_node method in the sqlalchemy DB API was modified to use a select query joined with the node_tags and node_traits tables in the node update DB operation. This was done to ensure that the returned NodeModel had its tags and traits attributes populated rather than lazy loaded. This was found not to work on PostgreSQL, which presents the following error message [2]: Exception during message handling: DBNotSupportedError: (psycopg2.NotSupportedError) FOR UPDATE cannot be applied to the nullable side of an outer join This issue is resolved in this commit by reverting to the original query without joins for the node update, and performing a joined query after the update. [1] https://review.openstack.org/#/c/532268/13 [2] http://logs.openstack.org/69/532269/22/check/ironic-tempest-dsvm-pxe_ipmitool-postgres/562b2ea/logs/screen-ir-cond.txt.gz?level=ERROR#_Jan_23_23_59_05_062967 Change-Id: Ib0d49f7e781f1aa0c4496957b00f6c8e3da0ecc0 Related-Bug: #1722194
Diffstat (limited to 'ironic/tests/unit/db/test_nodes.py')
-rw-r--r--ironic/tests/unit/db/test_nodes.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/ironic/tests/unit/db/test_nodes.py b/ironic/tests/unit/db/test_nodes.py
index eb08a00bc..f66a9fa0f 100644
--- a/ironic/tests/unit/db/test_nodes.py
+++ b/ironic/tests/unit/db/test_nodes.py
@@ -450,6 +450,30 @@ class DbNodeTestCase(base.DbTestCase):
res = self.dbapi.update_node(node.id, {'extra': new_extra})
self.assertEqual(new_extra, res.extra)
+ self.assertEqual([], res.tags)
+ self.assertEqual([], res.traits)
+
+ def test_update_node_with_tags(self):
+ node = utils.create_test_node()
+ tag = utils.create_test_node_tag(node_id=node.id)
+
+ old_extra = node.extra
+ new_extra = {'foo': 'bar'}
+ self.assertNotEqual(old_extra, new_extra)
+
+ res = self.dbapi.update_node(node.id, {'extra': new_extra})
+ self.assertEqual([tag.tag], [t.tag for t in res.tags])
+
+ def test_update_node_with_traits(self):
+ node = utils.create_test_node()
+ trait = utils.create_test_node_trait(node_id=node.id)
+
+ old_extra = node.extra
+ new_extra = {'foo': 'bar'}
+ self.assertNotEqual(old_extra, new_extra)
+
+ res = self.dbapi.update_node(node.id, {'extra': new_extra})
+ self.assertEqual([trait.trait], [t.trait for t in res.traits])
def test_update_node_not_found(self):
node_uuid = uuidutils.generate_uuid()