cinder/cinder
Gorka Eguileor e156653d39 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)
(cherry picked from commit 4e472a3e02)
2021-05-06 07:56:32 -04:00
..
api API validation: Add cinder_host type to support ipv6 in manage 2021-03-26 13:33:44 +00:00
backup Merge "Backup manager: Synchronously call remove_export" into stable/ussuri 2021-05-04 14:24:22 +00:00
brick Raise hacking version to 2.0.0 2020-01-02 14:42:49 -06:00
cmd Monkey patch original current_thread _active 2020-05-06 08:44:33 +00:00
common Change default glance_num_retries to 3 2020-10-02 08:00:27 +00:00
compute nova: use EndpointNotFound from keystoneauth1 2019-09-03 10:58:59 -04:00
db Modify default/delete volume type logic 2020-09-16 14:47:10 +00:00
group Continue renaming volume_utils (core) 2019-09-09 20:48:26 -04:00
image Label temporary files created by image_utils 2021-04-13 15:28:48 +00:00
interface Elaborate on terminate_connection documentation 2019-12-04 09:21:15 -06:00
keymgr Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
locale Imported Translations from Zanata 2020-04-26 06:27:45 +00:00
message Add user messages for some volume snapshot actions 2019-04-26 17:02:05 -04:00
objects Fix cross-project incremental backups 2020-07-01 18:20:15 -03:00
policies Correct group:reset_group_snapshot_status policy 2021-01-26 20:40:35 +00:00
privsep Enable flake8-logging-format extension 2020-01-09 14:35:20 -06:00
scheduler Merge "Add filter_function and goodness_function to pools" 2020-04-22 13:24:58 +00:00
tests Fix sporadic cleanup unit test failure 2021-05-06 07:56:32 -04:00
transfer Fix: show volume transfer by name for non-admins 2020-08-28 20:24:37 +00:00
volume Merge "Backup manager: Synchronously call remove_export" into stable/ussuri 2021-05-04 14:24:22 +00:00
wsgi Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
zonemanager Brocade: Fix lookup UnboundLocalError 2020-08-18 11:40:48 +02:00
__init__.py Set EVENTLET_NO_GREENDNS for IPv6 and dnspython compat 2016-11-11 13:19:07 -06:00
context.py Preserve request id in Cinder logs when creating boot volume 2020-03-27 01:10:06 +00:00
coordination.py Remove deprecated heartbeat options 2017-10-03 14:41:18 -05:00
exception.py Modify default/delete volume type logic 2020-09-16 14:47:10 +00:00
flow_utils.py Fix logging traceback in service logs 2016-12-20 12:39:07 +05:30
i18n.py Replace http with https for doc links in cinder 2017-10-17 11:14:01 +08:00
manager.py Merge "Publish backup capabilities to a scheduler" 2020-01-14 19:50:21 +00:00
opts.py Merge "HPE 3PAR: Support duplicated FQDN in network" 2020-04-22 11:33:13 +00:00
policy.py Resolve deprecation of encryption policy target 2020-04-16 10:59:18 -04:00
quota.py Bump hacking version to 1.1.x 2019-05-30 15:06:02 -04:00
quota_utils.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
rpc.py Replace assert to raise AssertionError 2019-06-05 18:41:21 +03:00
service.py Merge "Enable mutate for cinder scheduler" 2020-03-19 14:03:19 +00:00
service_auth.py Add service_token for cinder-nova interaction 2017-12-15 12:04:23 +05:30
ssh_utils.py Stop a connections leak when freeing an SSHPool 2018-02-14 18:16:55 -06:00
test.py Kaminario: Fix unique_fqdn_network option 2020-07-16 03:48:47 -07:00
utils.py Fix "is"/"is not" with a literal usage 2019-11-08 09:39:39 -05:00
version.py