This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new aec8b3f2980 Flaky (#11069)
aec8b3f2980 is described below
commit aec8b3f29809354ba0ade2c6a3b74583c8c5eb2a
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Aug 10 17:42:22 2023 +0200
Flaky (#11069)
* CAMEL-19684: A little potential fix but lets enable it for CI to keep an
eye again
* CAMEL-19684: Attempt to fix some flaky test
* CAMEL-19684: Attempt to fix some flaky test
---
.../camel/impl/engine/PooledExchangeFactory.java | 12 -------
.../component/file/FileRecursiveNoopTest.java | 11 +++---
.../management/ManagedPooledExchangeTest.java | 41 ++++++++++++----------
3 files changed, 29 insertions(+), 35 deletions(-)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
index 7573dacd18a..7468e4f9c58 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
@@ -41,18 +41,6 @@ public final class PooledExchangeFactory extends
PrototypeExchangeFactory {
super(consumer);
}
- @Override
- protected void doBuild() throws Exception {
- super.doBuild();
- // force creating and load the class during build time so the JVM does
not
- // load the class on first exchange to be created
- DefaultPooledExchange dummy = new DefaultPooledExchange(camelContext);
- // force message init to load classes
- dummy.getIn();
- dummy.getIn().getHeaders();
- LOG.trace("Warming up PooledExchangeFactory loaded class: {}",
dummy.getClass().getName());
- }
-
@Override
public ExchangeFactory newExchangeFactory(Consumer consumer) {
PooledExchangeFactory answer = new PooledExchangeFactory(consumer);
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileRecursiveNoopTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileRecursiveNoopTest.java
index e93f05c7b2d..8e5a109ac12 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileRecursiveNoopTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileRecursiveNoopTest.java
@@ -24,12 +24,13 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class FileRecursiveNoopTest extends ContextTestSupport {
- private final String fileUri = fileUri();
@BeforeEach
void sendMessages() {
- template.sendBodyAndHeader(fileUri, "a", Exchange.FILE_NAME, "a.txt");
- template.sendBodyAndHeader(fileUri, "b", Exchange.FILE_NAME, "b.txt");
+ testDirectory(true);
+
+ template.sendBodyAndHeader(fileUri(), "a", Exchange.FILE_NAME,
"a.txt");
+ template.sendBodyAndHeader(fileUri(), "b", Exchange.FILE_NAME,
"b.txt");
template.sendBodyAndHeader(fileUri("foo"), "a2", Exchange.FILE_NAME,
"a.txt");
template.sendBodyAndHeader(fileUri("bar"), "c", Exchange.FILE_NAME,
"c.txt");
template.sendBodyAndHeader(fileUri("bar"), "b2", Exchange.FILE_NAME,
"b.txt");
@@ -37,6 +38,8 @@ public class FileRecursiveNoopTest extends ContextTestSupport
{
@Test
public void testRecursiveNoop() throws Exception {
+ context.getRouteController().startAllRoutes();
+
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("a", "b", "a2", "c", "b2");
@@ -56,7 +59,7 @@ public class FileRecursiveNoopTest extends ContextTestSupport
{
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
from(fileUri("?initialDelay=0&delay=10&recursive=true&noop=true")).convertBodyTo(String.class)
+
from(fileUri("?initialDelay=0&delay=10&recursive=true&noop=true")).convertBodyTo(String.class).noAutoStartup()
.to("mock:result");
}
};
diff --git
a/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
b/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
index 89453a793b8..ee47b4b5737 100644
---
a/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
+++
b/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
@@ -29,8 +29,8 @@ import org.apache.camel.ServiceStatus;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.engine.PooledExchangeFactory;
+import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
@@ -39,7 +39,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
@DisabledOnOs(OS.AIX)
-@DisabledIfSystemProperty(named = "ci.env.name", matches = "github.com",
disabledReason = "Flaky on Github CI")
public class ManagedPooledExchangeTest extends ManagementTestSupport {
private final AtomicInteger counter = new AtomicInteger();
@@ -87,21 +86,23 @@ public class ManagedPooledExchangeTest extends
ManagementTestSupport {
Integer cap = (Integer) mbeanServer.getAttribute(on, "Capacity");
assertEquals(123, cap.intValue());
- // also only 1 exchange pooled
- con = (Integer) mbeanServer.getAttribute(on, "TotalPooled");
- assertEquals(1, con.intValue());
+ Awaitility.await().untilAsserted(() -> {
+ Long num = (Long) mbeanServer.getAttribute(on, "TotalCreated");
+ assertEquals(1, num.intValue());
+
+ num = (Long) mbeanServer.getAttribute(on, "TotalAcquired");
+ assertEquals(2, num.intValue());
- Long num = (Long) mbeanServer.getAttribute(on, "TotalCreated");
- assertEquals(1, num.intValue());
+ num = (Long) mbeanServer.getAttribute(on, "TotalReleased");
+ assertEquals(3, num.intValue());
- num = (Long) mbeanServer.getAttribute(on, "TotalAcquired");
- assertEquals(2, num.intValue());
+ num = (Long) mbeanServer.getAttribute(on, "TotalDiscarded");
+ assertEquals(0, num.intValue());
- num = (Long) mbeanServer.getAttribute(on, "TotalReleased");
- assertEquals(3, num.intValue());
+ Integer num2 = (Integer) mbeanServer.getAttribute(on,
"TotalPooled");
+ assertEquals(1, num2.intValue());
+ });
- num = (Long) mbeanServer.getAttribute(on, "TotalDiscarded");
- assertEquals(0, num.intValue());
}
@Override
@@ -116,12 +117,14 @@ public class ManagedPooledExchangeTest extends
ManagementTestSupport {
@Override
public void process(Exchange exchange) throws
Exception {
// should be same exchange instance as its
pooled
- Exchange old = ref.get();
- if (old == null) {
- ref.set(exchange);
- exchange.getMessage().setHeader("first",
true);
- } else {
- assertSame(old, exchange);
+ synchronized (this) {
+ Exchange old = ref.get();
+ if (old == null) {
+ ref.set(exchange);
+
exchange.getMessage().setHeader("first", true);
+ } else {
+ assertSame(old, exchange);
+ }
}
}
})