cinder/cinder/tests
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
..
compliance Fix compliance tests 2020-05-11 14:46:19 -05:00
functional Merge "Remove NestedQuotaDriver" 2021-02-16 16:26:03 +00:00
hacking Remove six of dir cinder/tests/functional&hacking/* 2020-10-08 09:39:49 +08:00
stubs/oslo_i18n Add mypy tox env 2020-10-14 08:24:13 -04:00
unit Fix sporadic cleanup unit test failure 2021-04-23 11:57:45 +00:00
README.rst Update the documentation link 2017-08-26 06:52:48 -07:00
__init__.py
fake_driver.py Move trace methods from utils to volume_utils 2021-02-12 20:16:55 +00:00
fixtures.py Stop to use the __future__ module. 2020-06-11 15:30:09 +02:00

README.rst

IMPORTANT DEFINITION OF TESTS IN CINDER

Cinder has a number of different test types, PLEASE be sure to refer to the Cinder Testing Docs to familiarize yourself with the various options before creating any new tests.

Please check Cinder-Testing.