called_with / not_called unit test error under Python 3.12

Bug #2046227 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
In Progress
Undecided
Unassigned

Bug Description

Hi,

Building Cinder under Debian Sid (ie: with Python 3.12 and 3.11) leads to unit test failures as per the stestr stack dump below. Note that as it is well identified as broken tests rather than broken feature, I'm simply blacklisting the tests with no further action in my package.

Also, note that as asyncore is gone from Python 3.12, I had to package pyasyncore (see in pypi) to be able to run Cinder unit tests with Python 3.12 and taskflow.

======================================================================
FAIL: cinder.tests.unit.volume.drivers.solidfire.test_solidfire.SolidFireVolumeTestCase.test_delete_volume
cinder.tests.unit.volume.drivers.solidfire.test_solidfire.SolidFireVolumeTestCase.test_delete_volume
----------------------------------------------------------------------
testtools.testresult.real._StringException: pythonlogging:'': {{{
2023-12-12 10:09:58,056 INFO [keystonemiddleware.auth_token] Starting Keystone auth_token middleware
2023-12-12 10:09:58,057 WARNING [keystonemiddleware._common.config] The option "auth_url" is not known to keystonemiddleware
2023-12-12 10:09:58,057 WARNING [keystonemiddleware.auth_token] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2023-12-12 10:09:58,061 WARNING [keystonemiddleware.auth_token] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2023-12-12 10:09:58,069 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()

2023-12-12 10:09:58,072 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()

2023-12-12 10:09:58,075 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()

2023-12-12 10:09:58,079 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()
}}}

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py", line 967, in test_delete_volume
    rem_vol.not_called(get_vol_result['volumeID'])
    ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/unittest/mock.py", line 663, in __getattr__
    raise AttributeError(
AttributeError: 'not_called' is not a valid assertion. Use a spec for the mock if 'not_called' is meant to be an attribute.

======================================================================
FAIL: cinder.tests.unit.volume.drivers.netapp.dataontap.test_nfs_base.NetAppNfsDriverTestCase.test_create_cloned_volume_2_False
cinder.tests.unit.volume.drivers.netapp.dataontap.test_nfs_base.NetAppNfsDriverTestCase.test_create_cloned_volume_2_False
----------------------------------------------------------------------
testtools.testresult.real._StringException: pythonlogging:'': {{{
2023-12-12 10:09:58,485 INFO [keystonemiddleware.auth_token] Starting Keystone auth_token middleware
2023-12-12 10:09:58,486 WARNING [keystonemiddleware._common.config] The option "auth_url" is not known to keystonemiddleware
2023-12-12 10:09:58,487 WARNING [keystonemiddleware.auth_token] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2023-12-12 10:09:58,488 WARNING [keystonemiddleware.auth_token] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2023-12-12 10:09:58,503 WARNING [cinder.volume.drivers.netapp.utils] It is not the recommended way to use drivers by NetApp. Please use NetAppDriver to achieve the functionality.
}}}

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ddt.py", line 220, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/<<PKGBUILDDIR>>/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py", line 334, in test_create_cloned_volume
    mock_super_create.not_called()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/unittest/mock.py", line 663, in __getattr__
    raise AttributeError(
AttributeError: 'not_called' is not a valid assertion. Use a spec for the mock if 'not_called' is meant to be an attribute.

======================================================================
FAIL: cinder.tests.unit.volume.drivers.netapp.dataontap.test_nfs_base.NetAppNfsDriverTestCase.test_create_volume_from_snapshot_2_False
cinder.tests.unit.volume.drivers.netapp.dataontap.test_nfs_base.NetAppNfsDriverTestCase.test_create_volume_from_snapshot_2_False
----------------------------------------------------------------------
testtools.testresult.real._StringException: pythonlogging:'': {{{
2023-12-12 10:09:58,714 INFO [keystonemiddleware.auth_token] Starting Keystone auth_token middleware
2023-12-12 10:09:58,715 WARNING [keystonemiddleware._common.config] The option "auth_url" is not known to keystonemiddleware
2023-12-12 10:09:58,715 WARNING [keystonemiddleware.auth_token] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2023-12-12 10:09:58,716 WARNING [keystonemiddleware.auth_token] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2023-12-12 10:09:58,725 WARNING [cinder.volume.drivers.netapp.utils] It is not the recommended way to use drivers by NetApp. Please use NetAppDriver to achieve the functionality.
}}}

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ddt.py", line 220, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/<<PKGBUILDDIR>>/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py", line 302, in test_create_volume_from_snapshot
    mock_super_create.not_called()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/unittest/mock.py", line 663, in __getattr__
    raise AttributeError(
AttributeError: 'not_called' is not a valid assertion. Use a spec for the mock if 'not_called' is meant to be an attribute.

======================================================================
FAIL: cinder.tests.unit.volume.drivers.solidfire.test_solidfire.SolidFireVolumeTestCase.test_failover_host
cinder.tests.unit.volume.drivers.solidfire.test_solidfire.SolidFireVolumeTestCase.test_failover_host
----------------------------------------------------------------------
testtools.testresult.real._StringException: pythonlogging:'': {{{
2023-12-12 10:10:00,361 INFO [keystonemiddleware.auth_token] Starting Keystone auth_token middleware
2023-12-12 10:10:00,364 WARNING [keystonemiddleware._common.config] The option "auth_url" is not known to keystonemiddleware
2023-12-12 10:10:00,364 WARNING [keystonemiddleware.auth_token] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2023-12-12 10:10:00,366 WARNING [keystonemiddleware.auth_token] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2023-12-12 10:10:00,376 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()

2023-12-12 10:10:00,383 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()

2023-12-12 10:10:00,389 WARNING [py.warnings] /usr/lib/python3/dist-packages/oslo_utils/timeutils.py:140: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  return datetime.datetime.utcnow()
}}}

Traceback (most recent call last):
  File "/usr/lib/python3.12/unittest/mock.py", line 1387, in patched
    return func(*newargs, **newkeywargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/<<PKGBUILDDIR>>/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py", line 3229, in test_failover_host
    mock_failover.called_with(fake_context, fake_cinder_vols, "secondary",
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/unittest/mock.py", line 663, in __getattr__
    raise AttributeError(
AttributeError: 'called_with' is not a valid assertion. Use a spec for the mock if 'called_with' is meant to be an attribute.

Tags: tests
Eric Harney (eharney)
tags: added: tests
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/903503

Changed in cinder:
status: New → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.