Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@
public class AnalyticsEngineProfileIT extends OpenSearchRestTestCase {

private static final String INDEX = "profile_test";
private static boolean initialized = false;

private void ensureSetup() throws IOException {
if (initialized) return;
// OpenSearchRestTestCase wipes indices between tests, so a static seed-once flag leaves every
// test after the first querying a deleted index. Probe the index instead and re-seed when the
// wipe removed it.
if (indexExists()) return;
enableCalcite();
createCompositeIndex();
ingestData();
initialized = true;
}

private boolean indexExists() throws IOException {
try {
return client()
.performRequest(new Request("HEAD", "/" + INDEX))
.getStatusLine()
.getStatusCode()
== 200;
} catch (ResponseException e) {
return false;
}
}

private void enableCalcite() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static java.sql.Types.BIGINT;
import static java.sql.Types.VARCHAR;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.util.Capability.DIRECT_LUCENE_QUERY;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
Expand All @@ -26,11 +27,13 @@
import org.opensearch.sql.opensearch.storage.OpenSearchIndex;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.InternalRestHighLevelClient;
import org.opensearch.sql.util.RequiresCapability;

/**
* Integration test demonstrating the integration and usage of the Unified Query API with OpenSearch
* as a data source.
*/
@RequiresCapability(DIRECT_LUCENE_QUERY)
public class UnifiedQueryOpenSearchIT extends PPLIntegTestCase implements ResultSetAssertion {

private UnifiedQueryContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.plugin.rest.RestPPLQueryAction.QUERY_API_ENDPOINT;
import static org.opensearch.sql.util.Capability.PROFILE_SHAPE;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;

Expand All @@ -18,6 +19,7 @@
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.RequiresCapability;

/**
* Integration tests for queries dispatched to the complex worker pool. Verifies that queries
Expand Down Expand Up @@ -53,6 +55,7 @@ public void testParseCommandDispatchesToComplexPool() throws IOException {
}

@Test
@RequiresCapability(PROFILE_SHAPE)
public void testComplexPoolProfileIncludesThreadPool() throws IOException {
// Query with parse to trigger complex pool
String query =
Expand All @@ -74,6 +77,7 @@ public void testComplexPoolProfileIncludesThreadPool() throws IOException {
}

@Test
@RequiresCapability(PROFILE_SHAPE)
public void testSimpleQueryUsesWorkerPool() throws IOException {
// Query without scripts — should use sql-worker pool
String query = String.format("source=%s | fields account_number | head 1", TEST_INDEX_BANK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.sql.calcite.big5;

import static org.opensearch.sql.util.Capability.LUCENE_PUSHDOWN_EXPLAIN;
import static org.opensearch.sql.util.MatcherUtils.assertYamlEqualsIgnoreId;

import java.io.IOException;
Expand All @@ -16,8 +17,10 @@
import org.junit.runners.MethodSorters;
import org.opensearch.common.collect.MapBuilder;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.RequiresCapability;

@FixMethodOrder(MethodSorters.JVM)
@RequiresCapability(LUCENE_PUSHDOWN_EXPLAIN)
public class PPLBig5IT extends PPLIntegTestCase {
protected static final MapBuilder<String, Long> summary = MapBuilder.newMapBuilder();

Expand All @@ -32,6 +35,11 @@ public void init() throws Exception {
public static void reset() throws IOException {
long total = 0;
Map<String, Long> map = summary.immutableMap();
if (map.isEmpty()) {
// Every test in the class was skipped (e.g. capability-gated on the analytics route);
// there is nothing to summarize and the average below would divide by zero.
return;
}
for (long duration : map.values()) {
total += duration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

package org.opensearch.sql.calcite.clickbench;

import static org.opensearch.sql.util.Capability.LUCENE_PUSHDOWN_EXPLAIN;

import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import org.opensearch.sql.util.RequiresCapability;

@FixMethodOrder(MethodSorters.JVM)
@RequiresCapability(LUCENE_PUSHDOWN_EXPLAIN)
public class CalcitePPLClickBenchIT extends PPLClickBenchIT {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public void init() throws Exception {
public static void reset() throws IOException {
long total = 0;
Map<String, Long> map = summary.immutableMap();
if (map.isEmpty()) {
// Every test in the class was skipped (e.g. capability-gated on the analytics route);
// there is nothing to summarize and the average below would divide by zero.
return;
}
for (long duration : map.values()) {
total += duration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public void init() throws Exception {
+ "\"t\":{\"type\":\"date\",\"format\":\"HH:mm:ss\"}}}}";
TestUtils.createIndexByRestClient(client(), INDEX, mapping);

Request doc = new Request("PUT", "/" + INDEX + "/_doc/1?refresh=true");
Request doc = TestUtils.seedDocRequest(INDEX, "1");
doc.setJsonEntity(
"{\"ts\":\"2024-03-15 10:30:00\","
+ "\"ts_nanos\":\"2024-03-15T10:30:00.123456789Z\","
+ "\"d\":\"2024-03-15\","
+ "\"t\":\"10:30:00\"}");
client().performRequest(doc);

Request doc2 = new Request("PUT", "/" + INDEX + "/_doc/2?refresh=true");
Request doc2 = TestUtils.seedDocRequest(INDEX, "2");
doc2.setJsonEntity(
"{\"ts\":\"2024-03-16 23:59:59\","
+ "\"ts_nanos\":\"2024-03-16T23:59:59.999999999Z\","
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.opensearch.sql.legacy.TestsConstants.*;
import static org.opensearch.sql.util.Capability.BIN_TIME_FIELD_BUCKETING;
import static org.opensearch.sql.util.Capability.STRICT_QUERY_REJECTION;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand Down Expand Up @@ -1008,6 +1009,7 @@ public void testStatsWithBinsOnTimeAndTermField_Avg() throws IOException {
}

@Test
@RequiresCapability(STRICT_QUERY_REJECTION)
public void testBinsOnTimeFieldWithPushdownDisabled_ShouldFail() throws IOException {
// Verify that bins parameter on timestamp fields fails with clear error when pushdown disabled
enabledOnlyWhenPushdownIsDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.util.Capability.COMPARISON_DELEGATION;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand All @@ -17,6 +18,7 @@
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.RequiresCapability;

/** Integration tests for the PPL convert command with Calcite enabled. */
public class CalciteConvertCommandIT extends PPLIntegTestCase {
Expand Down Expand Up @@ -370,6 +372,7 @@ public void testConvertTimeformatWithMultipleFunctions() throws IOException {
}

@Test
@RequiresCapability(COMPARISON_DELEGATION)
public void testConvertTimeformatWithWhere() throws IOException {
JSONObject result =
executeQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.opensearch.sql.calcite.remote;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.util.Capability.ERROR_REPORT_CONTEXT;
import static org.opensearch.sql.util.TestUtils.getResponseBody;

import java.io.IOException;
Expand All @@ -14,6 +15,7 @@
import org.opensearch.client.Request;
import org.opensearch.client.ResponseException;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.RequiresCapability;

/**
* Integration tests for error report builder with stage tracking. Validates that errors include
Expand All @@ -29,6 +31,7 @@ public void init() throws Exception {
}

@Test
@RequiresCapability(ERROR_REPORT_CONTEXT)
public void testFieldNotFoundErrorIncludesStage() throws IOException {
ResponseException exception =
assertThrows(
Expand Down Expand Up @@ -68,6 +71,7 @@ public void testFieldNotFoundErrorIncludesStage() throws IOException {
}

@Test
@RequiresCapability(ERROR_REPORT_CONTEXT)
public void testIndexNotFoundErrorIncludesStage() throws IOException {
ResponseException exception =
assertThrows(
Expand All @@ -87,6 +91,7 @@ public void testIndexNotFoundErrorIncludesStage() throws IOException {
}

@Test
@RequiresCapability(ERROR_REPORT_CONTEXT)
public void testMultipleFieldErrorsIncludeStage() throws IOException {
ResponseException exception =
assertThrows(
Expand Down Expand Up @@ -143,6 +148,7 @@ public void testFieldNotFoundIncludesErrorCode() throws IOException {
}

@Test
@RequiresCapability(ERROR_REPORT_CONTEXT)
public void testLocationMessagesAreUserFriendly() throws IOException {
ResponseException exception =
assertThrows(
Expand Down Expand Up @@ -181,6 +187,7 @@ public void testLocationMessagesAreUserFriendly() throws IOException {
}

@Test
@RequiresCapability(ERROR_REPORT_CONTEXT)
public void testStageDescriptionIsUserFriendly() throws IOException {
ResponseException exception =
assertThrows(
Expand Down Expand Up @@ -220,6 +227,7 @@ public void testStageDescriptionIsUserFriendly() throws IOException {
// the flattened mapping. It used to surface an opaque NullPointerException; it must now report a
// structured FIELD_NOT_FOUND error with a suggestion.
@Test
@RequiresCapability(ERROR_REPORT_CONTEXT)
public void testAliasToUnresolvablePathIncludesStructuredError() throws IOException {
String index = "test_alias_unresolved_keyword";
Request createIndex = new Request("PUT", "/" + index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DEEP_NESTED;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_TELEMETRY;
import static org.opensearch.sql.util.Capability.MULTI_VALUE_FIELD_LOAD;
import static org.opensearch.sql.util.Capability.STRUCT_PARENT_FIELD;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand All @@ -20,6 +22,7 @@
import org.opensearch.client.Request;
import org.opensearch.sql.legacy.TestUtils;
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.RequiresCapability;

public class CalciteEvalCommandIT extends PPLIntegTestCase {

Expand All @@ -30,7 +33,13 @@ public void init() throws Exception {

loadIndex(Index.BANK);
loadIndex(Index.TELEMETRY);
loadIndex(Index.DEEP_NESTED);
// deep_nested has a multi-value array for a scalar-mapped field, which the parquet store
// rejects at bulk load (MULTI_VALUE_FIELD_LOAD); skip the load on the AE route so it
// doesn't abort init() for the independent tests. The dependent tests are
// @RequiresCapability-gated.
if (!isAnalyticsParquetIndicesEnabled()) {
loadIndex(Index.DEEP_NESTED);
}

// Pre-create test_eval through the helper so the analytics-engine compatibility run
// (tests.analytics.parquet_indices=true) provisions it as a parquet-backed composite
Expand All @@ -48,15 +57,15 @@ public void init() throws Exception {
TestUtils.createIndexByRestClient(client(), "test_eval", testEvalMapping);

// Create test data for string concatenation
Request request1 = new Request("PUT", "/test_eval/_doc/1?refresh=true");
Request request1 = TestUtils.seedDocRequest("test_eval", "1");
request1.setJsonEntity("{\"name\": \"Alice\", \"age\": 25, \"title\": \"Engineer\"}");
client().performRequest(request1);

Request request2 = new Request("PUT", "/test_eval/_doc/2?refresh=true");
Request request2 = TestUtils.seedDocRequest("test_eval", "2");
request2.setJsonEntity("{\"name\": \"Bob\", \"age\": 30, \"title\": \"Manager\"}");
client().performRequest(request2);

Request request3 = new Request("PUT", "/test_eval/_doc/3?refresh=true");
Request request3 = TestUtils.seedDocRequest("test_eval", "3");
request3.setJsonEntity("{\"name\": \"Charlie\", \"age\": null, \"title\": \"Analyst\"}");
client().performRequest(request3);
}
Expand All @@ -67,12 +76,12 @@ public void init() throws Exception {
// from the document contents. Using dynamic mapping keeps the init idempotent across
// repeated `@Before` invocations in the preserved cluster.
if (!TestUtils.isIndexExist(client(), "test_eval_agent")) {
Request agentDoc1 = new Request("PUT", "/test_eval_agent/_doc/1?refresh=true");
Request agentDoc1 = TestUtils.seedDocRequest("test_eval_agent", "1");
agentDoc1.setJsonEntity(
"{\"agent\": {\"name\": \"winlogbeat\", \"version\": \"7.0\"}, \"message\": \"hello\"}");
client().performRequest(agentDoc1);

Request agentDoc2 = new Request("PUT", "/test_eval_agent/_doc/2?refresh=true");
Request agentDoc2 = TestUtils.seedDocRequest("test_eval_agent", "2");
agentDoc2.setJsonEntity(
"{\"agent\": {\"name\": \"filebeat\", \"version\": \"8.1\"}, \"message\": \"world\"}");
client().performRequest(agentDoc2);
Expand Down Expand Up @@ -133,6 +142,7 @@ public void testEvalStringConcatenationWithLiterals() throws IOException {
}

@Test
@RequiresCapability(STRUCT_PARENT_FIELD)
public void testEvalDottedNameDoesNotDropStructParent() throws IOException {
// Reviewer's case from PR #5351: assigning a new dotted-path column must not remove the
// struct-parent column that happens to be a prefix of the eval target.
Expand All @@ -154,6 +164,7 @@ public void testEvalDottedNameDoesNotDropStructParent() throws IOException {
}

@Test
@RequiresCapability(STRUCT_PARENT_FIELD)
public void testEvalDottedNamePreservesStructParent_ImplicitProject() throws IOException {
// Complementary coverage for the reviewer's case without the explicit trailing projection.
// With the implicit `fields *` (AllFields) that the PPL parser appends, the downstream
Expand Down Expand Up @@ -240,6 +251,11 @@ public void testEvalStringConcatenationWithExistingData() throws IOException {
}

@Test
@RequiresCapability(
value = MULTI_VALUE_FIELD_LOAD,
note =
"reads deep_nested whose multi-value field can't load on the AE store"
+ " (MULTI_VALUE_FIELD_LOAD).")
public void testStruckFieldAndSubFieldWithHead() throws IOException {
JSONObject result =
executeQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ARRAY;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_SIMPLE;
import static org.opensearch.sql.util.Capability.DOC_MUTATION;
import static org.opensearch.sql.util.Capability.MULTI_VALUE_FIELD_LOAD;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand All @@ -22,12 +23,19 @@
import org.opensearch.sql.ppl.PPLIntegTestCase;
import org.opensearch.sql.util.RequiresCapability;

@RequiresCapability(MULTI_VALUE_FIELD_LOAD)
public class CalciteExpandCommandIT extends PPLIntegTestCase {
@Override
public void init() throws Exception {
super.init();
loadIndex(Index.NESTED_SIMPLE);
loadIndex(Index.ARRAY);
// array has a multi-value array for a scalar-mapped field, which the parquet store
// rejects at bulk load (MULTI_VALUE_FIELD_LOAD); skip the load on the AE route so it
// doesn't abort init() for the independent tests. The dependent tests are
// @RequiresCapability-gated.
if (!isAnalyticsParquetIndicesEnabled()) {
loadIndex(Index.ARRAY);
}
enableCalcite();
}

Expand Down Expand Up @@ -154,6 +162,11 @@ public void testExpandOnNested() throws Exception {
// This makes it difficult to implement expand on arrays.
@Ignore
@Test
@RequiresCapability(
value = MULTI_VALUE_FIELD_LOAD,
note =
"reads array whose multi-value field can't load on the AE store"
+ " (MULTI_VALUE_FIELD_LOAD).")
public void testExpandOnArray() throws Exception {
JSONObject response =
executeQuery(String.format("source=%s | expand strings", TEST_INDEX_ARRAY));
Expand Down
Loading
Loading