cinder/cinder/tests/unit
Gorka Eguileor 4e472a3e02 Fix sporadic cleanup unit test failure
From time to time we see unit test
test_do_cleanup_not_cleaning_already_claimed_by_us failing at the gate
with error:

    testtools.matchers._impl.MismatchError: 1 != 0

This happens because the test was assuming that the machine running the
code would get different times in consecutive utcnow() calls, which
sometimes is not the case if the machine is fast.

The places where the call is expected to have different values are:

- When the test assigns original_time
- When the test assigns other_thread_claimed_time
- When cinder.manager.CleanableManager.do_cleanup assigns until

This patch fixes this issue by simulating that:

- worker1 entry was created in the past (original_time is T-1)

- db's worker_get_all is mocked to simulate that worker2 entry was
  created in the past (T-1)

- simulate that another thread has picked up the worker2 entry by
  writing a newer time in the DB (other_thread_claimed_time)

- making sure that the do_cleanup method uses a time between these two
  (T)

This way we will no longer rely on the values returned by utcnow().

Change-Id: I45f1a057151e749e8c44f266ec8b41a80761ebec
(cherry picked from commit 1c3cda154f)
2021-04-23 11:57:45 +00:00
..
api Fix: show volume by name for non-admins 2021-04-07 05:27:12 +00:00
attachments Add support volume local cache 2020-09-09 03:42:50 +00:00
backup Add support for RBD fast-diff feature for backups stored in Ceph 2021-03-15 13:48:28 +00:00
brick LVM: Fix delete volume error due to lvs failure 2021-04-01 19:40:47 +00:00
cmd Remove NestedQuotaDriver 2021-01-19 17:43:29 +00:00
compute Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
consistencygroup
db Fix quota usage duplicate entries 2021-04-05 06:21:23 +00:00
group Use resource_backend for volumes and groups 2020-08-14 08:13:42 +00:00
image Support mTLS when calling the glance API 2021-03-22 22:00:44 +00:00
keymgr Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
message Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
monkey_patch_example
objects Fix cross-project incremental backups 2020-05-21 09:38:25 -03:00
policies Import HTTPStatus instead of http_client (policy tests) 2020-10-13 10:00:20 -04:00
scheduler Remove six of dir cinder/tests/unit/policies&scheduler&targets/* 2020-10-08 10:58:09 +08:00
targets Remove six of dir cinder/tests/unit/policies&scheduler&targets/* 2020-10-08 10:58:09 +08:00
volume Merge "Change snapshots type with volume retype" into stable/wallaby 2021-04-05 20:25:36 +00:00
windows smbfs: set VHD UUID using volume UUID 2021-02-18 09:54:58 +02:00
zonemanager Update to hacking 4.0.0 2021-02-16 10:54:51 -05:00
__init__.py
cast_as_call.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
conf_fixture.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
fake_cluster.py
fake_constants.py Default type overrides 2020-09-16 14:05:31 +00:00
fake_group.py
fake_group_snapshot.py
fake_notifier.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
fake_objects.py
fake_service.py Fix migration 112 to use live_data_migration API 2017-10-20 18:24:33 -06:00
fake_snapshot.py Add context to cloning snapshots in remotefs driver 2019-07-10 10:41:15 +02:00
fake_utils.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
fake_volume.py Fix VolumeAttachment is not bound to a Session 2019-03-15 11:29:25 +01:00
policy.yaml [goal] Deprecate the JSON formatted policy file 2020-12-11 18:31:04 -06:00
test.py [goal] Deprecate the JSON formatted policy file 2020-12-11 18:31:04 -06:00
test_api.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_api_urlmap.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_cleanable_manager.py Fix sporadic cleanup unit test failure 2021-04-23 11:57:45 +00:00
test_cmd.py Update to hacking 4.0.0 2021-02-16 10:54:51 -05:00
test_context.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_coordination.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_db_api.py Prevent quota and reservations to go into negative 2021-04-05 06:24:05 +00:00
test_db_worker_api.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_evaluator.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_exception.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_fixtures.py Explicitly set expected log level for tests 2017-11-17 16:58:40 -06:00
test_hacking.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_image_utils.py Support format info in fs type drivers 2021-03-12 12:41:12 -05:00
test_interface.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_manager.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_paginate_query.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_policy.py Make sure we pass context objects directly to policy enforcement 2021-02-17 17:44:40 +00:00
test_qos_specs.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_quota.py Fix quota usage duplicate entries 2021-04-05 06:21:23 +00:00
test_quota_utils.py Remove NestedQuotaDriver 2021-01-19 17:43:29 +00:00
test_rpc.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_service.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_service_auth.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_setup_profiler.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_ssh_utils.py Refactor some unit tests 2020-10-14 11:01:02 +00:00
test_test.py Handle oslo.messaging ping endpoint 2020-09-03 17:04:17 -05:00
test_test_utils.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_utils.py LVM: Fix delete volume error due to lvs failure 2021-04-01 19:40:47 +00:00
test_volume_cleanup.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
test_volume_configuration.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_glance_metadata.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_throttling.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_transfer.py Fix: show volume transfer by name for non-admins 2020-08-03 12:46:31 +00:00
test_volume_types.py Modify default/delete volume type logic 2020-08-19 02:07:15 +00:00
test_volume_types_extra_specs.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_utils.py Move trace methods from utils to volume_utils 2021-02-12 20:16:55 +00:00
utils.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00