@@ -16,6 +16,7 @@ import {
16
16
enableStreams ,
17
17
fetchDocument ,
18
18
forkStream ,
19
+ indexAndAssertTargetStream ,
19
20
indexDocument ,
20
21
} from './helpers/requests' ;
21
22
@@ -153,10 +154,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
153
154
stream : 'somethingelse' , // a field named stream should work as well
154
155
} ) ,
155
156
} ;
156
- const response = await indexDocument ( esClient , 'logs' , doc ) ;
157
- expect ( response . result ) . to . eql ( 'created' ) ;
158
- const result = await fetchDocument ( esClient , 'logs' , response . _id ) ;
159
- expect ( result . _index ) . to . match ( / ^ \. d s \- l o g s - .* / ) ;
157
+ const result = await indexAndAssertTargetStream ( esClient , 'logs' , doc ) ;
160
158
expect ( result . _source ) . to . eql ( {
161
159
'@timestamp' : '2024-01-01T00:00:00.000Z' ,
162
160
message : 'test' ,
@@ -191,11 +189,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
191
189
message : 'test' ,
192
190
} ) ,
193
191
} ;
194
- const response = await indexDocument ( esClient , 'logs' , doc ) ;
195
- expect ( response . result ) . to . eql ( 'created' ) ;
196
-
197
- const result = await fetchDocument ( esClient , 'logs.nginx' , response . _id ) ;
198
- expect ( result . _index ) . to . match ( / ^ \. d s \- l o g s .n g i n x - .* / ) ;
192
+ const result = await indexAndAssertTargetStream ( esClient , 'logs.nginx' , doc ) ;
199
193
expect ( result . _source ) . to . eql ( {
200
194
'@timestamp' : '2024-01-01T00:00:10.000Z' ,
201
195
message : 'test' ,
@@ -225,11 +219,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
225
219
message : 'test' ,
226
220
} ) ,
227
221
} ;
228
- const response = await indexDocument ( esClient , 'logs' , doc ) ;
229
- expect ( response . result ) . to . eql ( 'created' ) ;
230
-
231
- const result = await fetchDocument ( esClient , 'logs.nginx.access' , response . _id ) ;
232
- expect ( result . _index ) . to . match ( / ^ \. d s \- l o g s .n g i n x .a c c e s s - .* / ) ;
222
+ const result = await indexAndAssertTargetStream ( esClient , 'logs.nginx.access' , doc ) ;
233
223
expect ( result . _source ) . to . eql ( {
234
224
'@timestamp' : '2024-01-01T00:00:20.000Z' ,
235
225
message : 'test' ,
@@ -259,11 +249,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
259
249
message : 'test' ,
260
250
} ) ,
261
251
} ;
262
- const response = await indexDocument ( esClient , 'logs' , doc ) ;
263
- expect ( response . result ) . to . eql ( 'created' ) ;
264
-
265
- const result = await fetchDocument ( esClient , 'logs.nginx' , response . _id ) ;
266
- expect ( result . _index ) . to . match ( / ^ \. d s \- l o g s .n g i n x - .* / ) ;
252
+ const result = await indexAndAssertTargetStream ( esClient , 'logs.nginx' , doc ) ;
267
253
expect ( result . _source ) . to . eql ( {
268
254
'@timestamp' : '2024-01-01T00:00:20.000Z' ,
269
255
message : 'test' ,
@@ -299,10 +285,8 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
299
285
message : 'test' ,
300
286
} ) ,
301
287
} ;
302
- const response1 = await indexDocument ( esClient , 'logs' , doc1 ) ;
303
- expect ( response1 . result ) . to . eql ( 'created' ) ;
304
- const response2 = await indexDocument ( esClient , 'logs' , doc2 ) ;
305
- expect ( response2 . result ) . to . eql ( 'created' ) ;
288
+ await indexAndAssertTargetStream ( esClient , 'logs.number-test' , doc1 ) ;
289
+ await indexAndAssertTargetStream ( esClient , 'logs.number-test' , doc2 ) ;
306
290
} ) ;
307
291
308
292
it ( 'Fork logs to logs.string-test' , async ( ) => {
@@ -334,11 +318,8 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
334
318
message : 'status_code: 400' ,
335
319
} ) ,
336
320
} ;
337
- const response1 = await indexDocument ( esClient , 'logs' , doc1 ) ;
338
- expect ( response1 . result ) . to . eql ( 'created' ) ;
339
-
340
- const response2 = await indexDocument ( esClient , 'logs' , doc2 ) ;
341
- expect ( response2 . result ) . to . eql ( 'created' ) ;
321
+ await indexAndAssertTargetStream ( esClient , 'logs.string-test' , doc1 ) ;
322
+ await indexAndAssertTargetStream ( esClient , 'logs.string-test' , doc2 ) ;
342
323
} ) ;
343
324
344
325
it ( 'Fork logs to logs.weird-characters' , async ( ) => {
@@ -369,17 +350,8 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
369
350
'weird fieldname' : 'Keep where it is' ,
370
351
} ,
371
352
} ;
372
- const response1 = await indexDocument ( esClient , 'logs' , doc1 ) ;
373
- expect ( response1 . result ) . to . eql ( 'created' ) ;
374
-
375
- const result1 = await fetchDocument ( esClient , 'logs.weird-characters' , response1 . _id ) ;
376
- expect ( result1 . _index ) . to . match ( / ^ \. d s \- l o g s .w e i r d - c h a r a c t e r s - .* / ) ;
377
-
378
- const response2 = await indexDocument ( esClient , 'logs' , doc2 ) ;
379
- expect ( response2 . result ) . to . eql ( 'created' ) ;
380
-
381
- const result2 = await fetchDocument ( esClient , 'logs' , response2 . _id ) ;
382
- expect ( result2 . _index ) . to . match ( / ^ \. d s \- l o g s - .* / ) ;
353
+ await indexAndAssertTargetStream ( esClient , 'logs.weird-characters' , doc1 ) ;
354
+ await indexAndAssertTargetStream ( esClient , 'logs' , doc2 ) ;
383
355
} ) ;
384
356
} ) ;
385
357
} ) ;
0 commit comments