-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-2527; System Test for Quotas in Ducktape #275
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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cf1a116
KAFKA-2527; System Test for Quotas in Ducktape
lindong28 345b997
adjust quota configuration
lindong28 28bd200
JmxMixin will subclass object
lindong28 0d07fc7
support jmx query with arbitrary object name and attributes
lindong28 c0fd768
jmx_object_name is required to use jmx tool
lindong28 f7cfad5
adjust quota test configuration
lindong28 35f3dd8
address reviewer comments
lindong28 42e5804
fix stop_node in console consumer
lindong28 3b68a11
resolve conflicts
lindong28 ceb4534
fix benchmark test
lindong28 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| class JmxMixin(object): | ||
|
|
||
| def __init__(self, num_nodes, jmx_object_names=None, jmx_attributes=[]): | ||
| self.jmx_object_names = jmx_object_names | ||
| self.jmx_attributes = jmx_attributes | ||
| self.jmx_port = 9192 | ||
|
|
||
| self.started = [False] * num_nodes | ||
| self.jmx_stats = [{} for x in range(num_nodes)] | ||
| self.maximum_jmx_value = {} # map from object_attribute_name to maximum value observed over time | ||
| self.average_jmx_value = {} # map from object_attribute_name to average value observed over time | ||
|
|
||
| def clean_node(self, node): | ||
| node.account.kill_process("jmx", clean_shutdown=False, allow_fail=True) | ||
| node.account.ssh("rm -rf /mnt/jmx_tool.log", allow_fail=False) | ||
|
|
||
| def start_jmx_tool(self, idx, node): | ||
| if self.started[idx-1] == True or self.jmx_object_names == None: | ||
| return | ||
| self.started[idx-1] = True | ||
|
|
||
| cmd = "/opt/kafka/bin/kafka-run-class.sh kafka.tools.JmxTool " \ | ||
| "--reporting-interval 1000 --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:%d/jmxrmi" % self.jmx_port | ||
| for jmx_object_name in self.jmx_object_names: | ||
| cmd += " --object-name %s" % jmx_object_name | ||
| for jmx_attribute in self.jmx_attributes: | ||
| cmd += " --attributes %s" % jmx_attribute | ||
| cmd += " | tee -a /mnt/jmx_tool.log" | ||
|
|
||
| self.logger.debug("Start JmxTool %d command: %s", idx, cmd) | ||
| jmx_output = node.account.ssh_capture(cmd, allow_fail=False) | ||
| jmx_output.next() | ||
|
|
||
| def read_jmx_output(self, idx, node): | ||
| if self.started[idx-1] == False: | ||
| return | ||
| self.maximum_jmx_value = {} | ||
| self.average_jmx_value = {} | ||
| object_attribute_names = [] | ||
|
|
||
| cmd = "cat /mnt/jmx_tool.log" | ||
| self.logger.debug("Read jmx output %d command: %s", idx, cmd) | ||
| for line in node.account.ssh_capture(cmd, allow_fail=False): | ||
| if "time" in line: | ||
| object_attribute_names = line.strip()[1:-1].split("\",\"")[1:] | ||
| continue | ||
| stats = [float(field) for field in line.split(',')] | ||
| time_sec = int(stats[0]/1000) | ||
| self.jmx_stats[idx-1][time_sec] = {name : stats[i+1] for i, name in enumerate(object_attribute_names)} | ||
|
|
||
| # do not calculate average and maximum of jmx stats until we have read output from all nodes | ||
| if any(len(time_to_stats)==0 for time_to_stats in self.jmx_stats): | ||
| return | ||
|
|
||
| start_time_sec = min([min(time_to_stats.keys()) for time_to_stats in self.jmx_stats]) | ||
| end_time_sec = max([max(time_to_stats.keys()) for time_to_stats in self.jmx_stats]) | ||
|
|
||
| for name in object_attribute_names: | ||
| aggregates_per_time = [] | ||
| for time_sec in xrange(start_time_sec, end_time_sec+1): | ||
| # assume that value is 0 if it is not read by jmx tool at the given time. This is appropriate for metrics such as bandwidth | ||
| values_per_node = [time_to_stats.get(time_sec, {}).get(name, 0) for time_to_stats in self.jmx_stats] | ||
| # assume that value is aggregated across nodes by sum. This is appropriate for metrics such as bandwidth | ||
| aggregates_per_time.append(sum(values_per_node)) | ||
| self.average_jmx_value[name] = sum(aggregates_per_time)/len(aggregates_per_time) | ||
| self.maximum_jmx_value[name] = max(aggregates_per_time) |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -13,19 +13,23 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from kafkatest.services.performance.jmx_mixin import JmxMixin | ||
| from kafkatest.services.performance import PerformanceService | ||
| import itertools | ||
|
|
||
|
|
||
| class ProducerPerformanceService(PerformanceService): | ||
| class ProducerPerformanceService(JmxMixin, PerformanceService): | ||
|
|
||
| logs = { | ||
| "producer_performance_log": { | ||
| "path": "/mnt/producer-performance.log", | ||
| "collect_default": True}, | ||
| } | ||
|
|
||
| def __init__(self, context, num_nodes, kafka, topic, num_records, record_size, throughput, settings={}, intermediate_stats=False): | ||
| super(ProducerPerformanceService, self).__init__(context, num_nodes) | ||
| def __init__(self, context, num_nodes, kafka, topic, num_records, record_size, throughput, settings={}, | ||
| intermediate_stats=False, client_id="producer-performance", jmx_object_names=None, jmx_attributes=[]): | ||
| JmxMixin.__init__(self, num_nodes, jmx_object_names, jmx_attributes) | ||
| PerformanceService.__init__(self, context, num_nodes) | ||
|
|
||
| self.kafka = kafka | ||
| self.args = { | ||
| 'topic': topic, | ||
|
|
@@ -35,12 +39,13 @@ def __init__(self, context, num_nodes, kafka, topic, num_records, record_size, t | |
| } | ||
| self.settings = settings | ||
| self.intermediate_stats = intermediate_stats | ||
| self.client_id = client_id | ||
|
|
||
| def _worker(self, idx, node): | ||
| args = self.args.copy() | ||
| args.update({'bootstrap_servers': self.kafka.bootstrap_servers()}) | ||
| cmd = "/opt/kafka/bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance "\ | ||
| "%(topic)s %(num_records)d %(record_size)d %(throughput)d bootstrap.servers=%(bootstrap_servers)s"\ | ||
| args.update({'bootstrap_servers': self.kafka.bootstrap_servers(), 'jmx_port': self.jmx_port, 'client_id': self.client_id}) | ||
| cmd = "JMX_PORT=%(jmx_port)d /opt/kafka/bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance "\ | ||
| "%(topic)s %(num_records)d %(record_size)d %(throughput)d bootstrap.servers=%(bootstrap_servers)s client.id=%(client_id)s"\ | ||
| " | tee /mnt/producer-performance.log" % args | ||
|
Contributor
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. @lindong28 When I drop the pipe to tee here on line 51 and keep the one below, the producer runs as expected. |
||
|
|
||
| for key, value in self.settings.items(): | ||
|
|
@@ -61,7 +66,10 @@ def parse_stats(line): | |
| 'latency_999th_ms': float(parts[7].split()[0]), | ||
| } | ||
| last = None | ||
| for line in node.account.ssh_capture(cmd): | ||
| producer_output = node.account.ssh_capture(cmd) | ||
| first_line = producer_output.next() | ||
| self.start_jmx_tool(idx, node) | ||
| for line in itertools.chain([first_line], producer_output): | ||
| if self.intermediate_stats: | ||
| try: | ||
| self.stats[idx-1].append(parse_stats(line)) | ||
|
|
@@ -74,3 +82,4 @@ def parse_stats(line): | |
| self.results[idx-1] = parse_stats(last) | ||
| except: | ||
| raise Exception("Unable to parse aggregate performance statistics on node %d: %s" % (idx, last)) | ||
| self.read_jmx_output(idx, node) | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
There is now one sanity check which fails both remotely and on my mac:
http://jenkins.confluent.io/job/kafka_system_tests_branch_builder/94/console
This is fixed by changing
console-consumertoconsole_consumer(dash to underscore)