Skip to content

Commit d2e5f2f

Browse files
authored
[7.x] Enhance the ingest node simulate verbose output (#60433) (#60678)
This commit enhances the verbose output for the `_ingest/pipeline/_simulate?verbose` api. Specifically this adds the following: * the pipeline processor is now included in the output * the conditional (if) and result is now included in the output iff it was defined * a status field is always displayed. the possible values of status are * `success` - if the processor ran with out errors * `error` - if the processor ran but threw an error that was not ingored * `error_ignored` - if the processor ran but threw an error that was ingored * `skipped` - if the process did not run (currently only possible if the if condition evaluates to false) * `dropped` - if the the `drop` processor ran and dropped the document * a `processor_type` field for the type of processor (e.g. set, rename, etc.) * throw a better error if trying to simulate with a pipeline that does not exist closes #56004
1 parent 1bfebd5 commit d2e5f2f

File tree

10 files changed

+514
-217
lines changed

10 files changed

+514
-217
lines changed

docs/reference/ingest/apis/simulate-pipeline.asciidoc

Lines changed: 81 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -342,84 +342,93 @@ The API returns the following response:
342342
[source,console-result]
343343
----
344344
{
345-
"docs": [
346-
{
347-
"processor_results": [
348-
{
349-
"doc": {
350-
"_id": "id",
351-
"_index": "index",
352-
"_type": "_doc",
353-
"_source": {
354-
"field2": "_value2",
355-
"foo": "bar"
356-
},
357-
"_ingest": {
358-
"timestamp": "2017-05-04T22:46:09.674Z",
359-
"pipeline": "_simulate_pipeline"
360-
}
361-
}
345+
"docs": [
346+
{
347+
"processor_results": [
348+
{
349+
"processor_type": "set",
350+
"status": "success",
351+
"doc": {
352+
"_index": "index",
353+
"_type": "_doc",
354+
"_id": "id",
355+
"_source": {
356+
"field2": "_value2",
357+
"foo": "bar"
362358
},
363-
{
364-
"doc": {
365-
"_id": "id",
366-
"_index": "index",
367-
"_type": "_doc",
368-
"_source": {
369-
"field3": "_value3",
370-
"field2": "_value2",
371-
"foo": "bar"
372-
},
373-
"_ingest": {
374-
"timestamp": "2017-05-04T22:46:09.675Z",
375-
"pipeline": "_simulate_pipeline"
376-
}
377-
}
359+
"_ingest": {
360+
"pipeline": "_simulate_pipeline",
361+
"timestamp": "2020-07-30T01:21:24.251836Z"
378362
}
379-
]
380-
},
381-
{
382-
"processor_results": [
383-
{
384-
"doc": {
385-
"_id": "id",
386-
"_index": "index",
387-
"_type": "_doc",
388-
"_source": {
389-
"field2": "_value2",
390-
"foo": "rab"
391-
},
392-
"_ingest": {
393-
"timestamp": "2017-05-04T22:46:09.676Z",
394-
"pipeline": "_simulate_pipeline"
395-
}
396-
}
363+
}
364+
},
365+
{
366+
"processor_type": "set",
367+
"status": "success",
368+
"doc": {
369+
"_index": "index",
370+
"_type": "_doc",
371+
"_id": "id",
372+
"_source": {
373+
"field3": "_value3",
374+
"field2": "_value2",
375+
"foo": "bar"
397376
},
398-
{
399-
"doc": {
400-
"_id": "id",
401-
"_index": "index",
402-
"_type": "_doc",
403-
"_source": {
404-
"field3": "_value3",
405-
"field2": "_value2",
406-
"foo": "rab"
407-
},
408-
"_ingest": {
409-
"timestamp": "2017-05-04T22:46:09.677Z",
410-
"pipeline": "_simulate_pipeline"
411-
}
412-
}
377+
"_ingest": {
378+
"pipeline": "_simulate_pipeline",
379+
"timestamp": "2020-07-30T01:21:24.251836Z"
413380
}
414-
]
415-
}
416-
]
381+
}
382+
}
383+
]
384+
},
385+
{
386+
"processor_results": [
387+
{
388+
"processor_type": "set",
389+
"status": "success",
390+
"doc": {
391+
"_index": "index",
392+
"_type": "_doc",
393+
"_id": "id",
394+
"_source": {
395+
"field2": "_value2",
396+
"foo": "rab"
397+
},
398+
"_ingest": {
399+
"pipeline": "_simulate_pipeline",
400+
"timestamp": "2020-07-30T01:21:24.251863Z"
401+
}
402+
}
403+
},
404+
{
405+
"processor_type": "set",
406+
"status": "success",
407+
"doc": {
408+
"_index": "index",
409+
"_type": "_doc",
410+
"_id": "id",
411+
"_source": {
412+
"field3": "_value3",
413+
"field2": "_value2",
414+
"foo": "rab"
415+
},
416+
"_ingest": {
417+
"pipeline": "_simulate_pipeline",
418+
"timestamp": "2020-07-30T01:21:24.251863Z"
419+
}
420+
}
421+
}
422+
]
423+
}
424+
]
417425
}
426+
418427
----
419-
// TESTRESPONSE[s/"2017-05-04T22:46:09.674Z"/$body.docs.0.processor_results.0.doc._ingest.timestamp/]
420-
// TESTRESPONSE[s/"2017-05-04T22:46:09.675Z"/$body.docs.0.processor_results.1.doc._ingest.timestamp/]
421-
// TESTRESPONSE[s/"2017-05-04T22:46:09.676Z"/$body.docs.1.processor_results.0.doc._ingest.timestamp/]
422-
// TESTRESPONSE[s/"2017-05-04T22:46:09.677Z"/$body.docs.1.processor_results.1.doc._ingest.timestamp/]
428+
// TESTRESPONSE[s/"2020-07-30T01:21:24.251836Z"/$body.docs.0.processor_results.0.doc._ingest.timestamp/]
429+
// TESTRESPONSE[s/"2020-07-30T01:21:24.251836Z"/$body.docs.0.processor_results.1.doc._ingest.timestamp/]
430+
// TESTRESPONSE[s/"2020-07-30T01:21:24.251863Z"/$body.docs.1.processor_results.0.doc._ingest.timestamp/]
431+
// TESTRESPONSE[s/"2020-07-30T01:21:24.251863Z"/$body.docs.1.processor_results.1.doc._ingest.timestamp/]
423432

424433
////
425434
[source,console]

modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/90_simulate.yml

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,15 @@ teardown:
559559
- match: { docs.0.processor_results.0.tag: "setstatus-1" }
560560
- match: { docs.0.processor_results.0.doc._source.field1: "123.42 400 <foo>" }
561561
- match: { docs.0.processor_results.0.doc._source.status: 200 }
562+
- match: { docs.0.processor_results.0.status: "success" }
563+
- match: { docs.0.processor_results.0.processor_type: "set" }
562564
- match: { docs.0.processor_results.1.tag: "rename-1" }
563565
- match: { docs.0.processor_results.1.ignored_error.error.type: "illegal_argument_exception" }
564566
- match: { docs.0.processor_results.1.ignored_error.error.reason: "field [foofield] doesn't exist" }
565567
- match: { docs.0.processor_results.1.doc._source.field1: "123.42 400 <foo>" }
566568
- match: { docs.0.processor_results.1.doc._source.status: 200 }
569+
- match: { docs.0.processor_results.1.status: "error_ignored" }
570+
- match: { docs.0.processor_results.1.processor_type: "rename" }
567571

568572
---
569573
"Test verbose simulate with ignore_failure and no exception thrown":
@@ -605,11 +609,16 @@ teardown:
605609
}
606610
- length: { docs: 1 }
607611
- length: { docs.0.processor_results: 2 }
612+
- length: { docs.0.processor_results.0: 4 }
608613
- match: { docs.0.processor_results.0.tag: "setstatus-1" }
614+
- match: { docs.0.processor_results.0.status: "success" }
615+
- match: { docs.0.processor_results.0.processor_type: "set" }
609616
- match: { docs.0.processor_results.0.doc._source.field1: "123.42 400 <foo>" }
610617
- match: { docs.0.processor_results.0.doc._source.status: 200 }
611-
- length: { docs.0.processor_results.1: 2 }
618+
- length: { docs.0.processor_results.1: 4 }
612619
- match: { docs.0.processor_results.1.tag: "rename-1" }
620+
- match: { docs.0.processor_results.1.status: "success" }
621+
- match: { docs.0.processor_results.1.processor_type: "rename" }
613622
- match: { docs.0.processor_results.1.doc._source.new_status: 200 }
614623

615624
---
@@ -725,7 +734,8 @@ teardown:
725734
{
726735
"set": {
727736
"field": "pipeline0",
728-
"value": true
737+
"value": true,
738+
"description" : "first_set"
729739
}
730740
},
731741
{
@@ -747,16 +757,25 @@ teardown:
747757
]
748758
}
749759
- length: { docs: 1 }
750-
- length: { docs.0.processor_results: 3 }
760+
- length: { docs.0.processor_results: 5 }
751761
- match: { docs.0.processor_results.0.doc._source.pipeline0: true }
762+
- match: { docs.0.processor_results.0.status: "success" }
763+
- match: { docs.0.processor_results.0.processor_type: "set" }
764+
- match: { docs.0.processor_results.0.description: "first_set" }
752765
- is_false: docs.0.processor_results.0.doc._source.pipeline1
753766
- is_false: docs.0.processor_results.0.doc._source.pipeline2
754-
- match: { docs.0.processor_results.1.doc._source.pipeline0: true }
755-
- match: { docs.0.processor_results.1.doc._source.pipeline1: true }
756-
- is_false: docs.0.processor_results.1.doc._source.pipeline2
767+
- match: { docs.0.processor_results.1.doc: null }
768+
- match: { docs.0.processor_results.1.status: "success" }
769+
- match: { docs.0.processor_results.1.processor_type: "pipeline" }
757770
- match: { docs.0.processor_results.2.doc._source.pipeline0: true }
758771
- match: { docs.0.processor_results.2.doc._source.pipeline1: true }
759-
- match: { docs.0.processor_results.2.doc._source.pipeline2: true }
772+
- is_false: docs.0.processor_results.2.doc._source.pipeline2
773+
- match: { docs.0.processor_results.3.doc: null }
774+
- match: { docs.0.processor_results.3.status: "success" }
775+
- match: { docs.0.processor_results.3.processor_type: "pipeline" }
776+
- match: { docs.0.processor_results.4.doc._source.pipeline0: true }
777+
- match: { docs.0.processor_results.4.doc._source.pipeline1: true }
778+
- match: { docs.0.processor_results.4.doc._source.pipeline2: true }
760779

761780
---
762781
"Test verbose simulate with true conditional and on failure":
@@ -817,19 +836,27 @@ teardown:
817836
- length: { docs.0.processor_results: 4 }
818837
- match: { docs.0.processor_results.0.tag: "gunna_fail" }
819838
- match: { docs.0.processor_results.0.error.reason: "field [foo1] doesn't exist" }
839+
- match: { docs.0.processor_results.0.status: "error" }
840+
- match: { docs.0.processor_results.0.processor_type: "rename" }
820841
- match: { docs.0.processor_results.1.tag: "failed1" }
821842
- match: { docs.0.processor_results.1.doc._source.failed1: "failed1" }
822843
- match: { docs.0.processor_results.1.doc._ingest.on_failure_processor_tag: "gunna_fail" }
844+
- match: { docs.0.processor_results.1.status: "success" }
845+
- match: { docs.0.processor_results.1.processor_type: "set" }
823846
- match: { docs.0.processor_results.2.tag: "gunna_fail_again" }
824847
- match: { docs.0.processor_results.2.error.reason: "field [foo2] doesn't exist" }
848+
- match: { docs.0.processor_results.2.status: "error" }
849+
- match: { docs.0.processor_results.2.processor_type: "rename" }
825850
- match: { docs.0.processor_results.3.tag: "failed2" }
826851
- match: { docs.0.processor_results.3.doc._source.failed1: "failed1" }
827852
- match: { docs.0.processor_results.3.doc._source.failed2: "failed2" }
828853
- match: { docs.0.processor_results.3.doc._ingest.on_failure_processor_tag: "gunna_fail_again" }
854+
- match: { docs.0.processor_results.3.status: "success" }
855+
- match: { docs.0.processor_results.3.processor_type: "set" }
829856

830857

831858
---
832-
"Test simulate with provided pipeline definition with tag and description in processors":
859+
"Test simulate with pipeline with conditional and skipped and dropped":
833860
- do:
834861
ingest.simulate:
835862
verbose: true
@@ -845,6 +872,16 @@ teardown:
845872
"field" : "field2",
846873
"value" : "_value"
847874
}
875+
},
876+
{
877+
"drop" : {
878+
"if": "false"
879+
}
880+
},
881+
{
882+
"drop" : {
883+
"if": "true"
884+
}
848885
}
849886
]
850887
},
@@ -859,7 +896,43 @@ teardown:
859896
]
860897
}
861898
- length: { docs: 1 }
862-
- length: { docs.0.processor_results: 1 }
899+
- length: { docs.0.processor_results: 3 }
863900
- match: { docs.0.processor_results.0.doc._source.field2: "_value" }
864901
- match: { docs.0.processor_results.0.description: "processor_description" }
865902
- match: { docs.0.processor_results.0.tag: "processor_tag" }
903+
- match: { docs.0.processor_results.0.status: "success" }
904+
- match: { docs.0.processor_results.0.processor_type: "set" }
905+
- match: { docs.0.processor_results.1.status: "skipped" }
906+
- match: { docs.0.processor_results.1.processor_type: "drop" }
907+
- match: { docs.0.processor_results.1.if.condition: "false" }
908+
- match: { docs.0.processor_results.1.if.result: false }
909+
- match: { docs.0.processor_results.2.status: "dropped" }
910+
- match: { docs.0.processor_results.2.processor_type: "drop" }
911+
- match: { docs.0.processor_results.2.if.condition: "true" }
912+
- match: { docs.0.processor_results.2.if.result: true }
913+
---
914+
"Test simulate with provided pipeline that does not exist":
915+
- do:
916+
catch: bad_request
917+
ingest.simulate:
918+
verbose: true
919+
body: >
920+
{
921+
"pipeline": {
922+
"description": "_description",
923+
"processors": [
924+
{
925+
"pipeline": {
926+
"name": "____pipeline_doesnot_exist___"
927+
}
928+
}
929+
]
930+
},
931+
"docs": [
932+
{
933+
"_source": {}
934+
}
935+
]
936+
}
937+
- match: { error.root_cause.0.type: "illegal_argument_exception" }
938+
- match: { error.root_cause.0.reason: "Pipeline processor configured for non-existent pipeline [____pipeline_doesnot_exist___]" }

0 commit comments

Comments
 (0)