Comment 0 for bug 1520626

Revision history for this message
Ilya Kharin (akscram) wrote :

This test fails periodically with error:

    ___ TestClusterObjectGetRoles.test_plugin_role_conflict_with_plugin_and_core ___
    [gw3] linux2 -- Python 2.7.6 /home/jenkins/workspace/gate-fuel-web-py27/nailgun/.tox/py27/bin/python2.7
    self = <nailgun.test.unit.test_objects.TestClusterObjectGetRoles testMethod=test_plugin_role_conflict_with_plugin_and_core>

        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'

    nailgun/test/unit/test_objects.py:1408: AssertionError

It seems that the objects.ClusterPlugins.set_attributes method does not synchronize objects in the session.