Skip to content

Commit

Permalink
[Fleet] Fix reserved keys for Elasticsearch output YAML box (elastic#…
Browse files Browse the repository at this point in the history
…175901)

## Summary

Fixes elastic#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>
  • Loading branch information
2 people authored and nreese committed Jan 31, 2024
1 parent 7edd628 commit c888fff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
10 changes: 5 additions & 5 deletions x-pack/plugins/fleet/common/constants/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValueOf<OutputType>> = [
Expand Down
33 changes: 30 additions & 3 deletions x-pack/plugins/fleet/cypress/e2e/fleet_settings_outputs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { RESERVED_CONFIG_YML_KEYS } from '../../common/constants';

import {
getSpecificSelectorId,
SETTINGS_CONFIRM_MODAL_BTN,
Expand Down Expand Up @@ -32,30 +34,55 @@ 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();
});

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')
Expand Down

0 comments on commit c888fff

Please sign in to comment.