From c888fff2af93d1532e6495fa81095b02aea7ee63 Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Tue, 30 Jan 2024 11:30:36 -0500 Subject: [PATCH] [Fleet] Fix reserved keys for Elasticsearch output YAML box (#175901) ## Summary Fixes #175892 Updates reserved keywords that trigger the `Custom` preset for the Elasticsearch output. https://github.com/elastic/kibana/assets/6766512/dda60f6c-d77e-4e98-946b-2c389660074b Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../plugins/fleet/common/constants/output.ts | 10 +++--- .../cypress/e2e/fleet_settings_outputs.cy.ts | 33 +++++++++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/fleet/common/constants/output.ts b/x-pack/plugins/fleet/common/constants/output.ts index 4d75f79df0a2625..cdd52a42f3e6c4a 100644 --- a/x-pack/plugins/fleet/common/constants/output.ts +++ b/x-pack/plugins/fleet/common/constants/output.ts @@ -122,12 +122,12 @@ export const kafkaSupportedVersions = [ export const RESERVED_CONFIG_YML_KEYS = [ 'bulk_max_size', - 'workers', + 'compression_level', + 'connection_idle_timeout', 'queue.mem.events', - 'flush.min_events', - 'flush.timeout', - 'compression', - 'idle_timeout', + 'queue.mem.flush.min_events', + 'queue.mem.flush.timeout', + 'workers', ]; export const OUTPUT_TYPES_WITH_PRESET_SUPPORT: Array> = [ diff --git a/x-pack/plugins/fleet/cypress/e2e/fleet_settings_outputs.cy.ts b/x-pack/plugins/fleet/cypress/e2e/fleet_settings_outputs.cy.ts index d759811883dc468..cd41b92cb6a8d2d 100644 --- a/x-pack/plugins/fleet/cypress/e2e/fleet_settings_outputs.cy.ts +++ b/x-pack/plugins/fleet/cypress/e2e/fleet_settings_outputs.cy.ts @@ -5,6 +5,8 @@ * 2.0. */ +import { RESERVED_CONFIG_YML_KEYS } from '../../common/constants'; + import { getSpecificSelectorId, SETTINGS_CONFIRM_MODAL_BTN, @@ -32,13 +34,16 @@ import { } from '../screens/fleet_outputs'; import { login } from '../tasks/login'; - import { visit } from '../tasks/common'; export const fillYamlConfigBox = (query: string) => { cy.get('[data-test-subj="kibanaCodeEditor"] textarea').type(query, { force: true }); }; +export const clearYamlConfigBox = () => { + cy.get('[data-test-subj="kibanaCodeEditor"] textarea').clear({ force: true }); +}; + describe('Outputs', () => { beforeEach(() => { login(); @@ -46,16 +51,38 @@ describe('Outputs', () => { describe('Elasticsearch', () => { describe('Preset input', () => { + afterEach(() => { + clearYamlConfigBox(); + cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT).select('balanced'); + }); + it('is set to balanced by default', () => { selectESOutput(); cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT).should('have.value', 'balanced'); }); - it('forces custom when reserved key is included in config YAML box', () => { + for (const keyword of RESERVED_CONFIG_YML_KEYS) { + it(`forces custom when reserved key ${keyword} is included in config YAML box`, () => { + selectESOutput(); + + fillYamlConfigBox(`${keyword}: value`); + + cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT) + .should('have.value', 'custom') + .should('be.disabled'); + }); + } + + it('handles expanded syntax for reserved keys', () => { selectESOutput(); - fillYamlConfigBox('bulk_max_size: 1000'); + fillYamlConfigBox(` +queue: + mem: + flush: + min_events: 100 + `); cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT) .should('have.value', 'custom')