Merge "Use processed bool as key in introspection_data DB table"

This commit is contained in:
Zuul 2019-02-14 12:00:29 +00:00 committed by Gerrit Code Review
commit 5728880e85
3 changed files with 21 additions and 2 deletions

View File

@ -137,7 +137,7 @@ class RuleAction(Base):
class IntrospectionData(Base):
__tablename__ = 'introspection_data'
uuid = Column(String(36), ForeignKey('nodes.uuid'), primary_key=True)
processed = Column(Boolean, default=False)
processed = Column(Boolean, default=False, primary_key=True)
data = Column(db_types.JsonEncodedDict(mysql_as_long=True),
nullable=True)

View File

@ -34,7 +34,7 @@ def upgrade():
'introspection_data',
sa.Column('uuid', sa.String(36), sa.ForeignKey('nodes.uuid'),
primary_key=True),
sa.Column('processed', sa.Boolean, default=False),
sa.Column('processed', sa.Boolean, default=False, primary_key=True),
sa.Column('data', db_types.JsonEncodedDict(mysql_as_long=True).impl,
nullable=True),
mysql_ENGINE='InnoDB',

View File

@ -1285,3 +1285,22 @@ class TestIntrospectionDataDbStore(test_base.NodeTest):
def test_get_no_data_available(self):
self.assertRaises(utils.IntrospectionDataNotFound,
node_cache.get_introspection_data, self.node.uuid)
def test_store_proc_and_unproc(self):
unproc_data = {'s': 'value', 'b': True, 'i': 42}
node_cache.store_introspection_data(self.node.uuid,
unproc_data,
processed=False)
proc_data = {'foo': 'bar'}
node_cache.store_introspection_data(self.node.uuid,
proc_data,
processed=True)
stored_data = node_cache.get_introspection_data(self.node.uuid,
True)
self.assertEqual(stored_data, proc_data)
stored_data = node_cache.get_introspection_data(self.node.uuid,
False)
self.assertEqual(stored_data, unproc_data)