cinder/cinder
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
backup Merge "Backup manager: Synchronously call remove_export" 2021-03-25 17:00:42 +00:00
brick LVM: Fix delete volume error due to lvs failure 2021-04-01 19:40:47 +00:00
cmd Update cinder manage quota commands 2021-04-05 06:22:33 +00:00
common Support mTLS when calling the glance API 2021-03-22 22:00:44 +00:00
compute nova: use EndpointNotFound from keystoneauth1 2019-09-03 10:58:59 -04:00
db Quota: Fix multiple race conditions 2021-04-05 06:25:50 +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
interface Add explanations on safe delete 2021-03-17 14:04:20 +01:00
keymgr Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
locale Imported Translations from Zanata 2021-03-24 06:25:01 +00:00
message Add user messages for some volume snapshot actions 2019-04-26 17:02:05 -04:00
objects Fix volume OVO create method 2021-03-17 13:07:09 +01:00
policies Simplify composite check strings for project personas 2021-02-17 17:44:40 +00:00
privsep Enable flake8-logging-format extension 2020-01-09 14:35:20 -06:00
scheduler Remove six of dir cinder/scheduler/* 2020-10-08 08:36:17 +08:00
tests Fix sporadic cleanup unit test failure 2021-04-23 11:57:45 +00:00
transfer Fix: show volume transfer by name for non-admins 2020-08-03 12:46:31 +00:00
volume Merge "LVM: Fix delete volume error due to lvs failure" into stable/wallaby 2021-04-07 02:10:15 +00:00
wsgi Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
zonemanager Brocade: Fix lookup UnboundLocalError 2020-08-07 15:24:44 +02:00
__init__.py
context.py mypy: annotate volume manager 2021-02-10 12:27:47 -05:00
coordination.py Remove deprecated heartbeat options 2017-10-03 14:41:18 -05:00
exception.py Merge "Remove NestedQuotaDriver" 2021-02-16 16:26:03 +00:00
flow_utils.py
i18n.py Replace http with https for doc links in cinder 2017-10-17 11:14:01 +08:00
manager.py mypy: annotate volume manager 2021-02-10 12:27:47 -05:00
opts.py Merge "Update code layout and missing Zadara features" 2021-03-19 19:00:48 +00:00
policy.py Merge "Make sure we pass context objects directly to policy enforcement" 2021-03-07 00:07:42 +00:00
quota.py Remove nested quota leftovers 2021-04-05 06:19:07 +00:00
quota_utils.py Change snapshots type with volume retype 2021-04-01 12:08:03 +02:00
rpc.py Remove six in files under cinder/* 2020-10-08 14:00:14 +08:00
service.py Fix typo on service cluster change method 2020-05-06 19:36:07 -05:00
service_auth.py Add service_token for cinder-nova interaction 2017-12-15 12:04:23 +05:30
ssh_utils.py Remove six in files under cinder/* 2020-10-08 14:00:14 +08:00
utils.py LVM: Fix delete volume error due to lvs failure 2021-04-01 19:40:47 +00:00
version.py