You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/09 04:35:59 UTC
[camel] branch master updated: Fixed flaky tests on slow CI servers
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new a0fa6c7 Fixed flaky tests on slow CI servers
a0fa6c7 is described below
commit a0fa6c79592fa30fa7b8d488aaf9921040b44f5f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 9 05:35:36 2019 +0100
Fixed flaky tests on slow CI servers
---
.../spring/config/ConsumerTemplateMaximumCacheSizeTest.java | 12 +++++++-----
.../spring/config/ProducerTemplateMaximumCacheSizeTest.java | 10 +++++++---
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ConsumerTemplateMaximumCacheSizeTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ConsumerTemplateMaximumCacheSizeTest.java
index 55d7fbc..e849d5b 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ConsumerTemplateMaximumCacheSizeTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ConsumerTemplateMaximumCacheSizeTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.spring.config;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.Endpoint;
@@ -24,6 +26,8 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
+import static org.awaitility.Awaitility.await;
+
@ContextConfiguration
public class ConsumerTemplateMaximumCacheSizeTest extends SpringRunWithTestSupport {
@@ -51,13 +55,11 @@ public class ConsumerTemplateMaximumCacheSizeTest extends SpringRunWithTestSuppo
// the eviction is async so force cleanup
template.cleanUp();
-
- // eviction may still run a bit
- int currentCacheSize = template.getCurrentCacheSize();
- assertTrue("Size should be around 50, but was " + currentCacheSize, currentCacheSize <= 53);
- template.stop();
+ await().atMost(2, TimeUnit.SECONDS).until(() -> template.getCurrentCacheSize() == 50);
+ assertEquals("Size should be 50", 50, template.getCurrentCacheSize());
// should be 0
+ template.stop();
assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ProducerTemplateMaximumCacheSizeTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ProducerTemplateMaximumCacheSizeTest.java
index 54f383b..e95eab4 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ProducerTemplateMaximumCacheSizeTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ProducerTemplateMaximumCacheSizeTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.spring.config;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.ProducerTemplate;
@@ -24,6 +26,8 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
+import static org.awaitility.Awaitility.await;
+
@ContextConfiguration
public class ProducerTemplateMaximumCacheSizeTest extends SpringRunWithTestSupport {
@@ -51,11 +55,11 @@ public class ProducerTemplateMaximumCacheSizeTest extends SpringRunWithTestSuppo
// the eviction is async so force cleanup
template.cleanUp();
-
- assertTrue("Size should be around 50", template.getCurrentCacheSize() >= 50);
- template.stop();
+ await().atMost(2, TimeUnit.SECONDS).until(() -> template.getCurrentCacheSize() == 50);
+ assertEquals("Size should be 50", 50, template.getCurrentCacheSize());
// should be 0
+ template.stop();
assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
}