Skip to content

Commit

Permalink
[CALCITE-4960] Enable unit tests in Elasticsearch Adapter
Browse files Browse the repository at this point in the history
1. Increase SocketTimeout and ConnectionTimeout for RestClient to avoid
CI failures.
2. Disable/Skip test cases with appropriate JIRA references.

Close apache#2659
  • Loading branch information
ILuffZhe authored and liyafan82 committed Mar 4, 2022
1 parent d3d4821 commit 1ce4f05
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 16 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/org/apache/calcite/util/Bug.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ public abstract class Bug {
* Druid plans with small intervals should be chosen over full interval scan plus filter</a> is
* fixed. */
public static final boolean CALCITE_4213_FIXED = false;
/** Whether
* <a href="https://issues.apache.org/jira/browse/CALCITE-4645">[CALCITE-4645]
* In Elasticsearch adapter, a range predicate should be translated to a range query</a> is
* fixed. */
public static final boolean CALCITE_4645_FIXED = false;
/** Whether
* <a href="https://issues.apache.org/jira/browse/CALCITE-4965">[CALCITE-4965]
* IS NOT NULL failed in Elasticsearch Adapter</a> is
* fixed. */
public static final boolean CALCITE_4965_FIXED = false;

/**
* Use this to flag temporary code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import org.apache.calcite.schema.impl.ViewTableMacro;
import org.apache.calcite.test.CalciteAssert;
import org.apache.calcite.test.ElasticsearchChecker;
import org.apache.calcite.util.Bug;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableMap;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
Expand Down Expand Up @@ -120,8 +121,8 @@ private CalciteAssert.ConnectionFactory newConnectionFactory() {
* So disable this test case until the translation from Search in range
* to rang Query in ES is implemented.
*/
@Disabled
@Test void searchInRange() {
Assumptions.assumeTrue(Bug.CALCITE_4645_FIXED, "CALCITE-4645");
CalciteAssert.that()
.with(newConnectionFactory())
.query("select count(*) from view where val1 >= 10 and val1 <=20")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import org.apache.calcite.schema.impl.ViewTable;
import org.apache.calcite.schema.impl.ViewTableMacro;
import org.apache.calcite.test.CalciteAssert;
import org.apache.calcite.util.Bug;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableMap;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
Expand All @@ -42,7 +42,6 @@
/**
* Test of different boolean expressions (some more complex than others).
*/
@Disabled("RestClient often timeout in PR CI")
@ResourceLock(value = "elasticsearch-scrolls", mode = ResourceAccessMode.READ)
class BooleanLogicTest {

Expand Down Expand Up @@ -120,7 +119,10 @@ private CalciteAssert.ConnectionFactory newConnectionFactory() {
assertEmpty("select * from view where num > 42 and num < 42 and num = 42");
assertEmpty("select * from view where num > 42 or num < 42 and num = 42");
assertSingle("select * from view where num > 42 and num < 42 or num = 42");
assertSingle("select * from view where num > 42 or num < 42 or num = 42");
if (Bug.CALCITE_4965_FIXED) {
assertSingle("select * from view where num > 42 or num < 42 or num = 42");
assertEmpty("select * from view where num is null");
}
assertSingle("select * from view where num >= 42 and num <= 42 and num = 42");
assertEmpty("select * from view where num >= 42 and num <= 42 and num <> 42");
assertEmpty("select * from view where num < 42");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
import org.apache.calcite.schema.impl.ViewTableMacro;
import org.apache.calcite.test.CalciteAssert;
import org.apache.calcite.test.ElasticsearchChecker;
import org.apache.calcite.util.Bug;
import org.apache.calcite.util.TestUtil;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.LineProcessor;
import com.google.common.io.Resources;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
Expand All @@ -55,7 +56,6 @@
* Set of tests for ES adapter. Uses real instance via {@link EmbeddedElasticsearchPolicy}. Document
* source is local {@code zips-mini.json} file (located in test classpath).
*/
@Disabled("RestClient often timeout in PR CI")
@ResourceLock(value = "elasticsearch-scrolls", mode = ResourceAccessMode.READ)
class ElasticSearchAdapterTest {

Expand Down Expand Up @@ -463,6 +463,7 @@ private static Consumer<ResultSet> sortedResultSetChecker(String column,
}

@Test void testFilterSortDesc() {
Assumptions.assumeTrue(Bug.CALCITE_4645_FIXED, "CALCITE-4645");
final String sql = "select * from zips\n"
+ "where pop BETWEEN 95000 AND 100000\n"
+ "order by state desc, pop";
Expand All @@ -476,8 +477,8 @@ private static Consumer<ResultSet> sortedResultSetChecker(String column,

@Test void testInPlan() {
final String[] searches = {
"query: {'constant_score':{filter:{bool:{should:"
+ "[{term:{pop:96074}},{term:{pop:99568}}]}}}}",
"query: {'constant_score':{filter:{terms:{pop:"
+ "[96074, 99568]}}}}",
"script_fields: {longitude:{script:'params._source.loc[0]'}, "
+ "latitude:{script:'params._source.loc[1]'}, "
+ "city:{script: 'params._source.city'}, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ RestClient restClient() {
return client;
}

final RestClient client = RestClient.builder(httpHost()).build();
final RestClient client = RestClient.builder(httpHost())
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder
.setConnectTimeout(60 * 1000) // default 1000
.setSocketTimeout(3 * 60 * 1000)) // default 30000
.build();
closer.add(client);
this.client = client;
return client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.google.common.io.Resources;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
Expand All @@ -71,7 +70,6 @@
/**
* Testing Elasticsearch match query.
*/
@Disabled("RestClient often timeout in PR CI")
@ResourceLock(value = "elasticsearch-scrolls", mode = ResourceAccessMode.READ)
class MatchTest {

Expand All @@ -80,7 +78,6 @@ class MatchTest {

/** Default index/type name. */
private static final String ZIPS = "match-zips";
private static final int ZIPS_SIZE = 149;

/**
* Used to create {@code zips} index and insert zip data in bulk.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.common.collect.ImmutableMap;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
Expand All @@ -42,7 +41,6 @@
/**
* Checks renaming of fields (also upper, lower cases) during projections.
*/
@Disabled("RestClient often timeout in PR CI")
@ResourceLock(value = "elasticsearch-scrolls", mode = ResourceAccessMode.READ)
class ProjectionTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* Tests usage of scrolling API like correct results and resource cleanup
* (delete scroll after scan).
*/
@Disabled("RestClient often timeout in PR CI")
@ResourceLock("elasticsearch-scrolls")
class ScrollingTest {

Expand Down

0 comments on commit 1ce4f05

Please sign in to comment.