Insufficient mocking in TestGenericHardwareManager
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ironic-python-agent |
Fix Released
|
Medium
|
Boushra Sondos Bettir |
Bug Description
When running unit tests, the unit tests are relying on local machine state to pass during the GenericHardware
IMO, these methods should be mocked to return true, similarly to how _is_linux_
https:/
Output from an example failing test on a machine with a read-only /dev/sda:
ironic_
-------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/usr/lib/
return func(*newargs, **newkeywargs)
File "/home/
self.
File "/home/
raise errors.
ironic_
Captured pythonlogging:
~~~~~~~
ERROR [root] Failed to invoke erase of device /dev/sda as the device is flagged read-only, and the conductor has not signaled this is a permitted case.
This issue was found by a new contributor, Boushra, attempting to run unit tests on WSL. It is trivially reproducible in an Ubuntu Jammy WSL terminal.
Changed in ironic-python-agent: | |
status: | New → Triaged |
importance: | Undecided → Medium |
tags: | added: low-hanging-fruit |
Changed in ironic-python-agent: | |
status: | Triaged → Fix Committed |
status: | Fix Committed → Fix Released |
Noticing some more errors that may definitely be a WSL issue:
``` python_ agent.tests. unit.test_ hardware. TestGenericHard wareManager. test_erase_ devices_ metadata ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -
ironic_
-------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/usr/lib/ python3. 10/unittest/ mock.py" , line 1379, in patched
return func(*newargs, **newkeywargs)
File "/home/ bbgoddess/ mlh-gresearch/ ironic- python- agent/ironic_ python_ agent/tests/ unit/test_ hardware. py", line 2422, in test_erase_ devices_ metadata assertEqual( [mock.call( '/dev/sda1' , self.node['uuid']),
self.
File "/home/ bbgoddess/ mlh-gresearch/ ironic- python- agent/. tox/py3/ lib/python3. 10/site- packages/ testtools/ testcase. py", line 394, in assertEqual assertThat( observed, matcher, message)
self.
File "/home/ bbgoddess/ mlh-gresearch/ ironic- python- agent/. tox/py3/ lib/python3. 10/site- packages/ testtools/ testcase. py", line 481, in assertThat
raise mismatch_error
testtools. matchers. _impl.MismatchE rror: !=: 732d-4742- 8e72-df8f3199d2 44'), 732d-4742- 8e72-df8f3199d2 44'), 732d-4742- 8e72-df8f3199d2 44')] 732d-4742- 8e72-df8f3199d2 44')]
reference = [call('/dev/sda1', 'dda135fb-
call('/dev/sda', 'dda135fb-
call('/dev/md0', 'dda135fb-
actual = [call('/dev/md0', 'dda135fb-
Captured pythonlogging: ~~~~~~~ ~~~~~~~ ~~
~~~~~~~
WARNING [root] Could not determine if /dev/md0 is aread-only device. Error: [Errno 2] No such file or directory: '/sys/block/md/ro'
```
There are about 20 that are similar to this. Since this is all under the hood of the same core issue of WSL, I'll take a look at it.