MINOR: Deploy VerifiableClient in constructor to avoid test timeouts (#8651)

Previous to this fix a plugged-in verifiable client, such as
confluent-kafka-python, would be deployed on the node in the background
worker thread as the client was started. Since this could be time consuming
(e.g., 10+ seconds) and since the main test thread would continue to
operate, it was common for the current test to time out waiting
for e.g. the verifiable producer to produce messages while it was in fact
still deploying.

The fix here is to deploy the verifiable client on the node when
the verifiable client is instantiated, which is thus a blocking
operation on the main test thread, avoiding any test-based timeouts.

Reviewers: Jason Gustafson <jason@confluent.io>
This commit is contained in:
Magnus Edenhill 2020-05-21 18:59:32 +02:00 committed by GitHub
parent f6781f42ff
commit 4aa4786a81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 5 deletions

View File

@ -181,8 +181,16 @@ def create_verifiable_client_implementation(context, parent):
class VerifiableClientMixin (object): class VerifiableClientMixin (object):
""" """
Verifiable client mixin class Verifiable client mixin class which loads the actual VerifiableClient.. class.
""" """
def __init__ (self, *args, **kwargs):
super(VerifiableClientMixin, self).__init__(*args, **kwargs)
if hasattr(self.impl, 'deploy'):
# Deploy client on node
self.context.logger.debug("Deploying %s on %s" % (self.impl, self.nodes))
for node in self.nodes:
self.impl.deploy(node)
@property @property
def impl (self): def impl (self):
""" """
@ -196,6 +204,13 @@ class VerifiableClientMixin (object):
return self._impl return self._impl
class VerifiableClient (object):
"""
Verifiable client base class
"""
def __init__(self, *args, **kwargs):
super(VerifiableClient, self).__init__()
def exec_cmd (self, node): def exec_cmd (self, node):
""" """
:return: command string to execute client. :return: command string to execute client.
@ -218,7 +233,7 @@ class VerifiableClientMixin (object):
return self.conf.get("kill_signal", signal.SIGTERM) return self.conf.get("kill_signal", signal.SIGTERM)
class VerifiableClientJava (VerifiableClientMixin): class VerifiableClientJava (VerifiableClient):
""" """
Verifiable Consumer and Producer using the official Java client. Verifiable Consumer and Producer using the official Java client.
""" """
@ -258,7 +273,7 @@ class VerifiableClientJava (VerifiableClientMixin):
return [] return []
class VerifiableClientDummy (VerifiableClientMixin): class VerifiableClientDummy (VerifiableClient):
""" """
Dummy class for testing the pluggable framework Dummy class for testing the pluggable framework
""" """
@ -280,7 +295,7 @@ class VerifiableClientDummy (VerifiableClientMixin):
return [] return []
class VerifiableClientApp (VerifiableClientMixin): class VerifiableClientApp (VerifiableClient):
""" """
VerifiableClient using --global settings for exec_cmd, pids and deploy. VerifiableClient using --global settings for exec_cmd, pids and deploy.
By using this a verifiable client application can be used through simple By using this a verifiable client application can be used through simple
@ -302,9 +317,9 @@ class VerifiableClientApp (VerifiableClientMixin):
raise SyntaxError("%s requires \"exec_cmd\": .. to be set in --globals %s object" % \ raise SyntaxError("%s requires \"exec_cmd\": .. to be set in --globals %s object" % \
(self.__class__.__name__, self.name)) (self.__class__.__name__, self.name))
def exec_cmd (self, node): def exec_cmd (self, node):
""" :return: command to execute to start instance """ """ :return: command to execute to start instance """
self.deploy(node)
return self.conf["exec_cmd"] return self.conf["exec_cmd"]
def pids (self, node): def pids (self, node):