Skip to content

Commit 5476160

Browse files
committed
test(integ-test): gate analytics-engine excludes via @RequiresCapability
Migrate the analytics-engine IT exclusions to method/class-level @RequiresCapability annotations so each test self-skips when the analytics engine is active, instead of relying on build.gradle excludes. Add coarse capabilities (backend: vector/geopoint/identifier, untyped NULL literal, filtered aggregate; frontend: response format, pagination/cursor, prepared statement, legacy method query, query error, explain format, function type compat) and reuse existing capabilities where they fit. SQLCorrectnessIT is outside the SQLIntegTestCase hierarchy, so it calls BackendCapabilities.requireCapability directly. Signed-off-by: Chen Dai <daichen@amazon.com>
1 parent cc65d75 commit 5476160

52 files changed

Lines changed: 313 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

integ-test/src/test/java/org/opensearch/sql/legacy/CsvFormatResponseIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_TYPE;
2121
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_WITH_QUOTES;
2222
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ONLINE;
23+
import static org.opensearch.sql.util.Capability.RESPONSE_FORMAT;
2324

2425
import java.io.IOException;
2526
import java.util.ArrayList;
@@ -39,8 +40,10 @@
3940
import org.opensearch.client.RequestOptions;
4041
import org.opensearch.client.Response;
4142
import org.opensearch.sql.legacy.executor.csv.CSVResult;
43+
import org.opensearch.sql.util.RequiresCapability;
4244

