Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from jngz-es/es-test-6.6.2
Browse files Browse the repository at this point in the history
Es test 6.6.2
  • Loading branch information
jngz-es authored Mar 26, 2019
2 parents 05d729b + 7f31a11 commit ae6ece5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
buildscript {

ext {
es_version = System.getProperty("es.version", "6.5.4")
es_version = System.getProperty("es.version", "6.6.2")
}
// This isn't applying from repositories.gradle so repeating it here
repositories {
Expand Down Expand Up @@ -46,7 +46,7 @@ repositories {
}

ext {
opendistroVersion = '0.7.0'
opendistroVersion = '0.8.0'
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
}

Expand Down Expand Up @@ -95,7 +95,7 @@ compileTestJava {
}

// TODO: Need to update integration test to use ElasticSearch test framework
test {
unitTest {
include '**/*Test.class'
exclude 'com/amazon/opendistroforelasticsearch/sql/intgtest/**'
// Gradle runs unit test using a working directory other and project root
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazon.opendistroforelasticsearch</groupId>
<artifactId>opendistro-sql</artifactId>
<version>6.5.4.0</version>
<version>6.6.2.0</version>
<packaging>jar</packaging>
<description>Open Distro for Elasticsearch SQL</description>
<name>opendistro-sql</name>
Expand All @@ -27,7 +27,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<runSuite>**/MainTestSuite.class</runSuite>
<elasticsearch.plugin.name>opendistro-sql</elasticsearch.plugin.name>
<elasticsearch.version>6.5.4</elasticsearch.version>
<elasticsearch.version>6.6.2</elasticsearch.version>
<elasticsearch.plugin.classname>com.amazon.opendistroforelasticsearch.sql.plugin.SqlPlug</elasticsearch.plugin.classname>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@

package com.amazon.opendistroforelasticsearch.sql.esintgtest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.env.Environment;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ExternalTestCluster;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.TestCluster;
import org.elasticsearch.transport.MockTcpTransportPlugin;
Expand All @@ -45,7 +44,7 @@

public class CustomExternalTestCluster extends TestCluster {

private static final Logger logger = Loggers.getLogger(ExternalTestCluster.class);
private static final Logger logger = LogManager.getLogger(CustomExternalTestCluster.class);

private static final AtomicInteger counter = new AtomicInteger();
public static final String EXTERNAL_CLUSTER_PREFIX = "external_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import com.amazon.opendistroforelasticsearch.sql.parser.ElasticSqlExprParser;
import com.amazon.opendistroforelasticsearch.sql.parser.SqlParser;
import com.amazon.opendistroforelasticsearch.sql.query.maker.QueryMaker;
import com.amazon.opendistroforelasticsearch.sql.util.MatcherUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.hamcrest.*;
import org.junit.Test;

Expand All @@ -45,14 +47,14 @@ public void simpleFormatCondition() {
List<QueryBuilder> q = query(SELECT_CNT_FROM_DATE + "WHERE date_format(creationDate, 'YYYY') < '2018'");

assertThat(q, hasQueryWithValue("fieldName", equalTo("creationDate")));
assertThat(q, hasQueryWithValue("format", hasFieldWithValue("format", "has format", equalTo("YYYY"))));
assertThat(q, hasQueryWithValueGetter(MatcherUtils.featureValueOf("has format", equalTo("YYYY"), f->((RangeQueryBuilder)f).format())));
}

@Test
public void equalCondition() {
List<QueryBuilder> q = query(SELECT_CNT_FROM_DATE + "WHERE date_format(creationDate, 'YYYY-MM-dd') = '2018-04-02'");

assertThat(q, hasQueryWithValue("format", hasFieldWithValue("format", "has format", equalTo("YYYY-MM-dd"))));
assertThat(q, hasQueryWithValueGetter(MatcherUtils.featureValueOf("has format", equalTo("YYYY-MM-dd"), f->((RangeQueryBuilder)f).format())));

// Equality query for date_format is created with a rangeQuery where the 'from' and 'to' values are equal to the value we are equating to
assertThat(q, hasQueryWithValue("from", equalTo(BytesRefs.toBytesRef("2018-04-02")))); // converting string to bytes ref as RangeQueryBuilder stores it this way
Expand Down Expand Up @@ -129,4 +131,10 @@ private <T, U> Matcher<Iterable<? super T>> hasNotQueryWithValue(String name, Ma
hasItem(hasFieldWithValue("mustNotClauses", "has mustNotClauses",
hasItem(hasFieldWithValue(name, "has " + name, matcher))))));
}

private <T, U> Matcher<Iterable<? super T>> hasQueryWithValueGetter(Matcher<? super U> matcher) {
return hasItem(
hasFieldWithValue("mustClauses", "has mustClauses",
hasItem(matcher)));
}
}

0 comments on commit ae6ece5

Please sign in to comment.