use of org.apache.flink.runtime.webmonitor.threadinfo.ThreadInfoSamplesRequest in project flink by apache.
the class ThreadInfoSampleServiceTest method testThrowExceptionIfNumSamplesIsNegative.
/**
* Test that negative numSamples parameter is handled.
*/
@Test
public void testThrowExceptionIfNumSamplesIsNegative() {
try {
threadInfoSampleService.requestThreadInfoSamples(new TestTask(), new ThreadInfoSamplesRequest(1, -1, DELAY_BETWEEN_SAMPLES, MAX_STACK_TRACK_DEPTH));
fail("Expected exception not thrown");
} catch (final IllegalArgumentException e) {
assertThat(e.getMessage(), is(equalTo("numSamples must be positive")));
}
}
use of org.apache.flink.runtime.webmonitor.threadinfo.ThreadInfoSamplesRequest in project flink by apache.
the class ThreadInfoSampleServiceTest method testTruncateStackTraceIfLimitIsSpecified.
/**
* Tests that stack traces are truncated when exceeding the configured depth.
*/
@Test(timeout = 10000L)
public void testTruncateStackTraceIfLimitIsSpecified() throws Exception {
final List<ThreadInfoSample> threadInfoSamples1 = threadInfoSampleService.requestThreadInfoSamples(new TestTask(), requestParams).get();
final List<ThreadInfoSample> threadInfoSamples2 = threadInfoSampleService.requestThreadInfoSamples(new TestTask(), new ThreadInfoSamplesRequest(1, NUMBER_OF_SAMPLES, DELAY_BETWEEN_SAMPLES, MAX_STACK_TRACK_DEPTH - 5)).get();
for (ThreadInfoSample sample : threadInfoSamples1) {
assertThat(sample.getStackTrace(), is(arrayWithSize(lessThanOrEqualTo(MAX_STACK_TRACK_DEPTH))));
assertTrue(sample.getStackTrace().length <= MAX_STACK_TRACK_DEPTH);
}
for (ThreadInfoSample sample : threadInfoSamples2) {
assertThat(sample.getStackTrace(), is(arrayWithSize(MAX_STACK_TRACK_DEPTH - 5)));
}
}
Aggregations