From 3999d179d3a083d2a737a7cd1f0fed39e386985a Mon Sep 17 00:00:00 2001 From: Jason Gustafson Date: Fri, 24 Mar 2017 17:42:13 -0700 Subject: [PATCH 1/2] HOTFIX: Fix unsafe dependence on class name in VerifiableClientJava --- tests/kafkatest/services/verifiable_client.py | 2 +- tests/kafkatest/services/verifiable_consumer.py | 12 +++++++++++- tests/kafkatest/services/verifiable_producer.py | 13 +++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/kafkatest/services/verifiable_client.py b/tests/kafkatest/services/verifiable_client.py index d8ffa356a8225..d249de6603fc4 100644 --- a/tests/kafkatest/services/verifiable_client.py +++ b/tests/kafkatest/services/verifiable_client.py @@ -228,7 +228,7 @@ def __init__(self, parent, conf=None): """ super(VerifiableClientJava, self).__init__() self.parent = parent - self.java_class_name = self.parent.__class__.__name__ + self.java_class_name = parent.java_class_name() self.conf = conf def exec_cmd (self, node): diff --git a/tests/kafkatest/services/verifiable_consumer.py b/tests/kafkatest/services/verifiable_consumer.py index 735a7bf0b6085..f1dfa9a923633 100644 --- a/tests/kafkatest/services/verifiable_consumer.py +++ b/tests/kafkatest/services/verifiable_consumer.py @@ -129,7 +129,14 @@ def last_commit(self, tp): return None - +""" +This service wraps org.apache.kafka.tools.VerifiableConsumer for use in +system testing. + +NOTE: this class should be treated as a PUBLIC API. Downstream users use +this service both directly and through class extension, so care must be +taken to ensure compatibility. +""" class VerifiableConsumer(KafkaPathResolverMixin, VerifiableClientMixin, BackgroundThreadService): PERSISTENT_ROOT = "/mnt/verifiable_consumer" STDOUT_CAPTURE = os.path.join(PERSISTENT_ROOT, "verifiable_consumer.stdout") @@ -175,6 +182,9 @@ def __init__(self, context, num_nodes, kafka, topic, group_id, for node in self.nodes: node.version = version + def java_class_name(self): + return "VerifiableConsumer" + def _worker(self, idx, node): with self.lock: if node not in self.event_handlers: diff --git a/tests/kafkatest/services/verifiable_producer.py b/tests/kafkatest/services/verifiable_producer.py index e32a3def92142..6662f86fd5cf6 100644 --- a/tests/kafkatest/services/verifiable_producer.py +++ b/tests/kafkatest/services/verifiable_producer.py @@ -28,8 +28,14 @@ from kafkatest.version import DEV_BRANCH from kafkatest.utils.remote_account import line_count - - +""" +This service wraps org.apache.kafka.tools.VerifiableProducer for use in +system testing. + +NOTE: this class should be treated as a PUBLIC API. Downstream users use +this service both directly and through class extension, so care must be +taken to ensure compatibility. +""" class VerifiableProducer(KafkaPathResolverMixin, VerifiableClientMixin, BackgroundThreadService): PERSISTENT_ROOT = "/mnt/verifiable_producer" STDOUT_CAPTURE = os.path.join(PERSISTENT_ROOT, "verifiable_producer.stdout") @@ -87,6 +93,9 @@ def __init__(self, context, num_nodes, kafka, topic, max_messages=-1, throughput self.stop_timeout_sec = stop_timeout_sec self.request_timeout_sec = request_timeout_sec + def java_class_name(self): + return "VerifiableProducer" + def prop_file(self, node): idx = self.idx(node) prop_file = str(self.security_config) From 9ab6df79700dcf8219142d82d32970e88a16daf7 Mon Sep 17 00:00:00 2001 From: Jason Gustafson Date: Fri, 24 Mar 2017 19:37:22 -0700 Subject: [PATCH 2/2] Move class documentation to the right place --- tests/kafkatest/services/verifiable_consumer.py | 16 ++++++++-------- tests/kafkatest/services/verifiable_producer.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/kafkatest/services/verifiable_consumer.py b/tests/kafkatest/services/verifiable_consumer.py index f1dfa9a923633..0d60dd102c441 100644 --- a/tests/kafkatest/services/verifiable_consumer.py +++ b/tests/kafkatest/services/verifiable_consumer.py @@ -129,15 +129,15 @@ def last_commit(self, tp): return None -""" -This service wraps org.apache.kafka.tools.VerifiableConsumer for use in -system testing. - -NOTE: this class should be treated as a PUBLIC API. Downstream users use -this service both directly and through class extension, so care must be -taken to ensure compatibility. -""" class VerifiableConsumer(KafkaPathResolverMixin, VerifiableClientMixin, BackgroundThreadService): + """This service wraps org.apache.kafka.tools.VerifiableConsumer for use in + system testing. + + NOTE: this class should be treated as a PUBLIC API. Downstream users use + this service both directly and through class extension, so care must be + taken to ensure compatibility. + """ + PERSISTENT_ROOT = "/mnt/verifiable_consumer" STDOUT_CAPTURE = os.path.join(PERSISTENT_ROOT, "verifiable_consumer.stdout") STDERR_CAPTURE = os.path.join(PERSISTENT_ROOT, "verifiable_consumer.stderr") diff --git a/tests/kafkatest/services/verifiable_producer.py b/tests/kafkatest/services/verifiable_producer.py index 6662f86fd5cf6..859e3c483d6b0 100644 --- a/tests/kafkatest/services/verifiable_producer.py +++ b/tests/kafkatest/services/verifiable_producer.py @@ -28,15 +28,15 @@ from kafkatest.version import DEV_BRANCH from kafkatest.utils.remote_account import line_count -""" -This service wraps org.apache.kafka.tools.VerifiableProducer for use in -system testing. - -NOTE: this class should be treated as a PUBLIC API. Downstream users use -this service both directly and through class extension, so care must be -taken to ensure compatibility. -""" class VerifiableProducer(KafkaPathResolverMixin, VerifiableClientMixin, BackgroundThreadService): + """This service wraps org.apache.kafka.tools.VerifiableProducer for use in + system testing. + + NOTE: this class should be treated as a PUBLIC API. Downstream users use + this service both directly and through class extension, so care must be + taken to ensure compatibility. + """ + PERSISTENT_ROOT = "/mnt/verifiable_producer" STDOUT_CAPTURE = os.path.join(PERSISTENT_ROOT, "verifiable_producer.stdout") STDERR_CAPTURE = os.path.join(PERSISTENT_ROOT, "verifiable_producer.stderr")