← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1930653] [NEW] test_refresh_associations_time fails intermittently

 

Public bug reported:

Noticed in the gate, test_refresh_associations_time failed with the
following trace:

ft1.1: nova.tests.unit.scheduler.client.test_report.TestAssociations.test_refresh_associations_timetesttools.testresult.real._StringException: pythonlogging:'': {{{
2021-06-02 18:09:44,145 WARNING [oslo_policy.policy] JSON formatted policy_file support is deprecated since Victoria release. You need to use YAML format which will be default in future. You can use ``oslopolicy-convert-json-to-yaml`` tool to convert existing JSON-formatted policy file to YAML-formatted in backward compatible way: https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html.
2021-06-02 18:09:44,172 WARNING [oslo_policy.policy] JSON formatted policy_file support is deprecated since Victoria release. You need to use YAML format which will be default in future. You can use ``oslopolicy-convert-json-to-yaml`` tool to convert existing JSON-formatted policy file to YAML-formatted in backward compatible way: https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html.
2021-06-02 18:09:44,190 WARNING [oslo_policy.policy] Policy Rules ['os_compute_api:extensions', 'os_compute_api:os-floating-ip-pools', 'os_compute_api:os-quota-sets:defaults', 'os_compute_api:os-availability-zone:list', 'os_compute_api:limits', 'system_admin_api', 'system_reader_api', 'project_admin_api', 'project_member_api', 'project_reader_api', 'system_admin_or_owner', 'system_or_project_reader', 'os_compute_api:limits:other_project', 'os_compute_api:os-lock-server:unlock:unlock_override', 'os_compute_api:servers:create:zero_disk_flavor', 'compute:servers:resize:cross_cell'] specified in policy files are the same as the defaults provided by the service. You can remove these rules from policy files which will make maintenance easier. You can detect these redundant rules by ``oslopolicy-list-redundant`` tool also.
}}}

Traceback (most recent call last):
  File "/home/zuul/src/opendev.org/openstack/nova/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 1346, in patched
    return func(*newargs, **newkeywargs)
  File "/home/zuul/src/opendev.org/openstack/nova/nova/tests/unit/scheduler/client/test_report.py", line 3146, in test_refresh_associations_time
    self.assert_getters_were_called(uuid)
  File "/home/zuul/src/opendev.org/openstack/nova/nova/tests/unit/scheduler/client/test_report.py", line 3047, in assert_getters_were_called
    self.mock_get_inv.assert_called_once_with(self.context, uuid)
  File "/home/zuul/src/opendev.org/openstack/nova/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 925, in assert_called_once_with
    raise AssertionError(msg)
AssertionError: Expected '_get_inventory' to be called once. Called 0 times.


I found this is because though most of the use of time.time() in the refresh associations code was mocked in the test, there is one spot where it is not mocked and if the test happens to run slowly, the delta between the recorded "now" and the refresh run timestamp will be larger than expected and cause the test assertion to fail.

I think this can be fixed by mocking the remaining call of time.time().

** Affects: nova
     Importance: Undecided
     Assignee: melanie witt (melwitt)
         Status: Triaged


** Tags: testing

-- 
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/1930653

Title:
  test_refresh_associations_time fails intermittently

Status in OpenStack Compute (nova):
  Triaged

Bug description:
  Noticed in the gate, test_refresh_associations_time failed with the
  following trace:

  ft1.1: nova.tests.unit.scheduler.client.test_report.TestAssociations.test_refresh_associations_timetesttools.testresult.real._StringException: pythonlogging:'': {{{
  2021-06-02 18:09:44,145 WARNING [oslo_policy.policy] JSON formatted policy_file support is deprecated since Victoria release. You need to use YAML format which will be default in future. You can use ``oslopolicy-convert-json-to-yaml`` tool to convert existing JSON-formatted policy file to YAML-formatted in backward compatible way: https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html.
  2021-06-02 18:09:44,172 WARNING [oslo_policy.policy] JSON formatted policy_file support is deprecated since Victoria release. You need to use YAML format which will be default in future. You can use ``oslopolicy-convert-json-to-yaml`` tool to convert existing JSON-formatted policy file to YAML-formatted in backward compatible way: https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html.
  2021-06-02 18:09:44,190 WARNING [oslo_policy.policy] Policy Rules ['os_compute_api:extensions', 'os_compute_api:os-floating-ip-pools', 'os_compute_api:os-quota-sets:defaults', 'os_compute_api:os-availability-zone:list', 'os_compute_api:limits', 'system_admin_api', 'system_reader_api', 'project_admin_api', 'project_member_api', 'project_reader_api', 'system_admin_or_owner', 'system_or_project_reader', 'os_compute_api:limits:other_project', 'os_compute_api:os-lock-server:unlock:unlock_override', 'os_compute_api:servers:create:zero_disk_flavor', 'compute:servers:resize:cross_cell'] specified in policy files are the same as the defaults provided by the service. You can remove these rules from policy files which will make maintenance easier. You can detect these redundant rules by ``oslopolicy-list-redundant`` tool also.
  }}}

  Traceback (most recent call last):
    File "/home/zuul/src/opendev.org/openstack/nova/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 1346, in patched
      return func(*newargs, **newkeywargs)
    File "/home/zuul/src/opendev.org/openstack/nova/nova/tests/unit/scheduler/client/test_report.py", line 3146, in test_refresh_associations_time
      self.assert_getters_were_called(uuid)
    File "/home/zuul/src/opendev.org/openstack/nova/nova/tests/unit/scheduler/client/test_report.py", line 3047, in assert_getters_were_called
      self.mock_get_inv.assert_called_once_with(self.context, uuid)
    File "/home/zuul/src/opendev.org/openstack/nova/.tox/py38/lib/python3.8/site-packages/mock/mock.py", line 925, in assert_called_once_with
      raise AssertionError(msg)
  AssertionError: Expected '_get_inventory' to be called once. Called 0 times.

  
  I found this is because though most of the use of time.time() in the refresh associations code was mocked in the test, there is one spot where it is not mocked and if the test happens to run slowly, the delta between the recorded "now" and the refresh run timestamp will be larger than expected and cause the test assertion to fail.

  I think this can be fixed by mocking the remaining call of
  time.time().

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


Follow ups