Tags info calculation is supported on plugins update
For instance we made plugins sync operation. In this case tags info should be processed on the same way as on plugin creation. Also test for tags metadata migration improved. Change-Id: I2eebc40af3c3f360e2ef96958a38c7eae0da43d5 Closes-Bug: #1655264
This commit is contained in:
parent
66db02a445
commit
3850bba483
@ -121,6 +121,8 @@ class Plugin(NailgunObject):
|
|||||||
graphs[graph.pop('type')] = graph
|
graphs[graph.pop('type')] = graph
|
||||||
|
|
||||||
data.pop("deployment_tasks", []) # could not be updated
|
data.pop("deployment_tasks", []) # could not be updated
|
||||||
|
# We must save tags info in the roles_metadata on the update
|
||||||
|
data = cls._process_tags(data)
|
||||||
super(Plugin, cls).update(instance, data)
|
super(Plugin, cls).update(instance, data)
|
||||||
|
|
||||||
for graph_type, graph_data in six.iteritems(graphs):
|
for graph_type, graph_data in six.iteritems(graphs):
|
||||||
|
@ -524,6 +524,33 @@ def prepare():
|
|||||||
])
|
])
|
||||||
}]
|
}]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
db.execute(
|
||||||
|
meta.tables['plugins'].insert(),
|
||||||
|
[{
|
||||||
|
'name': 'test_tags',
|
||||||
|
'title': 'Test tags plugin',
|
||||||
|
'version': '2.0.0',
|
||||||
|
'description': 'Test plugin A for Fuel',
|
||||||
|
'homepage': 'http://fuel_plugins.test_plugin.com',
|
||||||
|
'package_version': '5.0.0',
|
||||||
|
'groups': jsonutils.dumps(['tgroup']),
|
||||||
|
'authors': jsonutils.dumps(['tauthor']),
|
||||||
|
'licenses': jsonutils.dumps(['tlicense']),
|
||||||
|
'releases': jsonutils.dumps([
|
||||||
|
{'repository_path': 'repositories/ubuntu'}
|
||||||
|
]),
|
||||||
|
'deployment_tasks': jsonutils.dumps([]),
|
||||||
|
'fuel_version': jsonutils.dumps(['9.2']),
|
||||||
|
'network_roles_metadata': jsonutils.dumps([]),
|
||||||
|
'roles_metadata': jsonutils.dumps({
|
||||||
|
'plugin-tags-controller': {
|
||||||
|
'name': 'Plugin Tags Controller',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}]
|
||||||
|
)
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
@ -810,7 +837,7 @@ class TestTags(base.BaseAlembicMigrationTest):
|
|||||||
primary_tags = db.execute(query).fetchone()[0]
|
primary_tags = db.execute(query).fetchone()[0]
|
||||||
self.assertItemsEqual(primary_tags, ['controller', 'role_y'])
|
self.assertItemsEqual(primary_tags, ['controller', 'role_y'])
|
||||||
|
|
||||||
def test_tags_meta_migration(self):
|
def test_tags_releases_meta_migration(self):
|
||||||
releases = self.meta.tables['releases']
|
releases = self.meta.tables['releases']
|
||||||
query = sa.select([releases.c.roles_metadata,
|
query = sa.select([releases.c.roles_metadata,
|
||||||
releases.c.tags_metadata])
|
releases.c.tags_metadata])
|
||||||
@ -822,3 +849,18 @@ class TestTags(base.BaseAlembicMigrationTest):
|
|||||||
tags_meta[role_name].get('has_primary', False),
|
tags_meta[role_name].get('has_primary', False),
|
||||||
role_meta.get('has_primary', False)
|
role_meta.get('has_primary', False)
|
||||||
)
|
)
|
||||||
|
self.assertIn('tags', role_meta)
|
||||||
|
|
||||||
|
def test_tags_plugins_meta_migration(self):
|
||||||
|
plugins = self.meta.tables['plugins']
|
||||||
|
query = sa.select([plugins.c.roles_metadata,
|
||||||
|
plugins.c.tags_metadata])
|
||||||
|
for roles_meta, tags_meta in db.execute(query):
|
||||||
|
tags_meta = jsonutils.loads(tags_meta)
|
||||||
|
for role_name, role_meta in six.iteritems(
|
||||||
|
jsonutils.loads(roles_meta)):
|
||||||
|
self.assertEqual(
|
||||||
|
tags_meta[role_name].get('has_primary', False),
|
||||||
|
role_meta.get('has_primary', False)
|
||||||
|
)
|
||||||
|
self.assertIn('tags', role_meta)
|
||||||
|
@ -161,6 +161,12 @@ class TestPluginBase(base.BaseTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
getattr(self.plugin, key), val)
|
getattr(self.plugin, key), val)
|
||||||
|
|
||||||
|
def test_tags_saved_on_plugins_update(self):
|
||||||
|
Plugin.update(self.plugin,
|
||||||
|
{'roles_metadata': self.plugin.roles_metadata})
|
||||||
|
for role, meta in self.plugin.roles_metadata.items():
|
||||||
|
self.assertIn('tags', meta)
|
||||||
|
|
||||||
def test_get_deployment_tasks(self):
|
def test_get_deployment_tasks(self):
|
||||||
dg = DeploymentGraph.get_for_model(self.plugin_adapter.plugin)
|
dg = DeploymentGraph.get_for_model(self.plugin_adapter.plugin)
|
||||||
DeploymentGraph.update(
|
DeploymentGraph.update(
|
||||||
|
Loading…
Reference in New Issue
Block a user