Fix JMXFeatureTest failure due to disabled AsyncProfiler

patch by Arvind Kandpal; reviewed by Jyothsna Konisa, Stefan Miklosovic for CASSANDRA-21135
This commit is contained in:
arvindksi274-ksolves 2026-01-27 11:26:33 +05:30 committed by Stefan Miklosovic
parent 585f89bb42
commit d1b4ddc32a
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
2 changed files with 8 additions and 5 deletions

View File

@ -368,6 +368,10 @@ public class AsyncProfilerService implements AsyncProfilerMBean
@Override
public String status()
{
if (!ASYNC_PROFILER_ENABLED.getBoolean())
{
return "Async Profiler is not enabled. Enable it by setting " + ASYNC_PROFILER_ENABLED.getKey() + " property to true.";
}
return run(new ThrowingFunction<>()
{
@Override

View File

@ -264,14 +264,13 @@ public class AsyncProfilerServiceTest
}
@Test
public void testProfilerDisabledThrowsException()
public void testProfilerDisabledReturnsMessage()
{
try (WithProperties properties = new WithProperties().set(ASYNC_PROFILER_UNSAFE_MODE, true).set(ASYNC_PROFILER_ENABLED, false))
{
assertThatThrownBy(() -> {
AsyncProfilerService profiler = getProfiler(true);
profiler.status();
}).hasMessageContaining("Async Profiler is not enabled. Enable it by setting cassandra.async_profiler.enabled property to true.");
AsyncProfilerService profiler = getProfiler(true);
String status = profiler.status();
assertTrue(status.contains("Async Profiler is not enabled. Enable it by setting " + ASYNC_PROFILER_ENABLED.getKey() + " property to true."));
}
}