10
10
package org .elasticsearch .ingest ;
11
11
12
12
import org .elasticsearch .ElasticsearchParseException ;
13
- import org .elasticsearch .cluster .metadata .DataStream ;
14
13
import org .elasticsearch .cluster .metadata .ProjectId ;
15
14
import org .elasticsearch .core .Tuple ;
16
15
import org .elasticsearch .script .ScriptService ;
24
23
import static org .hamcrest .Matchers .equalTo ;
25
24
import static org .hamcrest .Matchers .is ;
26
25
import static org .hamcrest .Matchers .nullValue ;
27
- import static org .junit .Assume .assumeTrue ;
28
26
import static org .mockito .Mockito .mock ;
29
27
30
28
public class PipelineFactoryTests extends ESTestCase {
@@ -49,19 +47,10 @@ public void testCreate() throws Exception {
49
47
pipelineConfig .put (Pipeline .DEPRECATED_KEY , deprecated );
50
48
pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig0 ), Map .of ("test" , processorConfig1 )));
51
49
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 ());
56
52
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 );
65
54
assertThat (pipeline .getId (), equalTo ("_id" ));
66
55
assertThat (pipeline .getDescription (), equalTo ("_description" ));
67
56
assertThat (pipeline .getVersion (), equalTo (version ));
@@ -82,7 +71,7 @@ public void testCreateWithNoProcessorsField() throws Exception {
82
71
pipelineConfig .put (Pipeline .META_KEY , metadata );
83
72
}
84
73
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 );
86
75
fail ("should fail, missing required [processors] field" );
87
76
} catch (ElasticsearchParseException e ) {
88
77
assertThat (e .getMessage (), equalTo ("[processors] required property is missing" ));
@@ -97,14 +86,7 @@ public void testCreateWithEmptyProcessorsField() throws Exception {
97
86
pipelineConfig .put (Pipeline .META_KEY , metadata );
98
87
}
99
88
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 );
108
90
assertThat (pipeline .getId (), equalTo ("_id" ));
109
91
assertThat (pipeline .getDescription (), equalTo ("_description" ));
110
92
assertThat (pipeline .getVersion (), equalTo (version ));
@@ -122,14 +104,7 @@ public void testCreateWithPipelineOnFailure() throws Exception {
122
104
pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig )));
123
105
pipelineConfig .put (Pipeline .ON_FAILURE_KEY , List .of (Map .of ("test" , processorConfig )));
124
106
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 );
133
108
assertThat (pipeline .getId (), equalTo ("_id" ));
134
109
assertThat (pipeline .getDescription (), equalTo ("_description" ));
135
110
assertThat (pipeline .getVersion (), equalTo (version ));
@@ -152,14 +127,7 @@ public void testCreateWithPipelineEmptyOnFailure() throws Exception {
152
127
Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
153
128
Exception e = expectThrows (
154
129
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 )
163
131
);
164
132
assertThat (e .getMessage (), equalTo ("pipeline [_id] cannot have an empty on_failure option defined" ));
165
133
}
@@ -177,14 +145,7 @@ public void testCreateWithPipelineEmptyOnFailureInProcessor() throws Exception {
177
145
Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
178
146
Exception e = expectThrows (
179
147
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 )
188
149
);
189
150
assertThat (e .getMessage (), equalTo ("[on_failure] processors list cannot be empty" ));
190
151
}
@@ -202,14 +163,7 @@ public void testCreateWithPipelineIgnoreFailure() throws Exception {
202
163
}
203
164
pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig )));
204
165
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 );
213
167
assertThat (pipeline .getId (), equalTo ("_id" ));
214
168
assertThat (pipeline .getDescription (), equalTo ("_description" ));
215
169
assertThat (pipeline .getVersion (), equalTo (version ));
@@ -222,15 +176,12 @@ public void testCreateWithPipelineIgnoreFailure() throws Exception {
222
176
}
223
177
224
178
public void testCreateUnsupportedFieldAccessPattern () throws Exception {
225
- assumeTrue ("Test is only valid if the logs stream feature flag is enabled" , DataStream .LOGS_STREAM_FEATURE_FLAG );
226
179
Map <String , Object > processorConfig = new HashMap <>();
227
180
processorConfig .put (ConfigurationUtils .TAG_KEY , "test-processor" );
228
181
Map <String , Object > pipelineConfig = new HashMap <>();
229
182
pipelineConfig .put (Pipeline .DESCRIPTION_KEY , "_description" );
230
183
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" );
234
185
if (metadata != null ) {
235
186
pipelineConfig .put (Pipeline .META_KEY , metadata );
236
187
}
@@ -239,14 +190,7 @@ public void testCreateUnsupportedFieldAccessPattern() throws Exception {
239
190
Exception e = expectThrows (
240
191
ElasticsearchParseException .class ,
241
192
// 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 )
250
194
);
251
195
assertThat (e .getMessage (), equalTo ("pipeline [_id] doesn't support value of [random] for parameter [field_access_pattern]" ));
252
196
}
@@ -287,14 +231,7 @@ public void testCreateUnusedProcessorOptions() throws Exception {
287
231
Map <String , Processor .Factory > processorRegistry = Map .of ("test" , new TestProcessor .Factory ());
288
232
Exception e = expectThrows (
289
233
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 )
298
235
);
299
236
assertThat (e .getMessage (), equalTo ("processor [test] doesn't support one or more provided configuration parameters [unused]" ));
300
237
}
@@ -311,14 +248,7 @@ public void testCreateProcessorsWithOnFailureProperties() throws Exception {
311
248
}
312
249
pipelineConfig .put (Pipeline .PROCESSORS_KEY , List .of (Map .of ("test" , processorConfig )));
313
250
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 );
322
252
assertThat (pipeline .getId (), equalTo ("_id" ));
323
253
assertThat (pipeline .getDescription (), equalTo ("_description" ));
324
254
assertThat (pipeline .getVersion (), equalTo (version ));
0 commit comments