def test_plugin_role_conflict_with_plugin_and_core(self): self.create_plugin({ 'role_x': { 'name': 'Role X', 'description': 'Role X is ...', },
}) plugin_in_conflict = self.create_plugin({ 'role_x': { 'name': 'Role Y', 'description': 'Role Y is ...', }, 'role_a': { 'name': 'Role A', 'description': 'Role A is ...', },
})
message_pattern = ( '^Plugin \(ID={0}\) is unable to register the following node ' 'roles: (.*)' .format(plugin_in_conflict.id))
with self.assertRaisesRegexp( errors.AlreadyExists, message_pattern) as cm: objects.Cluster.get_roles(self.cluster)
# 0 - the whole message, 1 - is first match of (.*) pattern
roles = re.match(message_pattern, str(cm.exception)).group(1)
roles = [role.lstrip().rstrip() for role in roles.split(',')]
> self.assertItemsEqual(roles, ['role_x', 'role_a'])
E AssertionError: Element counts were not equal:
E First has 0, Second has 1: 'role_x'
This test fails periodically with error:
___ TestClusterObje ctGetRoles. test_plugin_ role_conflict_ with_plugin_ and_core ___ workspace/ gate-fuel- web-py27/ nailgun/ .tox/py27/ bin/python2. 7 test.unit. test_objects. TestClusterObje ctGetRoles testMethod= test_plugin_ role_conflict_ with_plugin_ and_core>
[gw3] linux2 -- Python 2.7.6 /home/jenkins/
self = <nailgun.
def test_plugin_ role_conflict_ with_plugin_ and_core( self):
self. create_ plugin( {
'role_ x': {
' name': 'Role X', 'description': 'Role X is ...', },
plugin_ in_conflict = self.create_ plugin( {
'role_ x': {
' name': 'Role Y', 'description': 'Role Y is ...', },
'role_ a': {
' name': 'Role A', 'description': 'Role A is ...', },
})
})
with self.assertRais esRegexp(
errors. AlreadyExists, message_pattern) as cm:
objects. Cluster. get_roles( self.cluster)
# 0 - the whole message, 1 - is first match of (.*) pattern message_ pattern, str(cm. exception) ).group( 1) ).rstrip( ) for role in roles.split(',')]
roles = re.match(
roles = [role.lstrip(
> self.assertItem sEqual( roles, ['role_x', 'role_a'])
E AssertionError: Element counts were not equal:
E First has 0, Second has 1: 'role_x'
nailgun/ test/unit/ test_objects. py:1408: AssertionError
It seems that the objects. ClusterPlugins. set_attributes method does not synchronize objects in the session.