gnodet commented on code in PR #31326: URL: https://github.com/apache/camel/pull/31326#discussion_r4787876187
########## components/camel-robotframework/src/test/java/org/apache/camel/component/robotframework/RobotFrameworkInterruptedRunTest.java: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.robotframework; + +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +/** + * A Robot Framework run that is interrupted must not break the later runs in the same JVM: the console stream of Robot + * Framework is shared by the JVM and, with the console enabled, it stays closed after the interrupt. + */ +class RobotFrameworkInterruptedRunTest extends CamelTestSupport { + + @Test + void testRunAfterInterruptedRunSucceeds() throws Exception { + template.send("direct:robot", e -> e.getIn().setBody("warmup")); + + // a thread that is interrupted while Robot Framework starts closes the console stream of Robot Framework + for (int i = 0; i < 5; i++) { + Thread interrupted = new Thread(() -> template.send("direct:robot", e -> e.getIn().setBody("interrupted"))); + interrupted.start(); + await().atMost(30, TimeUnit.SECONDS) + .until(() -> !interrupted.isAlive() || Arrays.stream(interrupted.getStackTrace()) + .anyMatch(frame -> frame.getClassName().startsWith("org.python."))); + interrupted.interrupt(); Review Comment: **Question about test reliability:** This test interrupts threads by checking if the stack trace contains `org.python.`. On loaded CI machines with high concurrency, this could be timing-sensitive. The 30-second timeout is generous, but have you verified this doesn't become flaky under high concurrency (e.g., with `-Dcamel.surefire.forkCount=8`)? Per CLAUDE.md test guidelines: "Check it: if a test fails only now and then, it almost always shares something or relies on timing. Reproduce it by running the module several times with `-Dcamel.surefire.forkCount=8`." This is not a blocking issue—the approach seems reasonable given Robot Framework's Jython nature—just flagging for consideration. -- 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]
