Only call register_service_clients if there are clients

Right now we unconditionally run register_service_clients() on each
plugin regardless of whether there are any clients or not. This can lead
to false tracebacks being logged if there is any error reported in the
call path, regardless of whether the plugin is at fault or not. To
avoid this potential confusion this commit changes the registry call to
only occur if there are any clients we actually want to register. If
there aren't any we just skip that plugin.

Change-Id: I526d4acd99bbcfbf27c4090391f341bc61fdb194
Matthew Treinish 2016-10-04 13:04:52 -04:00
parent 4db514cc01
commit 00c72b90f6
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
2 changed files with 5 additions and 5 deletions

View File

@ -157,8 +157,10 @@ class TempestTestPluginManager(object):
registry = clients.ClientsRegistry()
for plug in self.ext_plugins:
registry.register_service_client(, plug.obj.get_service_clients())
service_clients = plug.obj.get_service_clients()
if service_clients:
registry.register_service_client(, service_clients)
except Exception:
LOG.exception('Plugin %s raised an exception trying to run '
'get_service_clients' %

View File

@ -75,7 +75,5 @@ class TestPluginDiscovery(base.TestCase):
fake_obj = fake_plugin.FakeStevedoreObjNoServiceClients()
manager.ext_plugins = [fake_obj]
expected_result = []
registered_clients = registry.get_service_clients()
self.assertIn(, registered_clients)
self.assertEqual(expected_result, registered_clients[])
self.assertNotIn(, registered_clients)