Fixed missed plugin attributes in deployment info

After Mutable DB fields were introduced the changing of nested data in such
fields leads to saving changes into DB.
Now we can't use Mutable fields for transfer temporary changed data inside
the business logic and all places with implicit using of JSON field for
transferring temporary changed data were removed.
This is the reason of loosing plugins data from the serialized
deployment_info. For fix we are adding cluster plugins attributes into
deployment_info explicitly.

Change-Id: I0807c816c9d3af22a0d7e31f9ce96e974749c525
Closes-Bug: #1544505
This commit is contained in:
Bulat Gaifullin 2016-02-17 20:49:26 +03:00
parent b7fd4cdf7c
commit a5f3cc2a0b
5 changed files with 41 additions and 9 deletions

View File

@ -338,7 +338,7 @@ class Cluster(NailgunObject):
u"No attributes were found for cluster '{0}'"
.format(instance.name)
)
attrs = dict(attrs)
attrs = copy.deepcopy(attrs)
# Merge plugins attributes into editable ones
plugin_attrs = PluginManager.get_plugins_attributes(

View File

@ -107,7 +107,9 @@ class DeploymentMultinodeSerializer(object):
def get_common_attrs(self, cluster):
"""Cluster attributes."""
attrs = objects.Attributes.merged_attrs_values(cluster.attributes)
attrs = objects.Cluster.get_attributes(cluster)
attrs = objects.Attributes.merged_attrs_values(attrs)
release = self.current_release(cluster)
attrs['deployment_mode'] = cluster.mode

View File

@ -511,7 +511,8 @@ class EnvironmentManager(object):
if cluster:
cluster.plugins.append(plugin)
ClusterPlugins.set_attributes(
cluster.id, plugin.id, enabled=enabled
cluster.id, plugin.id, enabled=enabled,
attrs=plugin.attributes_metadata or {}
)
return plugin
@ -932,8 +933,11 @@ class EnvironmentManager(object):
kwargs={'cluster_id': self.clusters[0].id}),
expect_errors=True,
headers=self.default_headers)
self.tester.assertEqual(resp.status_code, expect_http)
if not str(expect_http).startswith("2"):
if isinstance(expect_http, (list, tuple)):
self.tester.assertIn(resp.status_code, expect_http)
else:
self.tester.assertEqual(resp.status_code, expect_http)
if resp.status_code >= 400:
return resp.body
return self.db.query(Task).filter_by(
uuid=resp.json_body['uuid']

View File

@ -423,17 +423,20 @@ class TestDeploymentAttributesSerialization80(
self.env.create_plugin(
cluster=self.cluster_db,
name='plugin_1',
attributes_metadata={'name': 'plugin_1'},
package_version='4.0.0',
fuel_version=['8.0'])
self.env.create_plugin(
cluster=self.cluster_db,
name='plugin_2',
attributes_metadata={'name': 'plugin_2'},
package_version='4.0.0',
fuel_version=['8.0'])
self.env.create_plugin(
cluster=self.cluster_db,
enabled=False,
name='plugin_3',
attributes_metadata={'name': 'plugin_3'},
package_version='4.0.0',
fuel_version=['8.0'])
@ -449,6 +452,31 @@ class TestDeploymentAttributesSerialization80(
self.assertIn('plugins', node)
self.assertItemsEqual(
expected_plugins_list, node['plugins'])
self.assertTrue(all(name in node for name
in expected_plugins_list))
def test_common_attributes_contains_plugin_metadata(self):
expected_value = 'check_value'
plugin = self.env.create_plugin(
cluster=self.cluster_db,
name='test_plugin',
package_version='4.0.0',
fuel_version=['8.0'],
attributes_metadata={
'config': {
'description': "Description",
'weight': 52,
'value': expected_value
}
}
)
attrs = self.serializer.get_common_attrs(self.cluster_db)
self.assertIn('test_plugin', attrs)
self.assertIn('metadata', attrs['test_plugin'])
self.assertEqual(
plugin.id, attrs['test_plugin']['metadata']['plugin_id']
)
self.assertEqual(expected_value, attrs['test_plugin']['config'])
class TestMultiNodeGroupsSerialization80(BaseDeploymentSerializer):

View File

@ -100,10 +100,8 @@ class TestNodeDisksHandlers(BaseIntegrationTest):
"meta": {"disks": disks}
}]
)
self.env.wait_ready(
self.env.launch_deployment())
self.env.wait_ready(
self.env.reset_environment())
self.env.wait_ready(self.env.launch_deployment())
self.env.wait_ready(self.env.reset_environment([200, 202]))
node_db = self.env.nodes[0]