not mocking openstacksdk exception may cause random non detected errors in unit tests
Bug #1848147 reported by
Riccardo Pittau
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
Low
|
Riccardo Pittau |
Bug Description
Recently added change to ironic notifier plugin migrated the client connection from ironicclient to openstacksdk. The change in the unit tests didn't take into consideration that the openstacksdk exceptions method raise_from_response evaluates the response code as int and this may cause random errors bypassed during tests.
An example can be seen here:
https:/
Important note:
this bug doesn't affect any operational part of the code but just the unit tests.
Changed in neutron: | |
assignee: | nobody → Riccardo Pittau (rpittau) |
status: | New → In Progress |
To post a comment you must log in.
adding the text of the error to the bug to preserve it for posterity
2019-10-11 16:02:02.469156 | ubuntu-bionic | Disabling service 'placement': Encountered an exception attempting to process config for project 'placement' (service type 'placement'): module 'keystoneauth1. loading. adapter' has no attribute 'process_ conf_options'
2019-10-11 16:02:02.471256 | ubuntu-bionic | Error encountered posting the event to ironic. '<' not supported between instances of 'MagicMock' and 'int'
2019-10-11 16:02:02.471319 | ubuntu-bionic | Traceback (most recent call last):
2019-10-11 16:02:02.471417 | ubuntu-bionic | File "/home/ zuul/src/ opendev. org/openstack/ neutron/ neutron/ notifiers/ ironic. py", line 77, in send_events
2019-10-11 16:02:02.471471 | ubuntu-bionic | os_exc. raise_from_ response( response)
2019-10-11 16:02:02.471658 | ubuntu-bionic | File "/home/ zuul/src/ opendev. org/openstack/ neutron/ .tox/lower- constraints/ lib/python3. 6/site- packages/ openstack/ exceptions. py", line 186, in raise_from_response
2019-10-11 16:02:02.471709 | ubuntu-bionic | if response. status_ code < 400:
2019-10-11 16:02:02.471799 | ubuntu-bionic | TypeError: '<' not supported between instances of 'MagicMock' and 'int'
2019-10-11 16:02:02.474934 | ubuntu-bionic | {6} neutron. tests.unit. notifiers. test_ironic. TestIronicNotif ier.test_ send_events [0.025151s] ... ok
2019-10-11 16:02:02.480138 | ubuntu-bionic | {5} neutron. tests.unit. objects. test_network. NetworkDhcpAgen tBindingObjectI faceTestCase. test_create [0.035683s] ... ok