From de35da590e7afa554b31ccf76a93cb9b1d8ca1e0 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 9 Oct 2024 15:11:42 -0700 Subject: [PATCH] [7.17] [UII] Adjust test based on ES version tested against (#195508) (#195665) # Backport This will backport the following commits from `main` to `7.17`: - [[UII] Adjust test based on ES version tested against (#195508)](https://github.com/elastic/kibana/pull/195508) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) \n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Jen Huang "}}]}] BACKPORT--> --- .../apis/epm/install_overrides.ts | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts index 8fa2d11f405d0..bf30840b48586 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts @@ -116,34 +116,45 @@ export default function (providerContext: FtrProviderContext) { // omit routings delete body.template.settings.index.routing; - expect(body).to.eql({ - template: { - settings: { - index: { - codec: 'best_compression', - lifecycle: { - name: 'overridden by user', - }, - mapping: { - total_fields: { - limit: '10000', - }, + expect(Object.keys(body)).to.eql(['template', 'overlapping']); + expect(body.template).to.eql({ + settings: { + index: { + codec: 'best_compression', + lifecycle: { + name: 'overridden by user', + }, + mapping: { + total_fields: { + limit: '10000', }, - number_of_shards: '3', }, + number_of_shards: '3', }, - mappings: { - dynamic: 'false', - }, - aliases: {}, }, - overlapping: [ - { - name: 'logs', - index_patterns: ['logs-*-*'], - }, - ], + mappings: { + dynamic: 'false', + }, + aliases: {}, }); + + // otel logs templates were added in 8.16 but these tests also run against + // previous versions, so we conditionally test based on the ES version + const esVersion = getService('esVersion'); + expect(body.overlapping).to.eql([ + { + name: 'logs', + index_patterns: ['logs-*-*'], + }, + ...(esVersion.matchRange('>=8.16.0') + ? [ + { + index_patterns: ['logs-*.otel-*'], + name: 'logs-otel@template', + }, + ] + : []), + ]); }); }); }