From 6fcf494a47f6c68b34e3cc3640bacab2064aa3ee Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 23 Oct 2018 17:13:43 -0700 Subject: [PATCH] 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 --- nodepool/tests/test_sdk_integration.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nodepool/tests/test_sdk_integration.py b/nodepool/tests/test_sdk_integration.py index 5208da0bc..97dfb748d 100644 --- a/nodepool/tests/test_sdk_integration.py +++ b/nodepool/tests/test_sdk_integration.py @@ -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)