From c1a91fc016e5296f7b0d1131b30cae196fcd8934 Mon Sep 17 00:00:00 2001 From: Yury Fridlyand Date: Mon, 6 Jun 2022 12:55:53 -0700 Subject: [PATCH] Rework on integration tests. Add tests for PPL. Signed-off-by: Yury Fridlyand --- .../sql/ppl/RelevanceFunctionIT.java | 44 +++++++++++++++++++ .../sql/sql/SimpleQueryStringIT.java | 8 ++-- 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionIT.java diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionIT.java new file mode 100644 index 0000000000..323c56acaa --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionIT.java @@ -0,0 +1,44 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BEER; +import static org.opensearch.sql.util.MatcherUtils.rows; +import static org.opensearch.sql.util.MatcherUtils.schema; +import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; +import static org.opensearch.sql.util.MatcherUtils.verifySchema; +import static org.opensearch.sql.util.MatcherUtils.verifySome; + +import java.io.IOException; +import org.junit.jupiter.api.Test; + +public class RelevanceFunctionIT extends PPLIntegTestCase { + @Override + public void init() throws IOException { + loadIndex(Index.BEER); + } + + @Test + public void test1() throws IOException { + String query = "SOURCE=" + TEST_INDEX_BEER + + " | WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')"; + var result = executeQuery(query); + //verifyDataRows(result, rows(32)); + + assertNotEquals(0, result.getInt("total")); + } + + @Test + public void verify_wildcard_test() throws IOException { + String query1 = "SOURCE=" + TEST_INDEX_BEER + + " | WHERE simple_query_string(['Tags'], 'taste')"; + var result1 = executeQuery(query1); + String query2 = "SOURCE=" + TEST_INDEX_BEER + + " | WHERE simple_query_string(['T*'], 'taste')"; + var result2 = executeQuery(query2); + assertNotEquals(result2.getInt("total"), result1.getInt("total")); + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/sql/SimpleQueryStringIT.java b/integ-test/src/test/java/org/opensearch/sql/sql/SimpleQueryStringIT.java index 9f2ed6ac33..ec1f804a43 100644 --- a/integ-test/src/test/java/org/opensearch/sql/sql/SimpleQueryStringIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/sql/SimpleQueryStringIT.java @@ -5,6 +5,8 @@ package org.opensearch.sql.sql; +import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BEER; + import java.io.IOException; import org.json.JSONObject; import org.junit.jupiter.api.Test; @@ -27,7 +29,7 @@ public void init() throws IOException { @Test public void test1() throws IOException { String query = "SELECT count(*) FROM " - + Index.BEER.getName() + " WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')"; + + TEST_INDEX_BEER + " WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')"; var result = new JSONObject(executeQuery(query, "jdbc")); assertNotEquals(0, result.getInt("total")); } @@ -35,10 +37,10 @@ public void test1() throws IOException { @Test public void verify_wildcard_test() throws IOException { String query1 = "SELECT count(*) FROM " - + Index.BEER.getName() + " WHERE simple_query_string(['Tags'], 'taste')"; + + TEST_INDEX_BEER + " WHERE simple_query_string(['Tags'], 'taste')"; var result1 = new JSONObject(executeQuery(query1, "jdbc")); String query2 = "SELECT count(*) FROM " - + Index.BEER.getName() + " WHERE simple_query_string(['T*'], 'taste')"; + + TEST_INDEX_BEER + " WHERE simple_query_string(['T*'], 'taste')"; var result2 = new JSONObject(executeQuery(query2, "jdbc")); assertNotEquals(result2.getInt("total"), result1.getInt("total")); }