Skip to content

Commit 4f6f6a1

Browse files
committed
Try to fix BWC test (4)
1 parent 8017c78 commit 4f6f6a1

File tree

6 files changed

+36
-20
lines changed

6 files changed

+36
-20
lines changed

x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;
2323
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
24-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
24+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SOURCE_FIELD_MAPPING;
2525

2626
public class MixedClusterEsqlSpecIT extends EsqlSpecTestCase {
2727
@ClassRule
@@ -92,8 +92,8 @@ protected boolean supportsIndexModeLookup() throws IOException {
9292
}
9393

9494
@Override
95-
protected boolean supportsUnmappedFields() throws IOException {
96-
return hasCapabilities(List.of(UNMAPPED_FIELDS.capabilityName()));
95+
protected boolean supportsSourceFieldMapping() throws IOException {
96+
return hasCapabilities(List.of(SOURCE_FIELD_MAPPING.capabilityName()));
9797
}
9898

9999
@Override

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ protected boolean supportsIndexModeLookup() throws IOException {
297297
}
298298

299299
@Override
300-
protected boolean supportsUnmappedFields() throws IOException {
300+
protected boolean supportsSourceFieldMapping() {
301301
return false;
302302
}
303303
}

x-pack/plugin/esql/qa/server/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/multi_node/EsqlSpecIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
1313
import org.junit.ClassRule;
1414

15+
import java.io.IOException;
16+
1517
public class EsqlSpecIT extends EsqlSpecTestCase {
1618
@ClassRule
1719
public static ElasticsearchCluster cluster = Clusters.testCluster(spec -> spec.plugin("inference-service-test"));
@@ -39,7 +41,7 @@ protected boolean enableRoundingDoubleValuesOnAsserting() {
3941
}
4042

4143
@Override
42-
protected boolean shouldSkipTestsWithSemanticTextFields() {
43-
return true;
44+
protected boolean supportsSourceFieldMapping() throws IOException {
45+
return false;
4446
}
4547
}

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlSpecIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@ protected boolean enableRoundingDoubleValuesOnAsserting() {
4747
protected boolean shouldSkipTestsWithSemanticTextFields() {
4848
return cluster.getNumNodes() > 1;
4949
}
50+
51+
@Override
52+
protected boolean supportsSourceFieldMapping() {
53+
return cluster.getNumNodes() == 1;
54+
}
5055
}

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
7272
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
7373
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SEMANTIC_TEXT_TYPE;
74+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SOURCE_FIELD_MAPPING;
7475

7576
// This test can run very long in serverless configurations
7677
@TimeoutSuite(millis = 30 * TimeUnits.MINUTE)
@@ -137,9 +138,9 @@ public void setup() throws IOException {
137138
}
138139

139140
boolean supportsLookup = supportsIndexModeLookup();
140-
boolean supportsUnmappedFields = supportsUnmappedFields();
141-
if (indexExists(availableDatasetsForEs(client(), supportsLookup, supportsUnmappedFields).iterator().next().indexName()) == false) {
142-
loadDataSetIntoEs(client(), supportsLookup, supportsUnmappedFields);
141+
boolean supportsSourceMapping = supportsSourceFieldMapping();
142+
if (indexExists(availableDatasetsForEs(client(), supportsLookup, supportsSourceMapping).iterator().next().indexName()) == false) {
143+
loadDataSetIntoEs(client(), supportsLookup, supportsSourceMapping);
143144
}
144145
}
145146

@@ -186,6 +187,9 @@ protected void shouldSkipTest(String testName) throws IOException {
186187
if (shouldSkipTestsWithSemanticTextFields()) {
187188
assumeFalse("semantic_text tests are muted", testCase.requiredCapabilities.contains(SEMANTIC_TEXT_TYPE.capabilityName()));
188189
}
190+
if (supportsSourceFieldMapping() == false) {
191+
assumeFalse("source mapping tests are muted", testCase.requiredCapabilities.contains(SOURCE_FIELD_MAPPING.capabilityName()));
192+
}
189193
}
190194

191195
protected static void checkCapabilities(RestClient client, TestFeatureService testFeatureService, String testName, CsvTestCase testCase)
@@ -243,7 +247,7 @@ protected boolean supportsIndexModeLookup() throws IOException {
243247
return true;
244248
}
245249

246-
protected boolean supportsUnmappedFields() throws IOException {
250+
protected boolean supportsSourceFieldMapping() throws IOException {
247251
return true;
248252
}
249253

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static void main(String[] args) throws IOException {
292292
public static Set<TestDataset> availableDatasetsForEs(
293293
RestClient client,
294294
boolean supportsIndexModeLookup,
295-
boolean supportsUnmappedFields
295+
boolean supportsSourceFieldMapping
296296
) throws IOException {
297297
boolean inferenceEnabled = clusterHasInferenceEndpoint(client);
298298

@@ -301,7 +301,7 @@ public static Set<TestDataset> availableDatasetsForEs(
301301
for (TestDataset dataset : CSV_DATASET_MAP.values()) {
302302
if ((inferenceEnabled || dataset.requiresInferenceEndpoint == false)
303303
&& (supportsIndexModeLookup || isLookupDataset(dataset) == false)
304-
&& (supportsUnmappedFields || isUnmappedFieldsDataset(dataset) == false)) {
304+
&& (supportsSourceFieldMapping || isSourceMappingDataset(dataset) == false)) {
305305
testDataSets.add(dataset);
306306
}
307307
}
@@ -315,33 +315,38 @@ private static boolean isLookupDataset(TestDataset dataset) throws IOException {
315315
return (mode != null && mode.equalsIgnoreCase("lookup"));
316316
}
317317

318-
private static boolean isUnmappedFieldsDataset(TestDataset dataset) throws IOException {
318+
private static boolean isSourceMappingDataset(TestDataset dataset) throws IOException {
319319
if (dataset.mappingFileName() == null) {
320320
return true;
321321
}
322322
String mappingJsonText = readTextFile(getResource("/" + dataset.mappingFileName()));
323323
JsonNode mappingNode = new ObjectMapper().readTree(mappingJsonText);
324-
// BWC tests don't support _source field directives, so don't load those datasets.
324+
// BWC tests don't support _source field mappings, so don't load those datasets.
325325
return mappingNode.get("_source") != null;
326326
}
327327

328-
public static void loadDataSetIntoEs(RestClient client, boolean supportsIndexModeLookup, boolean supportsUnmappedFields)
328+
public static void loadDataSetIntoEs(RestClient client, boolean supportsIndexModeLookup, boolean supportsSourceFieldMapping)
329329
throws IOException {
330-
loadDataSetIntoEs(client, supportsIndexModeLookup, supportsUnmappedFields, (restClient, indexName, indexMapping, indexSettings) -> {
331-
ESRestTestCase.createIndex(restClient, indexName, indexSettings, indexMapping, null);
332-
});
330+
loadDataSetIntoEs(
331+
client,
332+
supportsIndexModeLookup,
333+
supportsSourceFieldMapping,
334+
(restClient, indexName, indexMapping, indexSettings) -> {
335+
ESRestTestCase.createIndex(restClient, indexName, indexSettings, indexMapping, null);
336+
}
337+
);
333338
}
334339

335340
private static void loadDataSetIntoEs(
336341
RestClient client,
337342
boolean supportsIndexModeLookup,
338-
boolean supportsUnmappedFields,
343+
boolean supportsSourceFieldMapping,
339344
IndexCreator indexCreator
340345
) throws IOException {
341346
Logger logger = LogManager.getLogger(CsvTestsDataLoader.class);
342347

343348
Set<String> loadedDatasets = new HashSet<>();
344-
for (var dataset : availableDatasetsForEs(client, supportsIndexModeLookup, supportsUnmappedFields)) {
349+
for (var dataset : availableDatasetsForEs(client, supportsIndexModeLookup, supportsSourceFieldMapping)) {
345350
load(client, dataset, logger, indexCreator);
346351
loadedDatasets.add(dataset.indexName);
347352
}

0 commit comments

Comments
 (0)