1010package org .elasticsearch .ingest ;
1111
1212import org .elasticsearch .ElasticsearchParseException ;
13- import org .elasticsearch .cluster .metadata .DataStream ;
1413import org .elasticsearch .cluster .metadata .ProjectId ;
1514import org .elasticsearch .core .Tuple ;
1615import org .elasticsearch .script .ScriptService ;
2423import static org .hamcrest .Matchers .equalTo ;
2524import static org .hamcrest .Matchers .is ;
2625import static org .hamcrest .Matchers .nullValue ;
27- import static org .junit .Assume .assumeTrue ;
2826import static org .mockito .Mockito .mock ;
2927
3028public class PipelineFactoryTests extends ESTestCase {
@@ -49,19 +47,10 @@ public void testCreate() throws Exception {
4947 pipelineConfig .put (Pipeline .DEPRECATED_KEY , deprecated );
5048 pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig0 ), Map .of ("test" , processorConfig1 )));
5149 IngestPipelineFieldAccessPattern expectedAccessPattern = IngestPipelineFieldAccessPattern .CLASSIC ;
52- if (DataStream .LOGS_STREAM_FEATURE_FLAG ) {
53- expectedAccessPattern = randomFrom (IngestPipelineFieldAccessPattern .values ());
54- pipelineConfig .put (Pipeline .FIELD_ACCESS_PATTERN , expectedAccessPattern .getKey ());
55- }
50+ expectedAccessPattern = randomFrom (IngestPipelineFieldAccessPattern .values ());
51+ pipelineConfig .put (Pipeline .FIELD_ACCESS_PATTERN , expectedAccessPattern .getKey ());
5652 Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
57- Pipeline pipeline = Pipeline .create (
58- "_id" ,
59- pipelineConfig ,
60- processorRegistry ,
61- scriptService ,
62- null ,
63- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
64- );
53+ Pipeline pipeline = Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true );
6554 assertThat (pipeline .getId (), equalTo ("_id" ));
6655 assertThat (pipeline .getDescription (), equalTo ("_description" ));
6756 assertThat (pipeline .getVersion (), equalTo (version ));
@@ -82,7 +71,7 @@ public void testCreateWithNoProcessorsField() throws Exception {
8271 pipelineConfig .put (Pipeline .META_KEY , metadata );
8372 }
8473 try {
85- Pipeline .create ("_id" , pipelineConfig , Map .of (), scriptService , null , nodeFeature -> DataStream . LOGS_STREAM_FEATURE_FLAG );
74+ Pipeline .create ("_id" , pipelineConfig , Map .of (), scriptService , null , nodeFeature -> true );
8675 fail ("should fail, missing required [processors] field" );
8776 } catch (ElasticsearchParseException e ) {
8877 assertThat (e .getMessage (), equalTo ("[processors] required property is missing" ));
@@ -97,14 +86,7 @@ public void testCreateWithEmptyProcessorsField() throws Exception {
9786 pipelineConfig .put (Pipeline .META_KEY , metadata );
9887 }
9988 pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of ());
100- Pipeline pipeline = Pipeline .create (
101- "_id" ,
102- pipelineConfig ,
103- null ,
104- scriptService ,
105- null ,
106- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
107- );
89+ Pipeline pipeline = Pipeline .create ("_id" , pipelineConfig , null , scriptService , null , nodeFeature -> true );
10890 assertThat (pipeline .getId (), equalTo ("_id" ));
10991 assertThat (pipeline .getDescription (), equalTo ("_description" ));
11092 assertThat (pipeline .getVersion (), equalTo (version ));
@@ -122,14 +104,7 @@ public void testCreateWithPipelineOnFailure() throws Exception {
122104 pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig )));
123105 pipelineConfig .put (Pipeline .ON_FAILURE_KEY , List .of (Map .of ("test" , processorConfig )));
124106 Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
125- Pipeline pipeline = Pipeline .create (
126- "_id" ,
127- pipelineConfig ,
128- processorRegistry ,
129- scriptService ,
130- null ,
131- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
132- );
107+ Pipeline pipeline = Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true );
133108 assertThat (pipeline .getId (), equalTo ("_id" ));
134109 assertThat (pipeline .getDescription (), equalTo ("_description" ));
135110 assertThat (pipeline .getVersion (), equalTo (version ));
@@ -152,14 +127,7 @@ public void testCreateWithPipelineEmptyOnFailure() throws Exception {
152127 Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
153128 Exception e = expectThrows (
154129 ElasticsearchParseException .class ,
155- () -> Pipeline .create (
156- "_id" ,
157- pipelineConfig ,
158- processorRegistry ,
159- scriptService ,
160- null ,
161- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
162- )
130+ () -> Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true )
163131 );
164132 assertThat (e .getMessage (), equalTo ("pipeline [_id] cannot have an empty on_failure option defined" ));
165133 }
@@ -177,14 +145,7 @@ public void testCreateWithPipelineEmptyOnFailureInProcessor() throws Exception {
177145 Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
178146 Exception e = expectThrows (
179147 ElasticsearchParseException .class ,
180- () -> Pipeline .create (
181- "_id" ,
182- pipelineConfig ,
183- processorRegistry ,
184- scriptService ,
185- null ,
186- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
187- )
148+ () -> Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true )
188149 );
189150 assertThat (e .getMessage (), equalTo ("[on_failure] processors list cannot be empty" ));
190151 }
@@ -202,14 +163,7 @@ public void testCreateWithPipelineIgnoreFailure() throws Exception {
202163 }
203164 pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig )));
204165
205- Pipeline pipeline = Pipeline .create (
206- "_id" ,
207- pipelineConfig ,
208- processorRegistry ,
209- scriptService ,
210- null ,
211- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
212- );
166+ Pipeline pipeline = Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true );
213167 assertThat (pipeline .getId (), equalTo ("_id" ));
214168 assertThat (pipeline .getDescription (), equalTo ("_description" ));
215169 assertThat (pipeline .getVersion (), equalTo (version ));
@@ -222,15 +176,12 @@ public void testCreateWithPipelineIgnoreFailure() throws Exception {
222176 }
223177
224178 public void testCreateUnsupportedFieldAccessPattern () throws Exception {
225- assumeTrue ("Test is only valid if the logs stream feature flag is enabled" , DataStream .LOGS_STREAM_FEATURE_FLAG );
226179 Map <String , Object > processorConfig = new HashMap <>();
227180 processorConfig .put (ConfigurationUtils .TAG_KEY , "test-processor" );
228181 Map <String , Object > pipelineConfig = new HashMap <>();
229182 pipelineConfig .put (Pipeline .DESCRIPTION_KEY , "_description" );
230183 pipelineConfig .put (Pipeline .VERSION_KEY , versionString );
231- if (DataStream .LOGS_STREAM_FEATURE_FLAG ) {
232- pipelineConfig .put (Pipeline .FIELD_ACCESS_PATTERN , "random" );
233- }
184+ pipelineConfig .put (Pipeline .FIELD_ACCESS_PATTERN , "random" );
234185 if (metadata != null ) {
235186 pipelineConfig .put (Pipeline .META_KEY , metadata );
236187 }
@@ -239,14 +190,7 @@ public void testCreateUnsupportedFieldAccessPattern() throws Exception {
239190 Exception e = expectThrows (
240191 ElasticsearchParseException .class ,
241192 // All node features disabled
242- () -> Pipeline .create (
243- "_id" ,
244- pipelineConfig ,
245- processorRegistry ,
246- scriptService ,
247- null ,
248- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
249- )
193+ () -> Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true )
250194 );
251195 assertThat (e .getMessage (), equalTo ("pipeline [_id] doesn't support value of [random] for parameter [field_access_pattern]" ));
252196 }
@@ -287,14 +231,7 @@ public void testCreateUnusedProcessorOptions() throws Exception {
287231 Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
288232 Exception e = expectThrows (
289233 ElasticsearchParseException .class ,
290- () -> Pipeline .create (
291- "_id" ,
292- pipelineConfig ,
293- processorRegistry ,
294- scriptService ,
295- null ,
296- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
297- )
234+ () -> Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true )
298235 );
299236 assertThat (e .getMessage (), equalTo ("processor [test] doesn't support one or more provided configuration parameters [unused]" ));
300237 }
@@ -311,14 +248,7 @@ public void testCreateProcessorsWithOnFailureProperties() throws Exception {
311248 }
312249 pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig )));
313250 Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
314- Pipeline pipeline = Pipeline .create (
315- "_id" ,
316- pipelineConfig ,
317- processorRegistry ,
318- scriptService ,
319- null ,
320- nodeFeature -> DataStream .LOGS_STREAM_FEATURE_FLAG
321- );
251+ Pipeline pipeline = Pipeline .create ("_id" , pipelineConfig , processorRegistry , scriptService , null , nodeFeature -> true );
322252 assertThat (pipeline .getId (), equalTo ("_id" ));
323253 assertThat (pipeline .getDescription (), equalTo ("_description" ));
324254 assertThat (pipeline .getVersion (), equalTo (version ));
0 commit comments