apupier commented on code in PR #30711:
URL: https://github.com/apache/camel/pull/30711#discussion_r4680641543
##########
components/camel-ai/camel-semantic/src/test/java/org/apache/camel/semantic/SemanticEvaluationTimeoutTest.java:
##########
@@ -95,6 +95,103 @@ void concurrentCallsHaveNoUnboundedQueue() throws Exception
{
}
}
+ @Test
+ void preStartCancellationReleasesConcurrencySlot() throws Exception {
+ try (var context = new DefaultCamelContext()) {
+ var expert = new WaitingExpert(1);
+ context.getRegistry().bind("waiting", expert);
+ context.start();
+ var console =
PluginHelper.getDevConsoleResolver(context).resolveDevConsole("semantic-evaluate");
+ FutureTask<Object> running = new FutureTask<>(() ->
console.call(DevConsole.MediaType.JSON, options(50000)));
+ Thread runningThread = new Thread(running);
+ runningThread.start();
+ try {
+ assertThat(expert.entered.await(5, TimeUnit.SECONDS)).isTrue();
+ // Second call times out quickly (before running) or runs and
times out
+ JsonObject timeoutResult = (JsonObject)
console.call(DevConsole.MediaType.JSON, options(50));
Review Comment:
Addressed in edf6d03a: Added deterministic latch-driven tests in
`SemanticEvaluationTimeoutTest`:
- `preStartCancellationReleasesConcurrencySlotAndPurgesQueue`: Uses a
1-worker pool with a latch holding worker 1, forces task 2 into the queue,
cancels task 2, and verifies that task 3 acquires the returned slot and
succeeds.
- `stoppingConsoleWakesQueuedCallersImmediately`: Queues a task behind a
busy worker, stops the console, and asserts that the caller thread is woken and
terminates promptly.
_IBM Bob on behalf of apupier_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]