From 945d91e5e2a26c5e3afb9e428b600aa81eb30308 Mon Sep 17 00:00:00 2001 From: inge4pres Date: Mon, 9 Dec 2024 16:12:33 +0100 Subject: [PATCH] add integration tests Signed-off-by: inge4pres --- .../rest-api-spec/test/20_error_logs.yml | 23 ++++++++++++++++++ .../rest-api-spec/test/20_traces_ingest.yml | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_error_logs.yml b/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_error_logs.yml index 5d2a6ec29ff4c..98cf5060181f6 100644 --- a/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_error_logs.yml +++ b/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_error_logs.yml @@ -26,3 +26,26 @@ setup: - length: { hits.hits: 2 } - match: { hits.hits.0.fields: { "log.level": ["error"] } } - match: { hits.hits.1.fields: { "log.level": ["warn"] } } +--- +"Test traces-apm-* setting event.ingested via ingest pipeline": + - do: + bulk: + index: logs-apm.error-event-ingested-testing + refresh: true + body: + # No event.ingested field populated, it gets added + - create: {} + - '{"@timestamp": "2017-06-22", "log": {"level": "error"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}}' + + # event.ingested populated, it gets overwritten + - create: {} + - '{"@timestamp": "2017-06-22", "log": {"level": "warn"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}, "event": {"ingested": "2017-06-22 22:00:00.000Z"}}' + + - is_false: errors + + - do: + search: + index: logs-apm.error-event-ingested-testing + body: + fields: ["event.ingested"] + - length: { hits.hits: 2 } diff --git a/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml b/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml index ea7f948abf0b8..8167d912d4100 100644 --- a/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml +++ b/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml @@ -97,3 +97,27 @@ setup: - match: { hits.hits.1.fields: null } - match: { hits.hits.2.fields: {"event.success_count": [1]} } - match: { hits.hits.3.fields: {"event.success_count": [0]} } +--- +"Test traces-apm-* setting event.ingested via ingest pipeline": + - do: + bulk: + index: traces-apm-testing + refresh: true + body: + # No event.ingested field populated, it gets added + - create: {} + - '{"@timestamp": "2017-06-22"}' + + # event.ingested populated, it gets overwritten + - create: {} + - '{"@timestamp": "2017-06-22", "event": {"ingested": "2017-06-22T00:00:00.123456Z"}}' + + - is_false: errors + + - do: + search: + index: traces-apm-testing + body: + fields: ["event.ingested"] + - length: { hits.hits: 2 } +