Don't let openstacksdk run a taskmanager during testing

We have a test thread leak that causes the wait_for_threads() method in
the test suite to timeout and fail tests if they run after
nodepool.tests.test_sdk_integration.TestShadeIntegration.test_nodepool_occ_config.

This happens because that test was invoking the openstack provider
driver with use_taskmanager set to False which causes openstacksdk to
run a taskmanager for us. Unfortunately openstacksdk doesn't know how to
stop that taskmanager for us when the test is done. We fix this by
setting use_taskmanager to True and explicitly adding a test cleanup in
this test that will stop the provider manager (which stops the task
managers).

I know openstacksdk is trying to take on more of this work but we will
need to be careful around this in particular.

Change-Id: I8a72e68e03c85f1e136240ea759909fc8373dc8e
This commit is contained in:
Clark Boylan 2018-10-23 17:13:43 -07:00
parent 3d12962c4f
commit 6fcf494a47
1 changed files with 4 additions and 1 deletions

View File

@ -60,7 +60,10 @@ class TestShadeIntegration(tests.IntegrationTestCase):
config = nodepool_config.loadConfig(configfile)
self.assertIn('real-provider', config.providers)
pm = provider_manager.get_provider(
config.providers['real-provider'], use_taskmanager=False)
config.providers['real-provider'], use_taskmanager=True)
# We need to cleanup the provider manager so that it doesn't leak a
# thread that causes wait_for_threads in subsequent tests to fail.
self.addCleanup(pm.stop)
pm.start(None)
self.assertEqual(pm._client.auth, auth_data)