nova/nova/tests/unit/db
Matthew Booth f9c2503609 Fix retry of instance_update_and_get_original
_instance_update modifies its 'values' argument. Consequently if it is
retried due to an update conflict, the second invocation has the wrong
arguments.

A specific issue this causes is that if we called it with
expected_task_state a concurrent modification to task_state will cause
us to fail and retry. However, expected_task_state will have been popped
from values on the first invocation and will not be present for the
second. Consequently the second invocation will fail to perform the
task_state check and therefore succeed, resulting in a race.

We rewrite the old race unit test which wasn't testing the correct
thing for 2 reasons:

1. Due to the bug fixed in this patch, although we were calling
   update_on_match() twice, the second call didn't check the task state.
2. side_effect=iterable returns function items without executing them,
   but we weren't hitting this due to the bug fixed in this patch.

Closes-Bug: #1821373
Change-Id: I01c63e685113bf30e687ccb14a4d18e344b306f6
(cherry picked from commit aae5c7aa38)
(cherry picked from commit 61fef49b15)
(cherry picked from commit 4540cd6ef9)
2019-05-20 11:57:50 +01:00
..
__init__.py move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
fakes.py Add Flavor.description attribute 2017-11-05 01:24:01 -05:00
test_db_api.py Fix retry of instance_update_and_get_original 2019-05-20 11:57:50 +01:00
test_migration_utils.py Replaces uuid.uuid4 with uuidutils.generate_uuid() 2017-07-25 10:45:03 +05:30
test_migrations.py Add index(instance_uuid, updated_at) on instance_actions table 2018-01-22 01:34:20 +00:00
test_models.py Test that new tables don't use soft deletes 2016-02-04 09:21:31 -05:00
test_sqlalchemy_migration.py Add Flavor.description attribute 2017-11-05 01:24:01 -05:00