5151
5252public class CsvTestsDataLoader {
5353 private static final int BULK_DATA_SIZE = 100_000 ;
54- private static final TestsDataset EMPLOYEES = new TestsDataset ("employees" , "mapping-default.json" , "employees.csv" ).noSubfields ();
55- private static final TestsDataset EMPLOYEES_INCOMPATIBLE = new TestsDataset (
54+ private static final TestDataset EMPLOYEES = new TestDataset ("employees" , "mapping-default.json" , "employees.csv" ).noSubfields ();
55+ private static final TestDataset EMPLOYEES_INCOMPATIBLE = new TestDataset (
5656 "employees_incompatible" ,
5757 "mapping-default-incompatible.json" ,
5858 "employees_incompatible.csv"
5959 ).noSubfields ();
60- private static final TestsDataset HOSTS = new TestsDataset ("hosts" );
61- private static final TestsDataset APPS = new TestsDataset ("apps" );
62- private static final TestsDataset APPS_SHORT = APPS .withIndex ("apps_short" ).withTypeMapping (Map .of ("id" , "short" ));
63- private static final TestsDataset LANGUAGES = new TestsDataset ("languages" );
64- private static final TestsDataset LANGUAGES_LOOKUP = LANGUAGES .withIndex ("languages_lookup" )
60+ private static final TestDataset HOSTS = new TestDataset ("hosts" );
61+ private static final TestDataset APPS = new TestDataset ("apps" );
62+ private static final TestDataset APPS_SHORT = APPS .withIndex ("apps_short" ).withTypeMapping (Map .of ("id" , "short" ));
63+ private static final TestDataset LANGUAGES = new TestDataset ("languages" );
64+ private static final TestDataset LANGUAGES_LOOKUP = LANGUAGES .withIndex ("languages_lookup" )
6565 .withSetting ("languages_lookup-settings.json" );
66- private static final TestsDataset LANGUAGES_LOOKUP_NON_UNIQUE_KEY = LANGUAGES_LOOKUP .withIndex ("languages_lookup_non_unique_key" )
66+ private static final TestDataset LANGUAGES_LOOKUP_NON_UNIQUE_KEY = LANGUAGES_LOOKUP .withIndex ("languages_lookup_non_unique_key" )
6767 .withData ("languages_non_unique_key.csv" );
68- private static final TestsDataset LANGUAGES_NESTED_FIELDS = new TestsDataset (
68+ private static final TestDataset LANGUAGES_NESTED_FIELDS = new TestDataset (
6969 "languages_nested_fields" ,
7070 "mapping-languages_nested_fields.json" ,
7171 "languages_nested_fields.csv"
7272 ).withSetting ("languages_lookup-settings.json" );
73- private static final TestsDataset ALERTS = new TestsDataset ("alerts" );
74- private static final TestsDataset UL_LOGS = new TestsDataset ("ul_logs" );
75- private static final TestsDataset SAMPLE_DATA = new TestsDataset ("sample_data" );
76- private static final TestsDataset MV_SAMPLE_DATA = new TestsDataset ("mv_sample_data" );
77- private static final TestsDataset SAMPLE_DATA_STR = SAMPLE_DATA .withIndex ("sample_data_str" )
73+ private static final TestDataset ALERTS = new TestDataset ("alerts" );
74+ private static final TestDataset UL_LOGS = new TestDataset ("ul_logs" );
75+ private static final TestDataset SAMPLE_DATA = new TestDataset ("sample_data" );
76+ private static final TestDataset MV_SAMPLE_DATA = new TestDataset ("mv_sample_data" );
77+ private static final TestDataset SAMPLE_DATA_STR = SAMPLE_DATA .withIndex ("sample_data_str" )
7878 .withTypeMapping (Map .of ("client_ip" , "keyword" ));
79- private static final TestsDataset SAMPLE_DATA_TS_LONG = SAMPLE_DATA .withIndex ("sample_data_ts_long" )
79+ private static final TestDataset SAMPLE_DATA_TS_LONG = SAMPLE_DATA .withIndex ("sample_data_ts_long" )
8080 .withData ("sample_data_ts_long.csv" )
8181 .withTypeMapping (Map .of ("@timestamp" , "long" ));
82- private static final TestsDataset SAMPLE_DATA_TS_NANOS = SAMPLE_DATA .withIndex ("sample_data_ts_nanos" )
82+ private static final TestDataset SAMPLE_DATA_TS_NANOS = SAMPLE_DATA .withIndex ("sample_data_ts_nanos" )
8383 .withData ("sample_data_ts_nanos.csv" )
8484 .withTypeMapping (Map .of ("@timestamp" , "date_nanos" ));
85- private static final TestsDataset MISSING_IP_SAMPLE_DATA = new TestsDataset ("missing_ip_sample_data" );
86- private static final TestsDataset CLIENT_IPS = new TestsDataset ("clientips" );
87- private static final TestsDataset CLIENT_IPS_LOOKUP = CLIENT_IPS .withIndex ("clientips_lookup" )
85+ private static final TestDataset MISSING_IP_SAMPLE_DATA = new TestDataset ("missing_ip_sample_data" );
86+ private static final TestDataset CLIENT_IPS = new TestDataset ("clientips" );
87+ private static final TestDataset CLIENT_IPS_LOOKUP = CLIENT_IPS .withIndex ("clientips_lookup" )
8888 .withSetting ("clientips_lookup-settings.json" );
89- private static final TestsDataset MESSAGE_TYPES = new TestsDataset ("message_types" );
90- private static final TestsDataset MESSAGE_TYPES_LOOKUP = MESSAGE_TYPES .withIndex ("message_types_lookup" )
89+ private static final TestDataset MESSAGE_TYPES = new TestDataset ("message_types" );
90+ private static final TestDataset MESSAGE_TYPES_LOOKUP = MESSAGE_TYPES .withIndex ("message_types_lookup" )
9191 .withSetting ("message_types_lookup-settings.json" );
92- private static final TestsDataset CLIENT_CIDR = new TestsDataset ("client_cidr" );
93- private static final TestsDataset AGES = new TestsDataset ("ages" );
94- private static final TestsDataset HEIGHTS = new TestsDataset ("heights" );
95- private static final TestsDataset DECADES = new TestsDataset ("decades" );
96- private static final TestsDataset AIRPORTS = new TestsDataset ("airports" );
97- private static final TestsDataset AIRPORTS_MP = AIRPORTS .withIndex ("airports_mp" ).withData ("airports_mp.csv" );
98- private static final TestsDataset AIRPORTS_NO_DOC_VALUES = new TestsDataset ("airports_no_doc_values" ).withData ("airports.csv" );
99- private static final TestsDataset AIRPORTS_NOT_INDEXED = new TestsDataset ("airports_not_indexed" ).withData ("airports.csv" );
100- private static final TestsDataset AIRPORTS_NOT_INDEXED_NOR_DOC_VALUES = new TestsDataset ("airports_not_indexed_nor_doc_values" )
101- .withData ("airports.csv" );
102- private static final TestsDataset AIRPORTS_WEB = new TestsDataset ("airports_web" );
103- private static final TestsDataset DATE_NANOS = new TestsDataset ("date_nanos" );
104- private static final TestsDataset COUNTRIES_BBOX = new TestsDataset ("countries_bbox" );
105- private static final TestsDataset COUNTRIES_BBOX_WEB = new TestsDataset ("countries_bbox_web" );
106- private static final TestsDataset AIRPORT_CITY_BOUNDARIES = new TestsDataset ("airport_city_boundaries" );
107- private static final TestsDataset CARTESIAN_MULTIPOLYGONS = new TestsDataset ("cartesian_multipolygons" );
108- private static final TestsDataset CARTESIAN_MULTIPOLYGONS_NO_DOC_VALUES = new TestsDataset ("cartesian_multipolygons_no_doc_values" )
92+ private static final TestDataset CLIENT_CIDR = new TestDataset ("client_cidr" );
93+ private static final TestDataset AGES = new TestDataset ("ages" );
94+ private static final TestDataset HEIGHTS = new TestDataset ("heights" );
95+ private static final TestDataset DECADES = new TestDataset ("decades" );
96+ private static final TestDataset AIRPORTS = new TestDataset ("airports" );
97+ private static final TestDataset AIRPORTS_MP = AIRPORTS .withIndex ("airports_mp" ).withData ("airports_mp.csv" );
98+ private static final TestDataset AIRPORTS_NO_DOC_VALUES = new TestDataset ("airports_no_doc_values" ).withData ("airports.csv" );
99+ private static final TestDataset AIRPORTS_NOT_INDEXED = new TestDataset ("airports_not_indexed" ).withData ("airports.csv" );
100+ private static final TestDataset AIRPORTS_NOT_INDEXED_NOR_DOC_VALUES = new TestDataset ("airports_not_indexed_nor_doc_values" ).withData (
101+ "airports.csv"
102+ );
103+ private static final TestDataset AIRPORTS_WEB = new TestDataset ("airports_web" );
104+ private static final TestDataset DATE_NANOS = new TestDataset ("date_nanos" );
105+ private static final TestDataset COUNTRIES_BBOX = new TestDataset ("countries_bbox" );
106+ private static final TestDataset COUNTRIES_BBOX_WEB = new TestDataset ("countries_bbox_web" );
107+ private static final TestDataset AIRPORT_CITY_BOUNDARIES = new TestDataset ("airport_city_boundaries" );
108+ private static final TestDataset CARTESIAN_MULTIPOLYGONS = new TestDataset ("cartesian_multipolygons" );
109+ private static final TestDataset CARTESIAN_MULTIPOLYGONS_NO_DOC_VALUES = new TestDataset ("cartesian_multipolygons_no_doc_values" )
109110 .withData ("cartesian_multipolygons.csv" );
110- private static final TestsDataset MULTIVALUE_GEOMETRIES = new TestsDataset ("multivalue_geometries" );
111- private static final TestsDataset MULTIVALUE_POINTS = new TestsDataset ("multivalue_points" );
112- private static final TestsDataset DISTANCES = new TestsDataset ("distances" );
113- private static final TestsDataset K8S = new TestsDataset ("k8s" , "k8s-mappings.json" , "k8s.csv" ).withSetting ("k8s-settings.json" );
114- private static final TestsDataset ADDRESSES = new TestsDataset ("addresses" );
115- private static final TestsDataset BOOKS = new TestsDataset ("books" ).withSetting ("books-settings.json" );
116- private static final TestsDataset SEMANTIC_TEXT = new TestsDataset ("semantic_text" ).withInferenceEndpoint (true );
117-
118- public static final Map <String , TestsDataset > CSV_DATASET_MAP = Map .ofEntries (
111+ private static final TestDataset MULTIVALUE_GEOMETRIES = new TestDataset ("multivalue_geometries" );
112+ private static final TestDataset MULTIVALUE_POINTS = new TestDataset ("multivalue_points" );
113+ private static final TestDataset DISTANCES = new TestDataset ("distances" );
114+ private static final TestDataset K8S = new TestDataset ("k8s" , "k8s-mappings.json" , "k8s.csv" ).withSetting ("k8s-settings.json" );
115+ private static final TestDataset ADDRESSES = new TestDataset ("addresses" );
116+ private static final TestDataset BOOKS = new TestDataset ("books" ).withSetting ("books-settings.json" );
117+ private static final TestDataset SEMANTIC_TEXT = new TestDataset ("semantic_text" ).withInferenceEndpoint (true );
118+
119+ public static final Map <String , TestDataset > CSV_DATASET_MAP = Map .ofEntries (
119120 Map .entry (EMPLOYEES .indexName , EMPLOYEES ),
120121 Map .entry (EMPLOYEES_INCOMPATIBLE .indexName , EMPLOYEES_INCOMPATIBLE ),
121122 Map .entry (HOSTS .indexName , HOSTS ),
@@ -267,12 +268,12 @@ public static void main(String[] args) throws IOException {
267268 }
268269 }
269270
270- public static Set <TestsDataset > availableDatasetsForEs (RestClient client , boolean supportsIndexModeLookup ) throws IOException {
271+ public static Set <TestDataset > availableDatasetsForEs (RestClient client , boolean supportsIndexModeLookup ) throws IOException {
271272 boolean inferenceEnabled = clusterHasInferenceEndpoint (client );
272273
273- Set <TestsDataset > testDataSets = new HashSet <>();
274+ Set <TestDataset > testDataSets = new HashSet <>();
274275
275- for (TestsDataset dataset : CSV_DATASET_MAP .values ()) {
276+ for (TestDataset dataset : CSV_DATASET_MAP .values ()) {
276277 if ((inferenceEnabled || dataset .requiresInferenceEndpoint == false )
277278 && (supportsIndexModeLookup || isLookupDataset (dataset ) == false )) {
278279 testDataSets .add (dataset );
@@ -282,7 +283,7 @@ public static Set<TestsDataset> availableDatasetsForEs(RestClient client, boolea
282283 return testDataSets ;
283284 }
284285
285- public static boolean isLookupDataset (TestsDataset dataset ) throws IOException {
286+ public static boolean isLookupDataset (TestDataset dataset ) throws IOException {
286287 Settings settings = dataset .readSettingsFile ();
287288 String mode = settings .get ("index.mode" );
288289 return (mode != null && mode .equalsIgnoreCase ("lookup" ));
@@ -366,7 +367,7 @@ private static void loadEnrichPolicy(RestClient client, String policyName, Strin
366367 client .performRequest (request );
367368 }
368369
369- private static void load (RestClient client , TestsDataset dataset , Logger logger , IndexCreator indexCreator ) throws IOException {
370+ private static void load (RestClient client , TestDataset dataset , Logger logger , IndexCreator indexCreator ) throws IOException {
370371 final String mappingName = "/" + dataset .mappingFileName ;
371372 URL mapping = CsvTestsDataLoader .class .getResource (mappingName );
372373 if (mapping == null ) {
@@ -607,14 +608,14 @@ private static void forceMerge(RestClient client, Set<String> indices, Logger lo
607608 }
608609 }
609610
610- public record MultiIndexTestDataset (String indexPattern , List <TestsDataset > datasets ) {
611- public static MultiIndexTestDataset of (TestsDataset testsDataset ) {
611+ public record MultiIndexTestDataset (String indexPattern , List <TestDataset > datasets ) {
612+ public static MultiIndexTestDataset of (TestDataset testsDataset ) {
612613 return new MultiIndexTestDataset (testsDataset .indexName , List .of (testsDataset ));
613614 }
614615
615616 }
616617
617- public record TestsDataset (
618+ public record TestDataset (
618619 String indexName ,
619620 String mappingFileName ,
620621 String dataFileName ,
@@ -623,16 +624,16 @@ public record TestsDataset(
623624 @ Nullable Map <String , String > typeMapping ,
624625 boolean requiresInferenceEndpoint
625626 ) {
626- public TestsDataset (String indexName , String mappingFileName , String dataFileName ) {
627+ public TestDataset (String indexName , String mappingFileName , String dataFileName ) {
627628 this (indexName , mappingFileName , dataFileName , null , true , null , false );
628629 }
629630
630- public TestsDataset (String indexName ) {
631+ public TestDataset (String indexName ) {
631632 this (indexName , "mapping-" + indexName + ".json" , indexName + ".csv" , null , true , null , false );
632633 }
633634
634- public TestsDataset withIndex (String indexName ) {
635- return new TestsDataset (
635+ public TestDataset withIndex (String indexName ) {
636+ return new TestDataset (
636637 indexName ,
637638 mappingFileName ,
638639 dataFileName ,
@@ -643,8 +644,8 @@ public TestsDataset withIndex(String indexName) {
643644 );
644645 }
645646
646- public TestsDataset withData (String dataFileName ) {
647- return new TestsDataset (
647+ public TestDataset withData (String dataFileName ) {
648+ return new TestDataset (
648649 indexName ,
649650 mappingFileName ,
650651 dataFileName ,
@@ -655,8 +656,8 @@ public TestsDataset withData(String dataFileName) {
655656 );
656657 }
657658
658- public TestsDataset withSetting (String settingFileName ) {
659- return new TestsDataset (
659+ public TestDataset withSetting (String settingFileName ) {
660+ return new TestDataset (
660661 indexName ,
661662 mappingFileName ,
662663 dataFileName ,
@@ -667,8 +668,8 @@ public TestsDataset withSetting(String settingFileName) {
667668 );
668669 }
669670
670- public TestsDataset noSubfields () {
671- return new TestsDataset (
671+ public TestDataset noSubfields () {
672+ return new TestDataset (
672673 indexName ,
673674 mappingFileName ,
674675 dataFileName ,
@@ -679,8 +680,8 @@ public TestsDataset noSubfields() {
679680 );
680681 }
681682
682- public TestsDataset withTypeMapping (Map <String , String > typeMapping ) {
683- return new TestsDataset (
683+ public TestDataset withTypeMapping (Map <String , String > typeMapping ) {
684+ return new TestDataset (
684685 indexName ,
685686 mappingFileName ,
686687 dataFileName ,
@@ -691,8 +692,8 @@ public TestsDataset withTypeMapping(Map<String, String> typeMapping) {
691692 );
692693 }
693694
694- public TestsDataset withInferenceEndpoint (boolean needsInference ) {
695- return new TestsDataset (indexName , mappingFileName , dataFileName , settingFileName , allowSubFields , typeMapping , needsInference );
695+ public TestDataset withInferenceEndpoint (boolean needsInference ) {
696+ return new TestDataset (indexName , mappingFileName , dataFileName , settingFileName , allowSubFields , typeMapping , needsInference );
696697 }
697698
698699 private Settings readSettingsFile () throws IOException {
0 commit comments