Skip to content

Commit

Permalink
tests: add tests for the wait_ms parameter in the cpu profiler API
Browse files Browse the repository at this point in the history
  • Loading branch information
ballard26 committed Oct 26, 2023
1 parent 96448a8 commit 4c1c5ad
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions tests/rptest/tests/cpu_profiler_admin_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from rptest.services.kgo_repeater_service import repeater_traffic
from rptest.utils.mode_checks import skip_debug_mode

import requests


class CPUProfilerAdminAPITest(RedpandaTest):
topics = (TopicSpec(partition_count=30, replication_factor=3), )
Expand All @@ -26,22 +28,26 @@ def __init__(self, test_context):
log_config=LoggingConfig('info',
logger_levels={'resources': 'trace'}),
extra_rp_conf={
"cpu_profiler_enabled": True,
"cpu_profiler_enabled": False,
"cpu_profiler_sample_period_ms": 50,
})

self.admin = Admin(self.redpanda)

@cluster(num_nodes=4)
def test_get_cpu_profile(self):
self.redpanda.set_cluster_config({
"cpu_profiler_enabled": True,
})

# Provide traffic so there is something to sample.
with repeater_traffic(context=self.test_context,
redpanda=self.redpanda,
topic=self.topic,
msg_size=4096,
workers=1) as repeater:
repeater.await_group_ready()
repeater.await_progress(1024,
repeater.await_progress(2 * 1024,
timeout_sec=100 if self.debug_mode else 75)

profile = self.admin.get_cpu_profile()
Expand All @@ -50,3 +56,35 @@ def test_get_cpu_profile(self):
assert len(
profile[0]["samples"]
) > 0, "At least one cpu profile should've been collected."

@cluster(num_nodes=4)
def test_get_cpu_profile_with_override(self):
# Provide traffic so there is something to sample.
with repeater_traffic(context=self.test_context,
redpanda=self.redpanda,
topic=self.topic,
msg_size=4096,
workers=1) as repeater:
repeater.await_group_ready()
profile = self.admin.get_cpu_profile(wait_ms=30 * 1_000)

assert len(profile) > 0, "At least one shard should exist"
assert len(
profile[0]["samples"]
) > 0, "At least one cpu profile should've been collected."

@cluster(num_nodes=3)
def test_get_cpu_profile_with_override_limits(self):
try:
self.admin.get_cpu_profile(wait_ms=16 * 60 * 1_000)
except requests.exceptions.HTTPError:
pass
else:
assert False, "call with wait_ms > 15min should of failed"

try:
self.admin.get_cpu_profile(wait_ms="0")
except requests.exceptions.HTTPError:
pass
else:
assert False, "call with wait_ms < 1ms should of failed"

0 comments on commit 4c1c5ad

Please sign in to comment.