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 ),
@@ -266,12 +267,12 @@ public static void main(String[] args) throws IOException {
266267 }
267268 }
268269
269- public static Set <TestsDataset > availableDatasetsForEs (RestClient client , boolean supportsIndexModeLookup ) throws IOException {
270+ public static Set <TestDataset > availableDatasetsForEs (RestClient client , boolean supportsIndexModeLookup ) throws IOException {
270271 boolean inferenceEnabled = clusterHasInferenceEndpoint (client );
271272
272- Set <TestsDataset > testDataSets = new HashSet <>();
273+ Set <TestDataset > testDataSets = new HashSet <>();
273274
274- for (TestsDataset dataset : CSV_DATASET_MAP .values ()) {
275+ for (TestDataset dataset : CSV_DATASET_MAP .values ()) {
275276 if ((inferenceEnabled || dataset .requiresInferenceEndpoint == false )
276277 && (supportsIndexModeLookup || isLookupDataset (dataset ) == false )) {
277278 testDataSets .add (dataset );
@@ -281,7 +282,7 @@ public static Set<TestsDataset> availableDatasetsForEs(RestClient client, boolea
281282 return testDataSets ;
282283 }
283284
284- public static boolean isLookupDataset (TestsDataset dataset ) throws IOException {
285+ public static boolean isLookupDataset (TestDataset dataset ) throws IOException {
285286 Settings settings = dataset .readSettingsFile ();
286287 String mode = settings .get ("index.mode" );
287288 return (mode != null && mode .equalsIgnoreCase ("lookup" ));
@@ -363,7 +364,7 @@ private static void loadEnrichPolicy(RestClient client, String policyName, Strin
363364 client .performRequest (request );
364365 }
365366
366- private static void load (RestClient client , TestsDataset dataset , Logger logger , IndexCreator indexCreator ) throws IOException {
367+ private static void load (RestClient client , TestDataset dataset , Logger logger , IndexCreator indexCreator ) throws IOException {
367368 final String mappingName = "/" + dataset .mappingFileName ;
368369 URL mapping = CsvTestsDataLoader .class .getResource (mappingName );
369370 if (mapping == null ) {
@@ -604,14 +605,14 @@ private static void forceMerge(RestClient client, Set<String> indices, Logger lo
604605 }
605606 }
606607
607- public record MultiIndexTestDataset (String indexPattern , List <TestsDataset > datasets ) {
608- public static MultiIndexTestDataset of (TestsDataset testsDataset ) {
608+ public record MultiIndexTestDataset (String indexPattern , List <TestDataset > datasets ) {
609+ public static MultiIndexTestDataset of (TestDataset testsDataset ) {
609610 return new MultiIndexTestDataset (testsDataset .indexName , List .of (testsDataset ));
610611 }
611612
612613 }
613614
614- public record TestsDataset (
615+ public record TestDataset (
615616 String indexName ,
616617 String mappingFileName ,
617618 String dataFileName ,
@@ -620,16 +621,16 @@ public record TestsDataset(
620621 @ Nullable Map <String , String > typeMapping ,
621622 boolean requiresInferenceEndpoint
622623 ) {
623- public TestsDataset (String indexName , String mappingFileName , String dataFileName ) {
624+ public TestDataset (String indexName , String mappingFileName , String dataFileName ) {
624625 this (indexName , mappingFileName , dataFileName , null , true , null , false );
625626 }
626627
627- public TestsDataset (String indexName ) {
628+ public TestDataset (String indexName ) {
628629 this (indexName , "mapping-" + indexName + ".json" , indexName + ".csv" , null , true , null , false );
629630 }
630631
631- public TestsDataset withIndex (String indexName ) {
632- return new TestsDataset (
632+ public TestDataset withIndex (String indexName ) {
633+ return new TestDataset (
633634 indexName ,
634635 mappingFileName ,
635636 dataFileName ,
@@ -640,8 +641,8 @@ public TestsDataset withIndex(String indexName) {
640641 );
641642 }
642643
643- public TestsDataset withData (String dataFileName ) {
644- return new TestsDataset (
644+ public TestDataset withData (String dataFileName ) {
645+ return new TestDataset (
645646 indexName ,
646647 mappingFileName ,
647648 dataFileName ,
@@ -652,8 +653,8 @@ public TestsDataset withData(String dataFileName) {
652653 );
653654 }
654655
655- public TestsDataset withSetting (String settingFileName ) {
656- return new TestsDataset (
656+ public TestDataset withSetting (String settingFileName ) {
657+ return new TestDataset (
657658 indexName ,
658659 mappingFileName ,
659660 dataFileName ,
@@ -664,8 +665,8 @@ public TestsDataset withSetting(String settingFileName) {
664665 );
665666 }
666667
667- public TestsDataset noSubfields () {
668- return new TestsDataset (
668+ public TestDataset noSubfields () {
669+ return new TestDataset (
669670 indexName ,
670671 mappingFileName ,
671672 dataFileName ,
@@ -676,8 +677,8 @@ public TestsDataset noSubfields() {
676677 );
677678 }
678679
679- public TestsDataset withTypeMapping (Map <String , String > typeMapping ) {
680- return new TestsDataset (
680+ public TestDataset withTypeMapping (Map <String , String > typeMapping ) {
681+ return new TestDataset (
681682 indexName ,
682683 mappingFileName ,
683684 dataFileName ,
@@ -688,8 +689,8 @@ public TestsDataset withTypeMapping(Map<String, String> typeMapping) {
688689 );
689690 }
690691
691- public TestsDataset withInferenceEndpoint (boolean needsInference ) {
692- return new TestsDataset (indexName , mappingFileName , dataFileName , settingFileName , allowSubFields , typeMapping , needsInference );
692+ public TestDataset withInferenceEndpoint (boolean needsInference ) {
693+ return new TestDataset (indexName , mappingFileName , dataFileName , settingFileName , allowSubFields , typeMapping , needsInference );
693694 }
694695
695696 private Settings readSettingsFile () throws IOException {
0 commit comments