Reset global wsgi app state in unit test

Since I2bd360dcc6501feea7baf02d4510b282205fc061 there is a global state
set during the wsgi_app init making our unit test cases
non-deterministic based on the order of them. This patch makes sure
that the global state is reset for each test case.

Change-Id: Ie2ba746a7697a70fdbc6594f02257f78becfe962
Closes-Bug: #1921098
This commit is contained in:
Balazs Gibizer 2021-03-24 12:04:51 +01:00
parent 83f4514b0a
commit bc2c19bb2d
1 changed files with 5 additions and 0 deletions

View File

@ -53,6 +53,7 @@ from oslotest import mock_fixture
from sqlalchemy.dialects import sqlite from sqlalchemy.dialects import sqlite
import testtools import testtools
from nova.api.openstack import wsgi_app
from nova.compute import rpcapi as compute_rpcapi from nova.compute import rpcapi as compute_rpcapi
from nova import context from nova import context
from nova.db.sqlalchemy import api as sqlalchemy_api from nova.db.sqlalchemy import api as sqlalchemy_api
@ -284,6 +285,10 @@ class TestCase(base.BaseTestCase):
self.useFixture(nova_fixtures.GenericPoisonFixture()) self.useFixture(nova_fixtures.GenericPoisonFixture())
# make sure that the wsgi app is fully initialized for all testcase
# instead of only once initialized for test worker
wsgi_app.init_global_data.reset()
def _setup_cells(self): def _setup_cells(self):
"""Setup a normal cellsv2 environment. """Setup a normal cellsv2 environment.