Tests for 'NetworkConfigurationValidator. prepare_data' fail from time to time

Bug #1511725 reported by deactivateduser
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
High
Ihor Kalnytskyi

Bug Description

Unit tests for 'NetworkConfigurationValidator. prepare_data' fail time to time. Here's the partial log taken from CI:

2015-10-30 12:48:40.986 | TestNetworkConfigurationValidatorProtocol.test_networks_required_property_network_id
2015-10-30 12:48:40.987 | [gw1] linux2 -- Python 2.7.6 /home/jenkins/workspace/gate-fuel-web-python27/.tox/py27/bin/python2.7
2015-10-30 12:48:40.987 | self = <nailgun.test.unit.test_network_configuration_validator.TestNetworkConfigurationValidatorProtocol testMethod=test_networks_required_property_network_id>
2015-10-30 12:48:40.987 |
2015-10-30 12:48:40.987 | def test_networks_required_property_network_id(self):
2015-10-30 12:48:40.987 | self.nc['networks'][0].pop('id')
2015-10-30 12:48:40.987 | > self.assertRaisesRequiredProperty(self.nc, 'id')
2015-10-30 12:48:40.987 |
2015-10-30 12:48:40.987 | nailgun/test/unit/test_network_configuration_validator.py:97:
2015-10-30 12:48:40.988 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2015-10-30 12:48:40.988 | nailgun/test/base.py:1571: in assertRaisesRequiredProperty
2015-10-30 12:48:40.988 | context = self.get_invalid_data_context(obj)
2015-10-30 12:48:40.988 | ../.tox/py27/local/lib/python2.7/site-packages/mock.py:1201: in patched
2015-10-30 12:48:40.988 | return func(*args, **keywargs)
2015-10-30 12:48:40.988 | nailgun/test/unit/test_network_configuration_validator.py:42: in get_invalid_data_context
2015-10-30 12:48:40.988 | get_invalid_data_context(data, args[0])
2015-10-30 12:48:40.988 | nailgun/test/base.py:1555: in get_invalid_data_context
2015-10-30 12:48:40.989 | self.validator(serialized_data, *args)
2015-10-30 12:48:40.989 | nailgun/api/v1/validators/network.py:44: in validate_networks_data
2015-10-30 12:48:40.989 | data = cls.base_validation(data)
2015-10-30 12:48:40.989 | nailgun/api/v1/validators/network.py:38: in base_validation
2015-10-30 12:48:40.989 | valid_data = cls.prepare_data(valid_data)
2015-10-30 12:48:40.989 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2015-10-30 12:48:40.989 |
2015-10-30 12:48:40.989 | cls = <class 'nailgun.api.v1.validators.network.NetworkConfigurationValidator'>
2015-10-30 12:48:40.989 | data = {'networks': [{'cidr': '172.16.0.0/24', 'gateway': '172.16.0.1', 'group_id': 1, 'ip_ranges': [['172.16.0.2', '172.16.0.126']], ...}]}
2015-10-30 12:48:40.990 |
2015-10-30 12:48:40.990 | @classmethod
2015-10-30 12:48:40.990 | def prepare_data(cls, data):
2015-10-30 12:48:40.990 | """Prepares input data.
2015-10-30 12:48:40.990 |
2015-10-30 12:48:40.990 | Filter input data based on the fact that
2015-10-30 12:48:40.990 | updating parameters of the fuel admin network
2015-10-30 12:48:40.990 | is forbidden for default node group.
2015-10-30 12:48:40.990 |
2015-10-30 12:48:40.990 | Admin network cannot be updated because of:
2015-10-30 12:48:40.991 | - sharing itself between environments;
2015-10-30 12:48:40.991 | - having no mechanism to change its parameters on deployed Master node.
2015-10-30 12:48:40.991 | """
2015-10-30 12:48:40.991 | if data.get("networks"):
2015-10-30 12:48:40.991 | default_admin = db.query(
2015-10-30 12:48:40.991 | NetworkGroup).filter_by(group_id=None).first()
2015-10-30 12:48:40.991 | data["networks"] = [
2015-10-30 12:48:40.991 | n for n in data["networks"]
2015-10-30 12:48:40.991 | > if n.get("id") != default_admin.id
2015-10-30 12:48:40.991 | ]
2015-10-30 12:48:40.991 | E AttributeError: 'NoneType' object has no attribute 'id'

Full console output can be found in the attachment.

Revision history for this message
deactivateduser (deactivateduser-deactivatedaccount) wrote :
Changed in mos:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Ihor Kalnytskyi (ikalnytskyi) wrote :

The problem is that tests don't prepare DB state before running validator. In this particular case we rely on default (shared) admin network existance in the database, but it may not exist. It depends on test order.

Changed in mos:
assignee: Fuel Python Team (fuel-python) → Igor Kalnitsky (ikalnitsky)
tags: added: area-python
removed: tricky
Changed in mos:
status: Confirmed → Triaged
Dmitry Pyzhov (dpyzhov)
tags: added: tech-debt
Changed in fuel:
status: New → Triaged
importance: Undecided → High
assignee: nobody → Igor Kalnitsky (ikalnitsky)
milestone: none → 8.0
no longer affects: mos
Revision history for this message
Ihor Kalnytskyi (ikalnytskyi) wrote :

The patch was landed to master - https://review.openstack.org/#/c/240588/

Move it to Fix Commited.

Changed in fuel:
status: Triaged → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.