← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1887735] Re: nova.tests.unit.console.test_websocketproxy. NovaProxyRequestHandlerTestCase.test_tcp_rst_no_compute_rpcapi fails with mock==4.0.2

 

Fixed by https://review.opendev.org/c/openstack/nova/+/741351

** Changed in: nova
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1887735

Title:
  nova.tests.unit.console.test_websocketproxy.
  NovaProxyRequestHandlerTestCase.test_tcp_rst_no_compute_rpcapi fails
  with mock==4.0.2

Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  Seen in a proposed patch to update upper-constraints in
  openstack/requirements [1]:

  
  nova.tests.unit.console.test_websocketproxy.NovaProxyRequestHandlerTestCase.test_tcp_rst_no_compute_rpcapitesttools.testresult.real._StringException: pythonlogging:'': {{{
  2020-07-15 21:09:49,927 INFO [nova.console.websocketproxy] WebSocket server settings:
  2020-07-15 21:09:49,928 INFO [nova.console.websocketproxy]   - Listen on :None
  2020-07-15 21:09:49,928 INFO [nova.console.websocketproxy]   - SSL/TLS support
  2020-07-15 21:09:49,932 INFO [nova.console.websocketproxy] handler exception: Expected int or long, got <class 'mock.mock.MagicMock'>
  }}}

  Traceback (most recent call last):
    File "/home/zuul/src/opendev.org/openstack/nova/nova/tests/unit/console/test_websocketproxy.py", line 627, in test_tcp_rst_no_compute_rpcapi
      self.assertIsNone(self.wh._compute_rpcapi)
    File "/home/zuul/src/opendev.org/openstack/nova/.tox/py36/lib/python3.6/site-packages/testtools/testcase.py", line 430, in assertIsNone
      self.assertThat(observed, matcher, message)
    File "/home/zuul/src/opendev.org/openstack/nova/.tox/py36/lib/python3.6/site-packages/testtools/testcase.py", line 502, in assertThat
      raise mismatch_error
  testtools.matchers._impl.MismatchError: <nova.compute.rpcapi.ComputeAPI object at 0x7ff4113810f0> is not None

  
  I did some print()ing locally and found that what's happening here is that the mock library's own process for create_autospec is calling the NovaProxyRequestHandler class's compute_rpcapi @property directly and causing us to create the nova.compute.rpcapi.ComputeAPI object even though none of the nova code is touching it.

  This bug has actually been brought up before as an issue in the mock
  library repo [2] and is likely a bug in mock.

  The mock library is minimally maintained AFAIK and the community has
  desired to move away from it. Based on this, I think instead of
  working around the bug in nova or potentially blacklisting mock==4.0.2
  (since nova is the only project failing with its use at this point),
  it might best to fix the issue by using unittest.mock from the python
  standard library instead, in test_websocketproxy.py.

  [1] https://review.opendev.org/741091
  [2] https://github.com/testing-cabal/mock/issues/487

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1887735/+subscriptions



References