|
@@ -41,7 +41,6 @@ import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
|
|
|
import static org.elasticsearch.xpack.esql.CsvTestUtils.COMMA_ESCAPING_REGEX;
|
|
@@ -258,11 +257,22 @@ public class CsvTestsDataLoader {
|
|
|
public static Set<TestsDataset> availableDatasetsForEs(RestClient client, boolean supportsIndexModeLookup) throws IOException {
|
|
|
boolean inferenceEnabled = clusterHasInferenceEndpoint(client);
|
|
|
|
|
|
- return CSV_DATASET_MAP.values()
|
|
|
- .stream()
|
|
|
- .filter(d -> d.requiresInferenceEndpoint == false || inferenceEnabled)
|
|
|
- .filter(d -> supportsIndexModeLookup || d.indexName.endsWith("_lookup") == false) // TODO: use actual index settings
|
|
|
- .collect(Collectors.toCollection(HashSet::new));
|
|
|
+ Set<TestsDataset> testDataSets = new HashSet<>();
|
|
|
+
|
|
|
+ for (TestsDataset dataset : CSV_DATASET_MAP.values()) {
|
|
|
+ if ((inferenceEnabled || dataset.requiresInferenceEndpoint == false)
|
|
|
+ && (supportsIndexModeLookup || isLookupDataset(dataset) == false)) {
|
|
|
+ testDataSets.add(dataset);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return testDataSets;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean isLookupDataset(TestsDataset dataset) throws IOException {
|
|
|
+ Settings settings = dataset.readSettingsFile();
|
|
|
+ String mode = settings.get("index.mode");
|
|
|
+ return (mode != null && mode.equalsIgnoreCase("lookup"));
|
|
|
}
|
|
|
|
|
|
public static void loadDataSetIntoEs(RestClient client, boolean supportsIndexModeLookup) throws IOException {
|
|
@@ -354,13 +364,8 @@ public class CsvTestsDataLoader {
|
|
|
if (data == null) {
|
|
|
throw new IllegalArgumentException("Cannot find resource " + dataName);
|
|
|
}
|
|
|
- Settings indexSettings = Settings.EMPTY;
|
|
|
- final String settingName = dataset.settingFileName != null ? "/" + dataset.settingFileName : null;
|
|
|
- if (settingName != null) {
|
|
|
- indexSettings = Settings.builder()
|
|
|
- .loadFromStream(settingName, CsvTestsDataLoader.class.getResourceAsStream(settingName), false)
|
|
|
- .build();
|
|
|
- }
|
|
|
+
|
|
|
+ Settings indexSettings = dataset.readSettingsFile();
|
|
|
indexCreator.createIndex(client, dataset.indexName, readMappingFile(mapping, dataset.typeMapping), indexSettings);
|
|
|
loadCsvData(client, dataset.indexName, data, dataset.allowSubFields, logger);
|
|
|
}
|
|
@@ -669,6 +674,18 @@ public class CsvTestsDataLoader {
|
|
|
public TestsDataset withInferenceEndpoint(boolean needsInference) {
|
|
|
return new TestsDataset(indexName, mappingFileName, dataFileName, settingFileName, allowSubFields, typeMapping, needsInference);
|
|
|
}
|
|
|
+
|
|
|
+ private Settings readSettingsFile() throws IOException {
|
|
|
+ Settings indexSettings = Settings.EMPTY;
|
|
|
+ final String settingName = settingFileName != null ? "/" + settingFileName : null;
|
|
|
+ if (settingName != null) {
|
|
|
+ indexSettings = Settings.builder()
|
|
|
+ .loadFromStream(settingName, CsvTestsDataLoader.class.getResourceAsStream(settingName), false)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ return indexSettings;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public record EnrichConfig(String policyName, String policyFileName) {}
|