4e472a3e02
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
|
||
---|---|---|
.. | ||
compliance | ||
functional | ||
hacking | ||
stubs/oslo_i18n | ||
unit | ||
README.rst | ||
__init__.py | ||
fake_driver.py | ||
fixtures.py |
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.