Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Fix reserved keys for Elasticsearch output YAML box #175901

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Comment on lines -125 to +130
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted these alphabetically, hence the diff

];

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
Loading