From c4815b3416279f7d952a2904e3efb23fdc0ba755 Mon Sep 17 00:00:00 2001 From: Salvatore Campagna <93581129+salvatore-campagna@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:29:38 +0200 Subject: [PATCH 1/2] LogsDB `host` and `timestamp` mappings tests (#114001) Here we are testing mappings of `host` and `timestamp` fields as they are used as default fields to sort on when using LogsDB. LogsDB uses a `host.name` field mapped as a `keyword` and a `@timestamp` field, required by data streams. Some mappings throw errors as a result of incompatibilities when trying to merge object fields. Such errors are expected. --- x-pack/plugin/logsdb/build.gradle | 6 + .../test/10_logsdb_default_mapping.yml | 254 ++++++++++++++++++ 2 files changed, 260 insertions(+) create mode 100644 x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml diff --git a/x-pack/plugin/logsdb/build.gradle b/x-pack/plugin/logsdb/build.gradle index 466cf69243c8..929d7dad2f5e 100644 --- a/x-pack/plugin/logsdb/build.gradle +++ b/x-pack/plugin/logsdb/build.gradle @@ -23,6 +23,12 @@ base { archivesName = 'x-pack-logsdb' } +restResources { + restApi { + include 'bulk', 'search', '_common', 'indices', 'index', 'cluster', 'data_stream', 'ingest', 'cat', 'capabilities' + } +} + dependencies { compileOnly project(path: xpackModule('core')) testImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml new file mode 100644 index 000000000000..8346221c0106 --- /dev/null +++ b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml @@ -0,0 +1,254 @@ +--- +create logsdb data stream with host.name as keyword: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host.name: + type: "keyword" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + indices.create_data_stream: + name: "logsdb" + + - is_true: acknowledged + +--- +create logsdb data stream with host.name as keyword and timestamp as date: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host.name: + type: "keyword" + "@timestamp": + type: "date" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + indices.create_data_stream: + name: "logsdb" + + - is_true: acknowledged + +--- +create logsdb data stream with host as keyword: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "keyword" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with host as text and multi fields: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "text" + fields: + keyword: + ignore_above: 256 + type: "keyword" + "@timestamp": + type: "date" + format: "strict_date_optional_time" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with host as text: + - requires: + cluster_features: ["mapper.keyword_normalizer_synthetic_source"] + reason: "Support for normalizer on keyword fields" + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "text" + "@timestamp": + type: "date" + format: "strict_date_optional_time" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with host as text and name as double: + - requires: + cluster_features: ["mapper.keyword_normalizer_synthetic_source"] + reason: "Support for normalizer on keyword fields" + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "text" + fields: + name: + type: "double" + "@timestamp": + type: "date" + format: "strict_date_optional_time" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with timestamp object mapping: + - requires: + cluster_features: ["mapper.keyword_normalizer_synthetic_source"] + reason: "Support for normalizer on keyword fields" + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + properties: + name: + type: "keyword" + "@timestamp": + properties: + date: + type: "date" + format: "strict_date_optional_time" + + - do: + catch: bad_request + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - match: { error.type: "illegal_argument_exception" } + - match: { error.reason: "composable template [logsdb-index-template] template after composition with component templates [logsdb-mappings] is invalid" } From adba420cea003bcda9a07107b1b773722ca51269 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 07:36:15 +1100 Subject: [PATCH 2/2] Mute org.elasticsearch.xpack.inference.InferenceRestIT test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint} #114412 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 9e95c7cb9a62..5225c0016d92 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -360,6 +360,9 @@ tests: - class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT method: test {p0=synonyms/60_synonym_rule_get/Synonym rule not found} issue: https://github.com/elastic/elasticsearch/issues/114444 +- class: org.elasticsearch.xpack.inference.InferenceRestIT + method: test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint} + issue: https://github.com/elastic/elasticsearch/issues/114412 # Examples: #