Skip to content
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

feat(e2e): jmx.py supports obtaining the maximum average value of all windows #1595

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/kafkatest/services/monitor/jmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def __init__(self, num_nodes, jmx_object_names=None, jmx_attributes=None, jmx_po
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

# AutoMQ inject start
self.jmx_windows_size = 11
self.jmx_window_max_avg_values = {} # map from object_attribute_name to the maximum average value observed over windows of time
# AutoMQ inject end

self.jmx_tool_log = os.path.join(root, "jmx_tool.log")
self.jmx_tool_err_log = os.path.join(root, "jmx_tool.err.log")

Expand Down Expand Up @@ -130,6 +135,21 @@ def read_jmx_output(self, idx, node):
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)
# AutoMQ inject start
max_avg_value = float('-inf')
windows_size = self.jmx_windows_size
window_sum = sum(aggregates_per_time[:windows_size])
window_count = min(windows_size, len(aggregates_per_time))
if window_count > 0:
max_avg_value = window_sum / window_count
for i in range(windows_size, len(aggregates_per_time)):
window_sum -= aggregates_per_time[i - windows_size]
window_sum += aggregates_per_time[i]
window_avg = window_sum / windows_size
if window_avg > max_avg_value:
max_avg_value = window_avg
self.jmx_window_max_avg_values[name] = max_avg_value if max_avg_value != float('-inf') else 0
# AutoMQ inject end

def read_jmx_output_all_nodes(self):
for node in self.nodes:
Expand Down
Loading