-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MINOR: add wait_for_assigned_partitions to console-consumer #8192
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,10 @@ | |
import os | ||
|
||
from ducktape.services.background_thread import BackgroundThreadService | ||
from ducktape.utils.util import wait_until | ||
|
||
from kafkatest.directory_layout.kafka_path import KafkaPathResolverMixin | ||
from kafkatest.services.monitor.jmx import JmxMixin | ||
from kafkatest.services.monitor.jmx import JmxMixin, JmxTool | ||
from kafkatest.version import DEV_BRANCH, LATEST_0_8_2, LATEST_0_9, LATEST_0_10_0, V_0_9_0_0, V_0_10_0_0, V_0_11_0_0, V_2_0_0 | ||
|
||
""" | ||
|
@@ -62,7 +63,8 @@ def __init__(self, context, num_nodes, kafka, topic, group_id="test-consumer-gro | |
client_id="console-consumer", print_key=False, jmx_object_names=None, jmx_attributes=None, | ||
enable_systest_events=False, stop_timeout_sec=35, print_timestamp=False, print_partition=False, | ||
isolation_level="read_uncommitted", jaas_override_variables=None, | ||
kafka_opts_override="", client_prop_file_override="", consumer_properties={}): | ||
kafka_opts_override="", client_prop_file_override="", consumer_properties={}, | ||
wait_until_partitions_assigned=False): | ||
""" | ||
Args: | ||
context: standard context | ||
|
@@ -124,6 +126,7 @@ def __init__(self, context, num_nodes, kafka, topic, group_id="test-consumer-gro | |
self.kafka_opts_override = kafka_opts_override | ||
self.client_prop_file_override = client_prop_file_override | ||
self.consumer_properties = consumer_properties | ||
self.wait_until_partitions_assigned = wait_until_partitions_assigned | ||
|
||
|
||
def prop_file(self, node): | ||
|
@@ -273,8 +276,25 @@ def _worker(self, idx, node): | |
with self.lock: | ||
self.read_jmx_output(idx, node) | ||
|
||
def _wait_until_partitions_assigned(self, node, timeout_sec=60): | ||
if self.jmx_object_names is not None: | ||
raise Exception("'wait_until_partitions_assigned' is not supported while using 'jmx_object_names'/'jmx_attributes'") | ||
jmx_tool = JmxTool(self.context, jmx_poll_ms=100) | ||
jmx_tool.jmx_object_names = ["kafka.consumer:type=consumer-coordinator-metrics,client-id=%s" % self.client_id] | ||
jmx_tool.jmx_attributes = ["assigned-partitions"] | ||
jmx_tool.assigned_partitions_jmx_attr = "kafka.consumer:type=consumer-coordinator-metrics,client-id=%s:assigned-partitions" % self.client_id | ||
jmx_tool.start_jmx_tool(self.idx(node), node) | ||
jmx_tool.read_jmx_output(self.idx(node), node) | ||
assigned_partitions_jmx_attr = "kafka.consumer:type=consumer-coordinator-metrics,client-id=%s:assigned-partitions" % self.client_id | ||
wait_until(lambda: assigned_partitions_jmx_attr in jmx_tool.maximum_jmx_value, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should be re-running |
||
timeout_sec=timeout_sec, | ||
backoff_sec=.5, | ||
err_msg="consumer was not assigned partitions within %d seconds" % timeout_sec) | ||
|
||
def start_node(self, node): | ||
BackgroundThreadService.start_node(self, node) | ||
if self.wait_until_partitions_assigned: | ||
self._wait_until_partitions_assigned(node) | ||
|
||
def stop_node(self, node): | ||
self.logger.info("%s Stopping node %s" % (self.__class__.__name__, str(node.account))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not ideal but requires more refactoring to be able support multiple JmxTools running at once