Reviewed:  https://review.opendev.org/c/openstack/nova/+/794396
Committed: 
https://opendev.org/openstack/nova/commit/7b11409463de6efedab54aa0dcd0b9c423521c0a
Submitter: "Zuul (22348)"
Branch:    master

commit 7b11409463de6efedab54aa0dcd0b9c423521c0a
Author: melanie witt <[email protected]>
Date:   Thu Jun 3 04:58:17 2021 +0000

    Make test_refresh_associations_* deterministic
    
    There are two tests: test_refresh_associations_time and
    test_refresh_associations_disabled which override time.time() in most
    places to assert behaviors depending on elapsed time, however there is
    one place where it is not overridden and if the test happens to run
    slowly in the gate, the delta between the recorded "now" timestamp and
    the refresh run timestamp will be larger than expected and cause the
    test assertion to fail.
    
    Closes-Bug: #1930653
    
    Change-Id: I926aeec0c7d684f426c6b9936e6693621e0b9937


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

Title:
  test_refresh_associations_time fails intermittently

Status in OpenStack Compute (nova):
  Fix Released

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

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to