4345
/** Tests to cover requests with "?format=csv" parameter */
46+
@RequiresCapability(RESPONSE_FORMAT)
4447
public class CsvFormatResponseIT extends SQLIntegTestCase {
4548

4649
private boolean flatOption = false;

integ-test/src/test/java/org/opensearch/sql/legacy/CursorIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATE_TIME;
1313
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_SIMPLE;
1414
import static org.opensearch.sql.legacy.plugin.RestSqlAction.QUERY_API_ENDPOINT;
15+
import static org.opensearch.sql.util.Capability.PAGINATION_CURSOR;
1516
import static org.opensearch.sql.util.TestUtils.verifyIsV2Cursor;
1617

1718
import java.io.IOException;
@@ -27,7 +28,9 @@
2728
import org.opensearch.client.ResponseException;
2829
import org.opensearch.sql.common.setting.Settings;
2930
import org.opensearch.sql.legacy.utils.StringUtils;
31+
import org.opensearch.sql.util.RequiresCapability;
3032

33+
@RequiresCapability(PAGINATION_CURSOR)
3134
public class CursorIT extends SQLIntegTestCase {
3235

3336
private static final String CURSOR = "cursor";

integ-test/src/test/java/org/opensearch/sql/legacy/JdbcTestIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
import static org.hamcrest.Matchers.containsString;
99
import static org.hamcrest.Matchers.equalTo;
10+
import static org.opensearch.sql.util.Capability.DATETIME_FORMAT_RENDERING;
11+
import static org.opensearch.sql.util.Capability.PERCENTILE_APPROXIMATE;
1012

1113
import java.io.IOException;
1214
import org.json.JSONArray;
1315
import org.json.JSONObject;
1416
import org.junit.Assert;
1517
import org.junit.Ignore;
1618
import org.junit.Test;
19+
import org.opensearch.sql.util.RequiresCapability;
1720

1821
public class JdbcTestIT extends SQLIntegTestCase {
1922

@@ -25,6 +28,7 @@ protected void init() throws Exception {
2528
loadIndex(Index.WEBLOG);
2629
}
2730

31+
@RequiresCapability(PERCENTILE_APPROXIMATE)
2832
public void testPercentilesQuery() {
2933
JSONObject response =
3034
executeJdbcRequest(
@@ -43,6 +47,7 @@ public void testPercentilesQuery() {
4347

4448
// https://github.com/opensearch-project/sql/issues/537
4549
@Test
50+
@RequiresCapability(PERCENTILE_APPROXIMATE)
4651
public void testSlowQuery() throws IOException {
4752
// set slow log threshold = 0s
4853
updateClusterSettings(new ClusterSetting(PERSISTENT, "plugins.sql.slowlog", "0"));
@@ -89,6 +94,7 @@ public void testDivisionInQuery() {
8994
assertThat(response.getJSONArray("datarows").getJSONArray(0).getDouble(0), equalTo(16827.0));
9095
}
9196

97+
@RequiresCapability(DATETIME_FORMAT_RENDERING)
9298
public void testGroupByInQuery() {
9399
JSONObject response =
94100
executeJdbcRequest(

integ-test/src/test/java/org/opensearch/sql/legacy/JoinAliasWriterRuleIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
package org.opensearch.sql.legacy;
77

88
import static org.hamcrest.Matchers.equalTo;
9+
import static org.opensearch.sql.util.Capability.EXPLAIN_FORMAT;
10+
import static org.opensearch.sql.util.Capability.QUERY_ERROR_MESSAGE;
911

1012
import java.io.IOException;
1113
import org.junit.Ignore;
1214
import org.junit.Rule;
1315
import org.junit.Test;
1416
import org.junit.rules.ExpectedException;
1517
import org.opensearch.client.ResponseException;
18+
import org.opensearch.sql.util.RequiresCapability;
1619

1720
/** Test cases for writing missing join table aliases. */
1821
public class JoinAliasWriterRuleIT extends SQLIntegTestCase {
@@ -26,6 +29,7 @@ protected void init() throws Exception {
2629
}
2730

2831
@Test
32+
@RequiresCapability(EXPLAIN_FORMAT)
2933
public void noTableAliasNoCommonColumns() throws IOException {
3034
sameExplain(
3135
query(
@@ -45,6 +49,7 @@ public void noTableAliasNoCommonColumns() throws IOException {
4549
}
4650

4751
@Test
52+
@RequiresCapability(EXPLAIN_FORMAT)
4853
public void oneTableAliasNoCommonColumns() throws IOException {
4954
sameExplain(
5055
query(
@@ -61,6 +66,7 @@ public void oneTableAliasNoCommonColumns() throws IOException {
6166
}
6267

6368
@Test
69+
@RequiresCapability(EXPLAIN_FORMAT)
6470
public void bothTableAliasNoCommonColumns() throws IOException {
6571
sameExplain(
6672
query(
@@ -78,6 +84,7 @@ public void bothTableAliasNoCommonColumns() throws IOException {
7884

7985
@Test
8086
@Ignore
87+
@RequiresCapability(EXPLAIN_FORMAT)
8188
public void tableNamesWithTypeName() throws IOException {
8289
sameExplain(
8390
query(
@@ -98,6 +105,7 @@ public void tableNamesWithTypeName() throws IOException {
98105

99106
@Ignore
100107
@Test
108+
@RequiresCapability(EXPLAIN_FORMAT)
101109
public void tableNamesWithTypeNameExplicitTableAlias() throws IOException {
102110
sameExplain(
103111
query(
@@ -114,6 +122,7 @@ public void tableNamesWithTypeNameExplicitTableAlias() throws IOException {
114122
}
115123

116124
@Test
125+
@RequiresCapability(EXPLAIN_FORMAT)
117126
public void actualTableNameAsAliasOnColumnFields() throws IOException {
118127
sameExplain(
119128
query(
@@ -130,6 +139,7 @@ public void actualTableNameAsAliasOnColumnFields() throws IOException {
130139
}
131140

132141
@Test
142+
@RequiresCapability(EXPLAIN_FORMAT)
133143
public void actualTableNameAsAliasOnColumnFieldsTwo() throws IOException {
134144
sameExplain(
135145
query(
@@ -150,6 +160,7 @@ public void actualTableNameAsAliasOnColumnFieldsTwo() throws IOException {
150160
}
151161

152162
@Test
163+
@RequiresCapability(EXPLAIN_FORMAT)
153164
public void columnsWithTableAliasNotAffected() throws IOException {
154165
sameExplain(
155166
query(
@@ -166,6 +177,7 @@ public void columnsWithTableAliasNotAffected() throws IOException {
166177
}
167178

168179
@Test
180+
@RequiresCapability(QUERY_ERROR_MESSAGE)
169181
public void commonColumnWithoutTableAliasDifferentTables() throws IOException {
170182
exception.expect(ResponseException.class);
171183
exception.expectMessage("Field name [firstname] is ambiguous");
@@ -179,6 +191,7 @@ public void commonColumnWithoutTableAliasDifferentTables() throws IOException {
179191
}
180192

181193
@Test
194+
@RequiresCapability(QUERY_ERROR_MESSAGE)
182195
public void sameTablesNoAliasAndNoAliasOnColumns() throws IOException {
183196
exception.expect(ResponseException.class);
184197
exception.expectMessage("Not unique table/alias: [opensearch-sql_test_index_bank]");
@@ -192,6 +205,7 @@ public void sameTablesNoAliasAndNoAliasOnColumns() throws IOException {
192205
}
193206

194207
@Test
208+
@RequiresCapability(QUERY_ERROR_MESSAGE)
195209
public void sameTablesNoAliasWithTableNameAsAliasOnColumns() throws IOException {
196210
exception.expect(ResponseException.class);
197211
exception.expectMessage("Not unique table/alias: [opensearch-sql_test_index_bank]");
@@ -206,6 +220,7 @@ public void sameTablesNoAliasWithTableNameAsAliasOnColumns() throws IOException
206220
}
207221

208222
@Test
223+
@RequiresCapability(EXPLAIN_FORMAT)
209224
public void sameTablesWithExplicitAliasOnFirst() throws IOException {
210225
sameExplain(
211226
query(
@@ -221,6 +236,7 @@ public void sameTablesWithExplicitAliasOnFirst() throws IOException {
221236
}
222237

223238
@Test
239+
@RequiresCapability(EXPLAIN_FORMAT)
224240
public void sameTablesWithExplicitAliasOnSecond() throws IOException {
225241
sameExplain(
226242
query(

integ-test/src/test/java/org/opensearch/sql/legacy/MalformedQueryIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55

66
package org.opensearch.sql.legacy;
77

8+
import static org.opensearch.sql.util.Capability.QUERY_ERROR_MESSAGE;
9+
810
import java.io.IOException;
911
import java.util.Locale;
1012
import org.apache.hc.core5.http.ParseException;
1113
import org.apache.hc.core5.http.io.entity.EntityUtils;
1214
import org.json.JSONObject;
1315
import org.junit.Assert;
1416
import org.opensearch.client.ResponseException;
17+
import org.opensearch.sql.util.RequiresCapability;
1518

1619
/** Tests for clean handling of various types of invalid queries */
20+
@RequiresCapability(QUERY_ERROR_MESSAGE)
1721
public class MalformedQueryIT extends SQLIntegTestCase {
1822
@Override
1923
protected void init() throws Exception {

integ-test/src/test/java/org/opensearch/sql/legacy/MethodQueryIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
import static org.hamcrest.Matchers.both;
99
import static org.hamcrest.Matchers.containsString;
10+
import static org.opensearch.sql.util.Capability.EXPLAIN_FORMAT;
11+
import static org.opensearch.sql.util.Capability.LEGACY_METHOD_QUERY;
1012

1113
import java.io.IOException;
1214
import java.util.Locale;
1315
import org.junit.Assert;
1416
import org.junit.Ignore;
1517
import org.junit.Test;
18+
import org.opensearch.sql.util.RequiresCapability;
1619

1720
/**
1821
* 定製方法查詢.
@@ -41,6 +44,7 @@ protected void init() throws Exception {
4144
* @throws IOException
4245
*/
4346
@Test
47+
@RequiresCapability(EXPLAIN_FORMAT)
4448
public void queryTest() throws IOException {
4549
final String result =
4650
explainQuery(
@@ -70,6 +74,7 @@ public void queryTest() throws IOException {
7074
* @throws IOException
7175
*/
7276
@Test
77+
@RequiresCapability(EXPLAIN_FORMAT)
7378
public void matchQueryTest() throws IOException {
7479
final String result =
7580
explainQuery(
@@ -153,6 +158,7 @@ public void scoreQueryTest() throws IOException {
153158
}
154159

155160
@Test
161+
@RequiresCapability(LEGACY_METHOD_QUERY)
156162
public void regexpQueryTest() throws IOException {
157163
final String result =
158164
explainQuery(
@@ -168,6 +174,7 @@ public void regexpQueryTest() throws IOException {
168174
}
169175

170176
@Test
177+
@RequiresCapability(LEGACY_METHOD_QUERY)
171178
public void negativeRegexpQueryTest() throws IOException {
172179
final String result =
173180
explainQuery(
@@ -198,6 +205,7 @@ public void negativeRegexpQueryTest() throws IOException {
198205
* @throws IOException
199206
*/
200207
@Test
208+
@RequiresCapability(LEGACY_METHOD_QUERY)
201209
public void wildcardQueryTest() throws IOException {
202210
final String result =
203211
explainQuery(

integ-test/src/test/java/org/opensearch/sql/legacy/ObjectFieldSelectIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package org.opensearch.sql.legacy;
77

88
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DEEP_NESTED;
9+
import static org.opensearch.sql.util.Capability.STRUCT_PARENT_FIELD;
910
import static org.opensearch.sql.util.MatcherUtils.rows;
1011
import static org.opensearch.sql.util.MatcherUtils.schema;
1112
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
@@ -16,11 +17,13 @@
1617
import org.junit.Test;
1718
import org.opensearch.sql.common.setting.Settings;
1819
import org.opensearch.sql.legacy.utils.StringUtils;
20+
import org.opensearch.sql.util.RequiresCapability;
1921

2022
/**
2123
* Integration test for OpenSearch object field (and nested field). This class is focused on simple
2224
* SELECT-FROM query to ensure right column number and value is returned.
2325
*/
26+
@RequiresCapability(STRUCT_PARENT_FIELD)
2427
public class ObjectFieldSelectIT extends SQLIntegTestCase {
2528

2629
@Override

integ-test/src/test/java/org/opensearch/sql/legacy/PointInTimeLeakIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import static org.hamcrest.Matchers.equalTo;
99
import static org.hamcrest.Matchers.greaterThan;
10+
import static org.opensearch.sql.util.Capability.PAGINATION_CURSOR;
1011

1112
import java.io.IOException;
1213
import org.json.JSONArray;
@@ -17,12 +18,14 @@
1718
import org.opensearch.client.Response;
1819
import org.opensearch.client.ResponseException;
1920
import org.opensearch.sql.legacy.utils.StringUtils;
21+
import org.opensearch.sql.util.RequiresCapability;
2022

2123
/**
2224
* Integration test verifying PIT contexts are created only when needed and properly cleaned up.
2325
*
2426
* @see <a href="https://github.com/opensearch-project/sql/issues/5002">Issue #5002</a>
2527
*/
28+
@RequiresCapability(PAGINATION_CURSOR)
2629
public class PointInTimeLeakIT extends SQLIntegTestCase {
2730

2831
private static final String TEST_INDEX = "test-logs-2025.01.01";

0 commit comments

Comments
 (0)