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: I937bb581f61034d027b28a8e4fd5b42a35fcd7f6 Closes-Bug: #1655264
This commit is contained in:
parent
ca498021fd
commit
6b4d6acac1
|
@ -130,6 +130,8 @@ class Plugin(NailgunObject):
|
|||
graphs[graph.pop('type')] = graph
|
||||
|
||||
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)
|
||||
|
||||
for graph_type, graph_data in six.iteritems(graphs):
|
||||
|
|
|
@ -481,6 +481,32 @@ 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()
|
||||
|
||||
|
||||
|
@ -604,7 +630,7 @@ class TestTags(base.BaseAlembicMigrationTest):
|
|||
primary_tags = db.execute(query).fetchone()[0]
|
||||
self.assertItemsEqual(primary_tags, ['controller'])
|
||||
|
||||
def test_tags_meta_migration(self):
|
||||
def test_tags_releases_meta_migration(self):
|
||||
releases = self.meta.tables['releases']
|
||||
query = sa.select([releases.c.roles_metadata,
|
||||
releases.c.tags_metadata])
|
||||
|
@ -616,6 +642,21 @@ class TestTags(base.BaseAlembicMigrationTest):
|
|||
tags_meta[role_name].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)
|
||||
|
||||
def test_tags_migration_for_supported_releases(self):
|
||||
releases = self.meta.tables['releases']
|
||||
|
|
|
@ -160,6 +160,12 @@ class TestPluginBase(base.BaseTestCase):
|
|||
self.assertEqual(
|
||||
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):
|
||||
dg = DeploymentGraph.get_for_model(self.plugin_adapter.plugin)
|
||||
DeploymentGraph.update(
|
||||
|
|
Loading…
Reference in New Issue