From 19a11ef88a4b125146335f499d88d7e65beb747e Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Fri, 14 Feb 2025 14:39:15 +0100 Subject: [PATCH 1/6] --cached --- .../management/index_management/settings.ts | 137 +++++++++++------- 1 file changed, 82 insertions(+), 55 deletions(-) diff --git a/x-pack/test/api_integration/apis/management/index_management/settings.ts b/x-pack/test/api_integration/apis/management/index_management/settings.ts index 24819d177ccf0..abf6ce1da0aca 100644 --- a/x-pack/test/api_integration/apis/management/index_management/settings.ts +++ b/x-pack/test/api_integration/apis/management/index_management/settings.ts @@ -18,6 +18,60 @@ export default function ({ getService }: FtrProviderContext) { describe('settings', () => { after(async () => await deleteAllIndices()); + const expectedIndexSettings = [ + 'max_inner_result_window', + 'unassigned', + 'max_terms_count', + 'lifecycle', + 'routing_partition_size', + 'max_docvalue_fields_search', + 'merge', + 'max_refresh_listeners', + 'max_regex_length', + 'load_fixed_bitset_filters_eagerly', + 'number_of_routing_shards', + 'write', + 'verified_before_close', + 'mapping', + 'source_only', + 'soft_deletes', + 'max_script_fields', + 'query', + 'format', + 'frozen', + 'sort', + 'priority', + 'codec', + 'max_rescore_window', + 'analyze', + 'gc_deletes', + 'max_ngram_diff', + 'translog', + 'auto_expand_replicas', + 'requests', + 'data_path', + 'highlight', + 'routing', + 'search', + 'fielddata', + 'default_pipeline', + 'max_slices_per_scroll', + 'shard', + 'xpack', + 'percolator', + 'allocation', + 'refresh_interval', + 'indexing', + 'compound_format', + 'blocks', + 'max_result_window', + 'store', + 'queries', + 'warmer', + 'max_shingle_diff', + 'query_string', + ]; + it('should fetch an index settings', async () => { const index = await createIndex(); @@ -27,62 +81,8 @@ export default function ({ getService }: FtrProviderContext) { // Verify we fetch the corret index settings expect(body.settings.index.provided_name).to.be(index); - const expectedSettings = [ - 'max_inner_result_window', - 'unassigned', - 'max_terms_count', - 'lifecycle', - 'routing_partition_size', - 'max_docvalue_fields_search', - 'merge', - 'max_refresh_listeners', - 'max_regex_length', - 'load_fixed_bitset_filters_eagerly', - 'number_of_routing_shards', - 'write', - 'verified_before_close', - 'mapping', - 'source_only', - 'soft_deletes', - 'max_script_fields', - 'query', - 'format', - 'frozen', - 'sort', - 'priority', - 'codec', - 'max_rescore_window', - 'analyze', - 'gc_deletes', - 'max_ngram_diff', - 'translog', - 'auto_expand_replicas', - 'requests', - 'data_path', - 'highlight', - 'routing', - 'search', - 'fielddata', - 'default_pipeline', - 'max_slices_per_scroll', - 'shard', - 'xpack', - 'percolator', - 'allocation', - 'refresh_interval', - 'indexing', - 'compound_format', - 'blocks', - 'max_result_window', - 'store', - 'queries', - 'warmer', - 'max_shingle_diff', - 'query_string', - ]; - // Make sure none of the settings have been removed from ES API - expectedSettings.forEach((setting) => { + expectedIndexSettings.forEach((setting) => { try { expect(Object.hasOwn(body.defaults.index, setting)).to.be(true); } catch { @@ -91,6 +91,33 @@ export default function ({ getService }: FtrProviderContext) { }); }); + describe('Forward compatibility with 9.x', function () { + this.onlyEsVersion('>=9'); + + it('should fetch an index settings', async () => { + const indexSettingsNotIn9 = ['frozen']; + + const index = await createIndex(); + + const { status, body } = await getIndexSettings(index); + expect(status).to.eql(200); + + // Verify we fetch the corret index settings + expect(body.settings.index.provided_name).to.be(index); + + // Make sure none of the settings have been removed from ES API + expectedIndexSettings + .filter((setting) => !indexSettingsNotIn9.includes(setting)) + .forEach((setting) => { + try { + expect(Object.hasOwn(body.defaults.index, setting)).to.be(true); + } catch { + throw new Error(`Expected setting "${setting}" not found.`); + } + }); + }); + }); + it('should update an index settings', async () => { const index = await createIndex(); From f71b05459e3c3859291c0b078f93cbdda193aa6e Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Fri, 14 Feb 2025 14:40:09 +0100 Subject: [PATCH 2/6] commit with @elastic email From d2f9fc6f30ffe9a3e518d5a8ad6a7e59219c64c4 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Sat, 15 Feb 2025 07:59:07 +0100 Subject: [PATCH 3/6] Ensure the test only runs once for each major --- .../apis/management/index_management/settings.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/test/api_integration/apis/management/index_management/settings.ts b/x-pack/test/api_integration/apis/management/index_management/settings.ts index abf6ce1da0aca..d897b9db0bc20 100644 --- a/x-pack/test/api_integration/apis/management/index_management/settings.ts +++ b/x-pack/test/api_integration/apis/management/index_management/settings.ts @@ -73,6 +73,8 @@ export default function ({ getService }: FtrProviderContext) { ]; it('should fetch an index settings', async () => { + this.onlyEsVersion('8'); + const index = await createIndex(); const { status, body } = await getIndexSettings(index); From 532bf9561d615e71708647d7649117651219b113 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Sat, 15 Feb 2025 17:31:52 +0100 Subject: [PATCH 4/6] Dont use arrow function --- .../apis/management/index_management/settings.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/management/index_management/settings.ts b/x-pack/test/api_integration/apis/management/index_management/settings.ts index d897b9db0bc20..2a2d36e4fbd03 100644 --- a/x-pack/test/api_integration/apis/management/index_management/settings.ts +++ b/x-pack/test/api_integration/apis/management/index_management/settings.ts @@ -72,7 +72,8 @@ export default function ({ getService }: FtrProviderContext) { 'query_string', ]; - it('should fetch an index settings', async () => { + + it('should fetch an index settings', async function () { this.onlyEsVersion('8'); const index = await createIndex(); From 95a66026aa32368e04e884542a3d13268cc738a8 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 15 Feb 2025 16:58:32 +0000 Subject: [PATCH 5/6] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../api_integration/apis/management/index_management/settings.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/management/index_management/settings.ts b/x-pack/test/api_integration/apis/management/index_management/settings.ts index 2a2d36e4fbd03..394a3e936b5ac 100644 --- a/x-pack/test/api_integration/apis/management/index_management/settings.ts +++ b/x-pack/test/api_integration/apis/management/index_management/settings.ts @@ -72,7 +72,6 @@ export default function ({ getService }: FtrProviderContext) { 'query_string', ]; - it('should fetch an index settings', async function () { this.onlyEsVersion('8'); From 542211955d169005fad7558bed828a26ac1bbf37 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Sun, 16 Feb 2025 16:13:07 +0100 Subject: [PATCH 6/6] Wrap around describe --- .../management/index_management/settings.ts | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/x-pack/test/api_integration/apis/management/index_management/settings.ts b/x-pack/test/api_integration/apis/management/index_management/settings.ts index 394a3e936b5ac..ffd526c9b0791 100644 --- a/x-pack/test/api_integration/apis/management/index_management/settings.ts +++ b/x-pack/test/api_integration/apis/management/index_management/settings.ts @@ -72,24 +72,26 @@ export default function ({ getService }: FtrProviderContext) { 'query_string', ]; - it('should fetch an index settings', async function () { + describe('8.x specific tests', function () { this.onlyEsVersion('8'); - const index = await createIndex(); + it('should fetch an index settings', async function () { + const index = await createIndex(); - const { status, body } = await getIndexSettings(index); - expect(status).to.eql(200); + const { status, body } = await getIndexSettings(index); + expect(status).to.eql(200); - // Verify we fetch the corret index settings - expect(body.settings.index.provided_name).to.be(index); + // Verify we fetch the corret index settings + expect(body.settings.index.provided_name).to.be(index); - // Make sure none of the settings have been removed from ES API - expectedIndexSettings.forEach((setting) => { - try { - expect(Object.hasOwn(body.defaults.index, setting)).to.be(true); - } catch { - throw new Error(`Expected setting "${setting}" not found.`); - } + // Make sure none of the settings have been removed from ES API + expectedIndexSettings.forEach((setting) => { + try { + expect(Object.hasOwn(body.defaults.index, setting)).to.be(true); + } catch { + throw new Error(`Expected setting "${setting}" not found.`); + } + }); }); });