]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix test isolation issues related to versions
authorGorka Eguileor <geguileo@redhat.com>
Wed, 2 Mar 2016 12:23:31 +0000 (13:23 +0100)
committerGorka Eguileor <geguileo@redhat.com>
Wed, 2 Mar 2016 14:16:22 +0000 (15:16 +0100)
In cinder.rpc.RPCAPI methods _determine_rpc_version_cap and
_determine_obj_version_cap use global variables LAST_RPC_VERSIONS and
LAST_OBJ_VERSIONS to cache version values so we need to clear these
values between tests so one test values don't get passed to the next
test.

This was problematic for example when running some
cinder.tests.unit.api.contrib tests in a specific order:

- test_admin_actions.AdminActionsTest.test_delete_backup_force_when_creating
- test_backups.BackupsAPITestCase.test_create_backup_snapshot_json

Change-Id: I073557a6e0a17a3e00fd32d48d389a3bcf42e341

cinder/test.py

index 1d2d01c35abf51fe20a76b9f15c663de63be476f..0fdb1efd03ad4e78e7128e659fef86dfdc4c8899 100644 (file)
@@ -188,6 +188,14 @@ class TestCase(testtools.TestCase):
         self.useFixture(self.messaging_conf)
         rpc.init(CONF)
 
+        # NOTE(geguileo): This is required because _determine_obj_version_cap
+        # and _determine_rpc_version_cap functions in cinder.rpc.RPCAPI cache
+        # versions in LAST_RPC_VERSIONS and LAST_OBJ_VERSIONS so we may have
+        # weird interactions between tests if we don't clear them before each
+        # test.
+        rpc.LAST_OBJ_VERSIONS = {}
+        rpc.LAST_RPC_VERSIONS = {}
+
         conf_fixture.set_defaults(CONF)
         CONF([], default_config_files=[])