This is an automated email from the ASF dual-hosted git repository.
fortino pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 0346c6a657 OAK-10539: use assertEventually in ElasticReliabilityTest
(#1222)
0346c6a657 is described below
commit 0346c6a657fa007ec7a8836a2c364317eaa79630
Author: Fabrizio Fortino <[email protected]>
AuthorDate: Mon Nov 20 15:21:37 2023 +0100
OAK-10539: use assertEventually in ElasticReliabilityTest (#1222)
* OAK-10539: use assertEventually in ElasticReliabilityTest
* OAK-10539: set cache expiration and refresh to low values to avoid cached
results in tests
---
.../plugins/index/elastic/ElasticReliabilityTest.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReliabilityTest.java
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReliabilityTest.java
index c457670682..652d6f61a3 100644
---
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReliabilityTest.java
+++
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReliabilityTest.java
@@ -22,7 +22,10 @@ import eu.rekawek.toxiproxy.model.ToxicDirection;
import eu.rekawek.toxiproxy.model.toxic.LimitData;
import org.apache.jackrabbit.oak.api.Tree;
import org.junit.After;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.ProvideSystemProperty;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.testcontainers.containers.ToxiproxyContainer;
import org.testcontainers.utility.DockerImageName;
@@ -36,6 +39,15 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class ElasticReliabilityTest extends ElasticAbstractQueryTest {
+ // set cache expiration and refresh to low values to avoid cached results
in tests
+ @Rule
+ public final ProvideSystemProperty updateSystemProperties
+ = new ProvideSystemProperty("oak.elastic.statsExpireSeconds", "5")
+ .and("oak.elastic.statsRefreshSeconds", "1");
+
+ @Rule
+ public final RestoreSystemProperties restoreSystemProperties = new
RestoreSystemProperties();
+
private static final DockerImageName TOXIPROXY_IMAGE =
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.6.0");
private ToxiproxyContainer toxiproxy;
@@ -89,7 +101,7 @@ public class ElasticReliabilityTest extends
ElasticAbstractQueryTest {
.limitData("CUT_CONNECTION_UPSTREAM", ToxicDirection.UPSTREAM,
0L);
// elastic is down, query should not use it
- assertThat(explain(query), not(containsString("elasticsearch:test1")));
+ assertEventually(() -> assertThat(explain(query),
not(containsString("elasticsearch:test1"))));
// result set should be correct anyway since traversal is enabled
assertQuery(query, Arrays.asList("/test/a", "/test/b"));
@@ -98,7 +110,7 @@ public class ElasticReliabilityTest extends
ElasticAbstractQueryTest {
cutConnectionUpstream.remove();
// result set should be the same as before but this time elastic
should be used
- assertThat(explain(query), containsString("elasticsearch:test1"));
+ assertEventually(() -> assertThat(explain(query),
containsString("elasticsearch:test1")));
assertQuery(query, Arrays.asList("/test/a", "/test/b"));
}
}