|
| 1 | +setup: |
| 2 | +# - requires: |
| 3 | +# cluster_features: ["DATA_STREAM_FAILURE_STORE_FEATURE"] |
| 4 | +# reason: "data stream failure store required" |
| 5 | + |
| 6 | + # Create index template for data stream with failure store enabled |
| 7 | + - do: |
| 8 | + indices.put_index_template: |
| 9 | + name: test-logs-template |
| 10 | + body: |
| 11 | + index_patterns: ["test-logs-*"] |
| 12 | + data_stream: |
| 13 | + allow_custom_routing: true |
| 14 | + template: |
| 15 | + data_stream_options: |
| 16 | + failure_store: |
| 17 | + enabled: true |
| 18 | + mappings: |
| 19 | + properties: |
| 20 | + "@timestamp": |
| 21 | + type: date |
| 22 | + message: |
| 23 | + type: text |
| 24 | + count: |
| 25 | + type: long |
| 26 | + |
| 27 | + # Create a pipeline that will cause mapping failures |
| 28 | + - do: |
| 29 | + ingest.put_pipeline: |
| 30 | + id: "failing_pipeline" |
| 31 | + body: |
| 32 | + description: "Pipeline that may cause mapping failures" |
| 33 | + processors: |
| 34 | + - set: |
| 35 | + field: count |
| 36 | + value: "not_a_number" # This will cause a mapping failure |
| 37 | + |
| 38 | + # Create a remediation-pipeline with remediate processor |
| 39 | + - do: |
| 40 | + ingest.put_pipeline: |
| 41 | + id: "remediation_pipeline" |
| 42 | + body: |
| 43 | + description: "Pipeline to remediate failed documents" |
| 44 | + processors: |
| 45 | + - remediate: {} |
| 46 | + |
| 47 | +--- |
| 48 | +teardown: |
| 49 | + - do: |
| 50 | + indices.delete_data_stream: |
| 51 | + name: test-logs-remediate |
| 52 | + ignore: 404 |
| 53 | + |
| 54 | + - do: |
| 55 | + ingest.delete_pipeline: |
| 56 | + id: "failing_pipeline" |
| 57 | + ignore: 404 |
| 58 | + |
| 59 | + - do: |
| 60 | + ingest.delete_pipeline: |
| 61 | + id: "remediation_pipeline" |
| 62 | + ignore: 404 |
| 63 | + |
| 64 | + - do: |
| 65 | + indices.delete_index_template: |
| 66 | + name: test-logs-template |
| 67 | + ignore: 404 |
| 68 | + |
| 69 | +--- |
| 70 | +"Test remediate processor with data stream failure store": |
| 71 | + # Create the data stream by indexing a document |
| 72 | + - do: |
| 73 | + index: |
| 74 | + index: test-logs-remediate |
| 75 | + routing: custom-route-123 |
| 76 | + pipeline: failing_pipeline |
| 77 | + body: |
| 78 | + "@timestamp": "2023-01-01T00:00:00Z" |
| 79 | + message: "test message" |
| 80 | + count: 42 # This will be overwritten by the pipeline and cause failure |
| 81 | + |
| 82 | + # Wait for the failure store to be populated |
| 83 | + - do: |
| 84 | + indices.refresh: |
| 85 | + index: ".fs-test-logs-remediate-*" |
| 86 | + |
| 87 | + # Check that document went to failure store |
| 88 | + - do: |
| 89 | + search: |
| 90 | + index: ".fs-test-logs-remediate-*" |
| 91 | + body: |
| 92 | + query: |
| 93 | + match_all: {} |
| 94 | + |
| 95 | + - match: { hits.total.value: 1 } |
| 96 | + - match: { hits.hits.0._source.document.source.message: "test message" } |
| 97 | + - match: { hits.hits.0._source.document.source.count: "not_a_number" } |
| 98 | + - match: { hits.hits.0._source.document.index: "test-logs-remediate" } |
| 99 | + - match: { hits.hits.0._source.document.routing: "custom-route-123" } |
| 100 | + - is_true: hits.hits.0._source.error |
| 101 | + |
| 102 | + # Get the failure document ID for remediation |
| 103 | + - set: { hits.hits.0._id: failure_doc_id } |
| 104 | + - set: { hits.hits.0._source: original_source } |
| 105 | + |
| 106 | + - do: |
| 107 | + ingest.simulate: |
| 108 | + body: |
| 109 | + pipeline: |
| 110 | + processors: |
| 111 | + - remediate: {} |
| 112 | + docs: |
| 113 | + - _source: $original_source |
| 114 | + _index: "test-logs-remediate" |
| 115 | + _id: "${failure_doc_id}" |
| 116 | + |
| 117 | + # Check that it is using the remediated format |
| 118 | + - match: { docs.0.doc._index: "test-logs-remediate" } |
| 119 | + - match: { docs.0.doc._routing: "custom-route-123" } |
| 120 | + - match: { docs.0.doc._source.message: "test message" } |
| 121 | + - match: { docs.0.doc._source.count: "not_a_number" } |
| 122 | + - is_false: docs.0.doc._source.error |
| 123 | + - is_false: docs.0.doc._source.document |
| 124 | + |
| 125 | +--- |
| 126 | +"Test remediate processor error handling - missing document field": |
| 127 | + - do: |
| 128 | + ingest.simulate: |
| 129 | + body: |
| 130 | + pipeline: |
| 131 | + processors: |
| 132 | + - remediate: {} |
| 133 | + docs: |
| 134 | + - _source: |
| 135 | + error: "simulated failure" |
| 136 | + message: "test message" |
| 137 | + count: 42 |
| 138 | + # Missing "document" field - should cause error |
| 139 | + |
| 140 | + - match: { docs.0.error.type: "illegal_argument_exception" } |
| 141 | + - match: { docs.0.error.reason: "field [document] not present as part of path [document]" } |
| 142 | + |
| 143 | +--- |
| 144 | +"Test remediate processor error handling - missing source field": |
| 145 | + - do: |
| 146 | + ingest.simulate: |
| 147 | + body: |
| 148 | + pipeline: |
| 149 | + processors: |
| 150 | + - remediate: {} |
| 151 | + docs: |
| 152 | + - _source: |
| 153 | + error: "simulated failure" |
| 154 | + document: |
| 155 | + index: "original-index" |
| 156 | + # Missing "source" field - should cause error |
| 157 | + |
| 158 | + - match: { docs.0.error.type: "illegal_argument_exception" } |
| 159 | + - match: { docs.0.error.reason: "field [source] not present as part of path [document.source]" } |
0 commit comments