From 9cf478b4a38b8c9774d36b65695f42dc96932484 Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Mon, 15 Apr 2024 10:56:02 +0200 Subject: [PATCH 1/5] [Discover] Unskip field token flaky tests (#180721) - Closes https://github.com/elastic/kibana/issues/180622 75x https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5668 --- .../discover/group2/_data_grid_field_tokens.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/functional/apps/discover/group2/_data_grid_field_tokens.ts b/test/functional/apps/discover/group2/_data_grid_field_tokens.ts index 0782180ab79f0..74586018761aa 100644 --- a/test/functional/apps/discover/group2/_data_grid_field_tokens.ts +++ b/test/functional/apps/discover/group2/_data_grid_field_tokens.ts @@ -32,12 +32,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; async function findFirstColumnTokens() { + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); return await findFirstFieldIcons('euiDataGridBody > dataGridHeader'); } async function findFirstDocViewerTokens() { - await dataGrid.clickRowToggle({ rowIndex: 0 }); - return await findFirstFieldIcons('docTableDetailsFlyout'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + let fieldTokens: string[] | undefined = []; + await retry.try(async () => { + await dataGrid.clickRowToggle({ rowIndex: 0 }); + fieldTokens = await findFirstFieldIcons('docTableDetailsFlyout'); + }); + return fieldTokens; } async function findFirstFieldIcons(elementSelector: string) { @@ -62,8 +70,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return firstFieldIcons; } - // FLAKY: https://github.com/elastic/kibana/issues/180622 - describe.skip('discover data grid field tokens', function () { + describe('discover data grid field tokens', function () { before(async () => { await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); From 4f8e07ad8f68549651ff31357739a20c7d44908a Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 15 Apr 2024 05:36:47 -0400 Subject: [PATCH 2/5] skip failing test suite (#180756) --- .../timelines/esql/esql_assistant.cy.ts | 277 +++++++++--------- 1 file changed, 137 insertions(+), 140 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts index af66b1672c3e4..788c3611c2982 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts @@ -20,160 +20,157 @@ const ESQL_QUERY = 'from auditbeat-* | where ecs.version == "8.0.0"'; const KQL_QUERY = '_index : "auditbeat-*" and ecs.version : "8.0.0"'; const EQL_QUERY = 'process where process.name == "zsh"'; -describe( - 'Basic Assistant tests', - { - tags: ['@ess'], - env: { - ftrConfig: { - kbnServerArgs: [ - `--xpack.actions.preconfigured=${JSON.stringify({ - 'preconfigured-openai': { - name: 'preconfigured-openai', - actionTypeId: '.gen-ai', - config: { - apiProvider: 'OpenAI', - apiUrl: 'https://api.openai.com/v1/chat/completions', - defaultModel: 'gpt-4', - }, - secrets: { - apiKey: 'superlongapikey', - }, +// Failing: See https://github.com/elastic/kibana/issues/180756 +describe.skip('Basic Assistant tests', { + tags: ['@ess'], + env: { + ftrConfig: { + kbnServerArgs: [ + `--xpack.actions.preconfigured=${JSON.stringify({ + 'preconfigured-openai': { + name: 'preconfigured-openai', + actionTypeId: '.gen-ai', + config: { + apiProvider: 'OpenAI', + apiUrl: 'https://api.openai.com/v1/chat/completions', + defaultModel: 'gpt-4', }, - })}`, - ], - }, + secrets: { + apiKey: 'superlongapikey', + }, + }, + })}`, + ], }, }, - () => { - before(() => { +}, () => { + before(() => { + login(); + visitWithTimeRange(ALERTS_URL); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get( + '[data-test-subj="conversation-selector"] [data-test-subj="comboBoxSearchInput"]' + ).should('not.be.disabled'); + cy.get('[data-test-subj="prompt-textarea"]').then(($el) => { + if ($el.is(':disabled')) { + cy.get('[data-test-subj="connectorMissingCallout"]').find('button').click(); + cy.get('[data-test-subj="connector-selector"]').click(); + cy.get('[data-test-subj="preconfigured-openai"]').click(); + cy.get('[data-test-subj="save-button"]').click(); + } + }); + }); + + describe('ES|QL', () => { + beforeEach(() => { login(); visitWithTimeRange(ALERTS_URL); cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get( - '[data-test-subj="conversation-selector"] [data-test-subj="comboBoxSearchInput"]' - ).should('not.be.disabled'); - cy.get('[data-test-subj="prompt-textarea"]').then(($el) => { - if ($el.is(':disabled')) { - cy.get('[data-test-subj="connectorMissingCallout"]').find('button').click(); - cy.get('[data-test-subj="connector-selector"]').click(); - cy.get('[data-test-subj="preconfigured-openai"]').click(); - cy.get('[data-test-subj="save-button"]').click(); - } - }); + cy.get('[data-test-subj="conversation-selector"]') + .find('[data-test-subj="comboBoxSearchInput"]') + .type(`New conversation-` + Date.now()); + cy.get('[data-test-subj="prompt-textarea"]').type( + 'Below is an `Elasticsearch Query Language` query:' + + '{shift}{enter}' + + '```esql' + + '{shift}{enter}' + + `${ESQL_QUERY} | limit 1` + + '{shift}{enter}' + + '```' + ); + cy.get('[data-test-subj="submit-chat"]').click(); + visitWithTimeRange(ALERTS_URL); }); - describe('ES|QL', () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="conversation-selector"]') - .find('[data-test-subj="comboBoxSearchInput"]') - .type(`New conversation-` + Date.now()); - cy.get('[data-test-subj="prompt-textarea"]').type( - 'Below is an `Elasticsearch Query Language` query:' + - '{shift}{enter}' + - '```esql' + - '{shift}{enter}' + - `${ESQL_QUERY} | limit 1` + - '{shift}{enter}' + - '```' - ); - cy.get('[data-test-subj="submit-chat"]').click(); - visitWithTimeRange(ALERTS_URL); - }); - - it('should properly propagate esql query to discover when Timeline was not opened before', () => { - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); - updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); - submitDiscoverSearchBar(); - cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); - }); + it('should properly propagate esql query to discover when Timeline was not opened before', () => { + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); + updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); + submitDiscoverSearchBar(); + cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); + }); - it('should properly propagate esql query to discover when Timeline is active', () => { - openActiveTimeline(); - cy.window().then((win) => { - win.onbeforeunload = null; - }); - goToEsqlTab(); - updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); - submitDiscoverSearchBar(); - cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); + it('should properly propagate esql query to discover when Timeline is active', () => { + openActiveTimeline(); + cy.window().then((win) => { + win.onbeforeunload = null; }); + goToEsqlTab(); + updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); + submitDiscoverSearchBar(); + cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); }); + }); - describe('KQL', () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="conversation-selector"]') - .find('[data-test-subj="comboBoxSearchInput"]') - .type(`New conversation-` + Date.now()); - }); + describe('KQL', () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="conversation-selector"]') + .find('[data-test-subj="comboBoxSearchInput"]') + .type(`New conversation-` + Date.now()); + }); - it('should properly propagate KQL query', () => { - cy.get('[data-test-subj="prompt-textarea"]').type( - 'Below is an `Elasticsearch Query Language` query:' + - '{shift}{enter}' + - '```kql' + - '{shift}{enter}' + - `${KQL_QUERY}` + - '{shift}{enter}' + - '```' - ); - cy.get('[data-test-subj="submit-chat"]').click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="timelineQueryInput"]', KQL_QUERY); - cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); - cy.get('[data-test-subj="server-side-event-count"]') - .filter(':visible') - .should('have.text', 1); - }); + it('should properly propagate KQL query', () => { + cy.get('[data-test-subj="prompt-textarea"]').type( + 'Below is an `Elasticsearch Query Language` query:' + + '{shift}{enter}' + + '```kql' + + '{shift}{enter}' + + `${KQL_QUERY}` + + '{shift}{enter}' + + '```' + ); + cy.get('[data-test-subj="submit-chat"]').click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="timelineQueryInput"]', KQL_QUERY); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); + cy.get('[data-test-subj="server-side-event-count"]') + .filter(':visible') + .should('have.text', 1); }); + }); - describe('EQL', () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="conversation-selector"]') - .find('[data-test-subj="comboBoxSearchInput"]') - .type(`New conversation-` + Date.now()); - }); + describe('EQL', () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="conversation-selector"]') + .find('[data-test-subj="comboBoxSearchInput"]') + .type(`New conversation-` + Date.now()); + }); - it('should properly propagate EQL query', () => { - cy.get('[data-test-subj="prompt-textarea"]').type( - 'Below is an `Elasticsearch Query Language` query:' + - '{shift}{enter}' + - '```eql' + - '{shift}{enter}' + - `${EQL_QUERY}` + - '{shift}{enter}' + - '```' - ); - cy.get('[data-test-subj="submit-chat"]').click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="eqlQueryBarTextInput"]', `${EQL_QUERY}`); - cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); - cy.get('[data-test-subj="server-side-event-count"]') - .filter(':visible') - .should('have.text', 1); - }); + it('should properly propagate EQL query', () => { + cy.get('[data-test-subj="prompt-textarea"]').type( + 'Below is an `Elasticsearch Query Language` query:' + + '{shift}{enter}' + + '```eql' + + '{shift}{enter}' + + `${EQL_QUERY}` + + '{shift}{enter}' + + '```' + ); + cy.get('[data-test-subj="submit-chat"]').click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="eqlQueryBarTextInput"]', `${EQL_QUERY}`); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); + cy.get('[data-test-subj="server-side-event-count"]') + .filter(':visible') + .should('have.text', 1); }); - } -); + }); +}); From a47ac326602d29465d316c69c53e0177f4d67481 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 15 Apr 2024 05:38:45 -0400 Subject: [PATCH 3/5] skip failing test suite (#180755) --- .../discover_timeline_state_integration.cy.ts | 288 +++++++++--------- 1 file changed, 142 insertions(+), 146 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts index ff932a44b0da4..542d8016384ba 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts @@ -69,161 +69,157 @@ const handleIntercepts = () => { }); }; -describe( - 'Discover Timeline State Integration', - { - tags: ['@ess', '@skipInServerless'], - }, +// Failing: See https://github.com/elastic/kibana/issues/180755 +describe.skip('Discover Timeline State Integration', { + tags: ['@ess', '@skipInServerless'], +}, () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + createTimelineFromBottomBar(); + goToEsqlTab(); + updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); + handleIntercepts(); + }); - () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - createTimelineFromBottomBar(); + describe('ESQL tab state', () => { + it('should be able create an empty timeline with default esql tab state', () => { + addNameToTimelineAndSave('Timerange timeline'); + createNewTimeline(); goToEsqlTab(); - updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); - handleIntercepts(); + cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).should( + 'contain.text', + `Last 15 minutes` + ); }); + it('should save/restore esql tab dataview/timerange/filter/query/columns when saving/resoring timeline', () => { + const timelineSuffix = Date.now(); + const timelineName = `DataView timeline-${timelineSuffix}`; + const column1 = 'event.category'; + const column2 = 'ecs.version'; + addDiscoverEsqlQuery(esqlQuery); + addFieldToTable(column1); + addFieldToTable(column2); - describe('ESQL tab state', () => { - it('should be able create an empty timeline with default esql tab state', () => { - addNameToTimelineAndSave('Timerange timeline'); - createNewTimeline(); - goToEsqlTab(); - cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).should( - 'contain.text', - `Last 15 minutes` - ); - }); - it('should save/restore esql tab dataview/timerange/filter/query/columns when saving/resoring timeline', () => { - const timelineSuffix = Date.now(); - const timelineName = `DataView timeline-${timelineSuffix}`; - const column1 = 'event.category'; - const column2 = 'ecs.version'; - addDiscoverEsqlQuery(esqlQuery); - addFieldToTable(column1); - addFieldToTable(column2); + // create a custom timeline + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_PATCH_REQ}`) + .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) + .then((timelineId) => { + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + // create an empty timeline + createNewTimeline(); + // switch to old timeline + openTimelineFromSettings(); + openTimelineById(timelineId); + goToEsqlTab(); + cy.get(LOADING_INDICATOR).should('not.exist'); + verifyDiscoverEsqlQuery(esqlQuery); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); + cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( + 'have.text', + INITIAL_START_DATE + ); + }); + }); + it('should save/restore esql tab dataview/timerange/filter/query/columns when timeline is opened via url', () => { + const timelineSuffix = Date.now(); + const timelineName = `DataView timeline-${timelineSuffix}`; + const column1 = 'event.category'; + const column2 = 'ecs.version'; + addDiscoverEsqlQuery(esqlQuery); + addFieldToTable(column1); + addFieldToTable(column2); - // create a custom timeline - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_PATCH_REQ}`) - .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) - .then((timelineId) => { - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - // create an empty timeline - createNewTimeline(); - // switch to old timeline - openTimelineFromSettings(); - openTimelineById(timelineId); - goToEsqlTab(); + // create a custom timeline + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_PATCH_REQ}`) + .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) + .then((timelineId) => { + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + // reload the page with the exact url + cy.reload(); + verifyDiscoverEsqlQuery(esqlQuery); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); + cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( + 'have.text', + INITIAL_START_DATE + ); + }); + }); + it('should save/restore esql tab ES|QL when saving timeline', () => { + const timelineSuffix = Date.now(); + const timelineName = `ES|QL timeline-${timelineSuffix}`; + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_PATCH_REQ}`) + .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) + .then((timelineId) => { + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + // create an empty timeline + createNewTimeline(); + // switch to old timeline + openTimelineFromSettings(); + openTimelineById(timelineId).then(() => { cy.get(LOADING_INDICATOR).should('not.exist'); - verifyDiscoverEsqlQuery(esqlQuery); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); - cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( - 'have.text', - INITIAL_START_DATE - ); - }); - }); - it('should save/restore esql tab dataview/timerange/filter/query/columns when timeline is opened via url', () => { - const timelineSuffix = Date.now(); - const timelineName = `DataView timeline-${timelineSuffix}`; - const column1 = 'event.category'; - const column2 = 'ecs.version'; - addDiscoverEsqlQuery(esqlQuery); - addFieldToTable(column1); - addFieldToTable(column2); - - // create a custom timeline - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_PATCH_REQ}`) - .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) - .then((timelineId) => { - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - // reload the page with the exact url - cy.reload(); - verifyDiscoverEsqlQuery(esqlQuery); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); - cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( - 'have.text', - INITIAL_START_DATE - ); - }); - }); - it('should save/restore esql tab ES|QL when saving timeline', () => { - const timelineSuffix = Date.now(); - const timelineName = `ES|QL timeline-${timelineSuffix}`; - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_PATCH_REQ}`) - .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) - .then((timelineId) => { - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - // create an empty timeline - createNewTimeline(); - // switch to old timeline - openTimelineFromSettings(); - openTimelineById(timelineId).then(() => { - cy.get(LOADING_INDICATOR).should('not.exist'); - goToEsqlTab(); - cy.get(DISCOVER_DATA_VIEW_SWITCHER.BTN).should('not.exist'); - }); + goToEsqlTab(); + cy.get(DISCOVER_DATA_VIEW_SWITCHER.BTN).should('not.exist'); }); - }); + }); }); + }); - describe('Discover saved search state for ESQL tab', () => { - it('should save esql tab saved search with `Security Solution` tag', () => { - const timelineSuffix = Date.now(); - const timelineName = `SavedObject timeline-${timelineSuffix}`; - addDiscoverEsqlQuery(esqlQuery); - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - cy.get(LOADING_INDICATOR).should('not.exist'); - openKibanaNavigation(); - navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); - cy.get(LOADING_INDICATOR).should('not.exist'); - goToSavedObjectSettings(); - cy.get(LOADING_INDICATOR).should('not.exist'); - clickSavedObjectTagsFilter(); - cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); - cy.get(BASIC_TABLE_LOADING).should('not.exist'); - cy.get(SAVED_OBJECTS_ROW_TITLES).should( - 'contain.text', - `Saved search for timeline - ${timelineName}` - ); - }); - - it('should rename the saved search on timeline rename', () => { - const initialTimelineSuffix = Date.now(); - const initialTimelineName = `Timeline-${initialTimelineSuffix}`; - addDiscoverEsqlQuery(esqlQuery); - addNameToTimelineAndSave(initialTimelineName); - cy.get(LOADING_INDICATOR).should('not.exist'); - const timelineSuffix = Date.now(); - const renamedTimelineName = `Rename timeline-${timelineSuffix}`; - addNameToTimelineAndSave(renamedTimelineName); - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - openKibanaNavigation(); - navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); - cy.get(LOADING_INDICATOR).should('not.exist'); - goToSavedObjectSettings(); - cy.get(LOADING_INDICATOR).should('not.exist'); - clickSavedObjectTagsFilter(); - cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); - cy.get(BASIC_TABLE_LOADING).should('not.exist'); - cy.get(SAVED_OBJECTS_ROW_TITLES).should( - 'contain.text', - `Saved search for timeline - ${renamedTimelineName}` - ); - }); + describe('Discover saved search state for ESQL tab', () => { + it('should save esql tab saved search with `Security Solution` tag', () => { + const timelineSuffix = Date.now(); + const timelineName = `SavedObject timeline-${timelineSuffix}`; + addDiscoverEsqlQuery(esqlQuery); + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + cy.get(LOADING_INDICATOR).should('not.exist'); + openKibanaNavigation(); + navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); + cy.get(LOADING_INDICATOR).should('not.exist'); + goToSavedObjectSettings(); + cy.get(LOADING_INDICATOR).should('not.exist'); + clickSavedObjectTagsFilter(); + cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); + cy.get(BASIC_TABLE_LOADING).should('not.exist'); + cy.get(SAVED_OBJECTS_ROW_TITLES).should( + 'contain.text', + `Saved search for timeline - ${timelineName}` + ); }); - // Issue for enabling below tests: https://github.com/elastic/kibana/issues/165913 - context.skip('Advanced Settings', () => { - it('rows per page in saved search should be according to the user selected number of pages', () => {}); - it('rows per page in new search should be according to the value selected in advanced settings', () => {}); + it('should rename the saved search on timeline rename', () => { + const initialTimelineSuffix = Date.now(); + const initialTimelineName = `Timeline-${initialTimelineSuffix}`; + addDiscoverEsqlQuery(esqlQuery); + addNameToTimelineAndSave(initialTimelineName); + cy.get(LOADING_INDICATOR).should('not.exist'); + const timelineSuffix = Date.now(); + const renamedTimelineName = `Rename timeline-${timelineSuffix}`; + addNameToTimelineAndSave(renamedTimelineName); + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + openKibanaNavigation(); + navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); + cy.get(LOADING_INDICATOR).should('not.exist'); + goToSavedObjectSettings(); + cy.get(LOADING_INDICATOR).should('not.exist'); + clickSavedObjectTagsFilter(); + cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); + cy.get(BASIC_TABLE_LOADING).should('not.exist'); + cy.get(SAVED_OBJECTS_ROW_TITLES).should( + 'contain.text', + `Saved search for timeline - ${renamedTimelineName}` + ); }); - } -); + }); + + // Issue for enabling below tests: https://github.com/elastic/kibana/issues/165913 + context.skip('Advanced Settings', () => { + it('rows per page in saved search should be according to the user selected number of pages', () => {}); + it('rows per page in new search should be according to the value selected in advanced settings', () => {}); + }); +}); From fd904624867ff33163253b1e7fd9c6e1f68c2a29 Mon Sep 17 00:00:00 2001 From: Alex Szabo Date: Mon, 15 Apr 2024 12:04:23 +0200 Subject: [PATCH 4/5] fix formatting for skipped tests (#180779) ## Summary Follow up on: - https://github.com/elastic/kibana/issues/180756 - https://github.com/elastic/kibana/issues/180755 Context: https://elastic.slack.com/archives/C013B57RRGE/p1713169263454469 --- .../discover_timeline_state_integration.cy.ts | 288 +++++++++--------- .../timelines/esql/esql_assistant.cy.ts | 276 ++++++++--------- 2 files changed, 286 insertions(+), 278 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts index 542d8016384ba..f27502dcd2bad 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/discover_timeline_state_integration.cy.ts @@ -70,156 +70,160 @@ const handleIntercepts = () => { }; // Failing: See https://github.com/elastic/kibana/issues/180755 -describe.skip('Discover Timeline State Integration', { - tags: ['@ess', '@skipInServerless'], -}, () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - createTimelineFromBottomBar(); - goToEsqlTab(); - updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); - handleIntercepts(); - }); - - describe('ESQL tab state', () => { - it('should be able create an empty timeline with default esql tab state', () => { - addNameToTimelineAndSave('Timerange timeline'); - createNewTimeline(); +describe.skip( + 'Discover Timeline State Integration', + { + tags: ['@ess', '@skipInServerless'], + }, + () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + createTimelineFromBottomBar(); goToEsqlTab(); - cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).should( - 'contain.text', - `Last 15 minutes` - ); + updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); + handleIntercepts(); }); - it('should save/restore esql tab dataview/timerange/filter/query/columns when saving/resoring timeline', () => { - const timelineSuffix = Date.now(); - const timelineName = `DataView timeline-${timelineSuffix}`; - const column1 = 'event.category'; - const column2 = 'ecs.version'; - addDiscoverEsqlQuery(esqlQuery); - addFieldToTable(column1); - addFieldToTable(column2); - // create a custom timeline - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_PATCH_REQ}`) - .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) - .then((timelineId) => { - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - // create an empty timeline - createNewTimeline(); - // switch to old timeline - openTimelineFromSettings(); - openTimelineById(timelineId); - goToEsqlTab(); - cy.get(LOADING_INDICATOR).should('not.exist'); - verifyDiscoverEsqlQuery(esqlQuery); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); - cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( - 'have.text', - INITIAL_START_DATE - ); - }); - }); - it('should save/restore esql tab dataview/timerange/filter/query/columns when timeline is opened via url', () => { - const timelineSuffix = Date.now(); - const timelineName = `DataView timeline-${timelineSuffix}`; - const column1 = 'event.category'; - const column2 = 'ecs.version'; - addDiscoverEsqlQuery(esqlQuery); - addFieldToTable(column1); - addFieldToTable(column2); + describe('ESQL tab state', () => { + it('should be able create an empty timeline with default esql tab state', () => { + addNameToTimelineAndSave('Timerange timeline'); + createNewTimeline(); + goToEsqlTab(); + cy.get(GET_LOCAL_SHOW_DATES_BUTTON(DISCOVER_CONTAINER)).should( + 'contain.text', + `Last 15 minutes` + ); + }); + it('should save/restore esql tab dataview/timerange/filter/query/columns when saving/resoring timeline', () => { + const timelineSuffix = Date.now(); + const timelineName = `DataView timeline-${timelineSuffix}`; + const column1 = 'event.category'; + const column2 = 'ecs.version'; + addDiscoverEsqlQuery(esqlQuery); + addFieldToTable(column1); + addFieldToTable(column2); - // create a custom timeline - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_PATCH_REQ}`) - .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) - .then((timelineId) => { - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - // reload the page with the exact url - cy.reload(); - verifyDiscoverEsqlQuery(esqlQuery); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); - cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); - cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( - 'have.text', - INITIAL_START_DATE - ); - }); - }); - it('should save/restore esql tab ES|QL when saving timeline', () => { - const timelineSuffix = Date.now(); - const timelineName = `ES|QL timeline-${timelineSuffix}`; - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_PATCH_REQ}`) - .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) - .then((timelineId) => { - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - // create an empty timeline - createNewTimeline(); - // switch to old timeline - openTimelineFromSettings(); - openTimelineById(timelineId).then(() => { - cy.get(LOADING_INDICATOR).should('not.exist'); + // create a custom timeline + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_PATCH_REQ}`) + .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) + .then((timelineId) => { + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + // create an empty timeline + createNewTimeline(); + // switch to old timeline + openTimelineFromSettings(); + openTimelineById(timelineId); goToEsqlTab(); - cy.get(DISCOVER_DATA_VIEW_SWITCHER.BTN).should('not.exist'); + cy.get(LOADING_INDICATOR).should('not.exist'); + verifyDiscoverEsqlQuery(esqlQuery); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); + cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( + 'have.text', + INITIAL_START_DATE + ); }); - }); - }); - }); + }); + it('should save/restore esql tab dataview/timerange/filter/query/columns when timeline is opened via url', () => { + const timelineSuffix = Date.now(); + const timelineName = `DataView timeline-${timelineSuffix}`; + const column1 = 'event.category'; + const column2 = 'ecs.version'; + addDiscoverEsqlQuery(esqlQuery); + addFieldToTable(column1); + addFieldToTable(column2); - describe('Discover saved search state for ESQL tab', () => { - it('should save esql tab saved search with `Security Solution` tag', () => { - const timelineSuffix = Date.now(); - const timelineName = `SavedObject timeline-${timelineSuffix}`; - addDiscoverEsqlQuery(esqlQuery); - addNameToTimelineAndSave(timelineName); - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - cy.get(LOADING_INDICATOR).should('not.exist'); - openKibanaNavigation(); - navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); - cy.get(LOADING_INDICATOR).should('not.exist'); - goToSavedObjectSettings(); - cy.get(LOADING_INDICATOR).should('not.exist'); - clickSavedObjectTagsFilter(); - cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); - cy.get(BASIC_TABLE_LOADING).should('not.exist'); - cy.get(SAVED_OBJECTS_ROW_TITLES).should( - 'contain.text', - `Saved search for timeline - ${timelineName}` - ); + // create a custom timeline + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_PATCH_REQ}`) + .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) + .then((timelineId) => { + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + // reload the page with the exact url + cy.reload(); + verifyDiscoverEsqlQuery(esqlQuery); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column1)).should('exist'); + cy.get(GET_DISCOVER_DATA_GRID_CELL_HEADER(column2)).should('exist'); + cy.get(GET_LOCAL_DATE_PICKER_START_DATE_POPOVER_BUTTON(DISCOVER_CONTAINER)).should( + 'have.text', + INITIAL_START_DATE + ); + }); + }); + it('should save/restore esql tab ES|QL when saving timeline', () => { + const timelineSuffix = Date.now(); + const timelineName = `ES|QL timeline-${timelineSuffix}`; + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_PATCH_REQ}`) + .its(TIMELINE_RESPONSE_SAVED_OBJECT_ID_PATH) + .then((timelineId) => { + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + // create an empty timeline + createNewTimeline(); + // switch to old timeline + openTimelineFromSettings(); + openTimelineById(timelineId).then(() => { + cy.get(LOADING_INDICATOR).should('not.exist'); + goToEsqlTab(); + cy.get(DISCOVER_DATA_VIEW_SWITCHER.BTN).should('not.exist'); + }); + }); + }); }); - it('should rename the saved search on timeline rename', () => { - const initialTimelineSuffix = Date.now(); - const initialTimelineName = `Timeline-${initialTimelineSuffix}`; - addDiscoverEsqlQuery(esqlQuery); - addNameToTimelineAndSave(initialTimelineName); - cy.get(LOADING_INDICATOR).should('not.exist'); - const timelineSuffix = Date.now(); - const renamedTimelineName = `Rename timeline-${timelineSuffix}`; - addNameToTimelineAndSave(renamedTimelineName); - cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); - openKibanaNavigation(); - navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); - cy.get(LOADING_INDICATOR).should('not.exist'); - goToSavedObjectSettings(); - cy.get(LOADING_INDICATOR).should('not.exist'); - clickSavedObjectTagsFilter(); - cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); - cy.get(BASIC_TABLE_LOADING).should('not.exist'); - cy.get(SAVED_OBJECTS_ROW_TITLES).should( - 'contain.text', - `Saved search for timeline - ${renamedTimelineName}` - ); + describe('Discover saved search state for ESQL tab', () => { + it('should save esql tab saved search with `Security Solution` tag', () => { + const timelineSuffix = Date.now(); + const timelineName = `SavedObject timeline-${timelineSuffix}`; + addDiscoverEsqlQuery(esqlQuery); + addNameToTimelineAndSave(timelineName); + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + cy.get(LOADING_INDICATOR).should('not.exist'); + openKibanaNavigation(); + navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); + cy.get(LOADING_INDICATOR).should('not.exist'); + goToSavedObjectSettings(); + cy.get(LOADING_INDICATOR).should('not.exist'); + clickSavedObjectTagsFilter(); + cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); + cy.get(BASIC_TABLE_LOADING).should('not.exist'); + cy.get(SAVED_OBJECTS_ROW_TITLES).should( + 'contain.text', + `Saved search for timeline - ${timelineName}` + ); + }); + + it('should rename the saved search on timeline rename', () => { + const initialTimelineSuffix = Date.now(); + const initialTimelineName = `Timeline-${initialTimelineSuffix}`; + addDiscoverEsqlQuery(esqlQuery); + addNameToTimelineAndSave(initialTimelineName); + cy.get(LOADING_INDICATOR).should('not.exist'); + const timelineSuffix = Date.now(); + const renamedTimelineName = `Rename timeline-${timelineSuffix}`; + addNameToTimelineAndSave(renamedTimelineName); + cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); + openKibanaNavigation(); + navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); + cy.get(LOADING_INDICATOR).should('not.exist'); + goToSavedObjectSettings(); + cy.get(LOADING_INDICATOR).should('not.exist'); + clickSavedObjectTagsFilter(); + cy.get(GET_SAVED_OBJECTS_TAGS_OPTION('Security_Solution')).trigger('click'); + cy.get(BASIC_TABLE_LOADING).should('not.exist'); + cy.get(SAVED_OBJECTS_ROW_TITLES).should( + 'contain.text', + `Saved search for timeline - ${renamedTimelineName}` + ); + }); }); - }); - // Issue for enabling below tests: https://github.com/elastic/kibana/issues/165913 - context.skip('Advanced Settings', () => { - it('rows per page in saved search should be according to the user selected number of pages', () => {}); - it('rows per page in new search should be according to the value selected in advanced settings', () => {}); - }); -}); + // Issue for enabling below tests: https://github.com/elastic/kibana/issues/165913 + context.skip('Advanced Settings', () => { + it('rows per page in saved search should be according to the user selected number of pages', () => {}); + it('rows per page in new search should be according to the value selected in advanced settings', () => {}); + }); + } +); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts index 788c3611c2982..fa24e3ba901b2 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/esql/esql_assistant.cy.ts @@ -21,156 +21,160 @@ const KQL_QUERY = '_index : "auditbeat-*" and ecs.version : "8.0.0"'; const EQL_QUERY = 'process where process.name == "zsh"'; // Failing: See https://github.com/elastic/kibana/issues/180756 -describe.skip('Basic Assistant tests', { - tags: ['@ess'], - env: { - ftrConfig: { - kbnServerArgs: [ - `--xpack.actions.preconfigured=${JSON.stringify({ - 'preconfigured-openai': { - name: 'preconfigured-openai', - actionTypeId: '.gen-ai', - config: { - apiProvider: 'OpenAI', - apiUrl: 'https://api.openai.com/v1/chat/completions', - defaultModel: 'gpt-4', +describe.skip( + 'Basic Assistant tests', + { + tags: ['@ess'], + env: { + ftrConfig: { + kbnServerArgs: [ + `--xpack.actions.preconfigured=${JSON.stringify({ + 'preconfigured-openai': { + name: 'preconfigured-openai', + actionTypeId: '.gen-ai', + config: { + apiProvider: 'OpenAI', + apiUrl: 'https://api.openai.com/v1/chat/completions', + defaultModel: 'gpt-4', + }, + secrets: { + apiKey: 'superlongapikey', + }, }, - secrets: { - apiKey: 'superlongapikey', - }, - }, - })}`, - ], + })}`, + ], + }, }, }, -}, () => { - before(() => { - login(); - visitWithTimeRange(ALERTS_URL); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get( - '[data-test-subj="conversation-selector"] [data-test-subj="comboBoxSearchInput"]' - ).should('not.be.disabled'); - cy.get('[data-test-subj="prompt-textarea"]').then(($el) => { - if ($el.is(':disabled')) { - cy.get('[data-test-subj="connectorMissingCallout"]').find('button').click(); - cy.get('[data-test-subj="connector-selector"]').click(); - cy.get('[data-test-subj="preconfigured-openai"]').click(); - cy.get('[data-test-subj="save-button"]').click(); - } - }); - }); - - describe('ES|QL', () => { - beforeEach(() => { + () => { + before(() => { login(); visitWithTimeRange(ALERTS_URL); cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="conversation-selector"]') - .find('[data-test-subj="comboBoxSearchInput"]') - .type(`New conversation-` + Date.now()); - cy.get('[data-test-subj="prompt-textarea"]').type( - 'Below is an `Elasticsearch Query Language` query:' + - '{shift}{enter}' + - '```esql' + - '{shift}{enter}' + - `${ESQL_QUERY} | limit 1` + - '{shift}{enter}' + - '```' - ); - cy.get('[data-test-subj="submit-chat"]').click(); - visitWithTimeRange(ALERTS_URL); + cy.get( + '[data-test-subj="conversation-selector"] [data-test-subj="comboBoxSearchInput"]' + ).should('not.be.disabled'); + cy.get('[data-test-subj="prompt-textarea"]').then(($el) => { + if ($el.is(':disabled')) { + cy.get('[data-test-subj="connectorMissingCallout"]').find('button').click(); + cy.get('[data-test-subj="connector-selector"]').click(); + cy.get('[data-test-subj="preconfigured-openai"]').click(); + cy.get('[data-test-subj="save-button"]').click(); + } + }); }); - it('should properly propagate esql query to discover when Timeline was not opened before', () => { - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); - updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); - submitDiscoverSearchBar(); - cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); - }); + describe('ES|QL', () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="conversation-selector"]') + .find('[data-test-subj="comboBoxSearchInput"]') + .type(`New conversation-` + Date.now()); + cy.get('[data-test-subj="prompt-textarea"]').type( + 'Below is an `Elasticsearch Query Language` query:' + + '{shift}{enter}' + + '```esql' + + '{shift}{enter}' + + `${ESQL_QUERY} | limit 1` + + '{shift}{enter}' + + '```' + ); + cy.get('[data-test-subj="submit-chat"]').click(); + visitWithTimeRange(ALERTS_URL); + }); - it('should properly propagate esql query to discover when Timeline is active', () => { - openActiveTimeline(); - cy.window().then((win) => { - win.onbeforeunload = null; + it('should properly propagate esql query to discover when Timeline was not opened before', () => { + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); + updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); + submitDiscoverSearchBar(); + cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); }); - goToEsqlTab(); - updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); - submitDiscoverSearchBar(); - cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); - }); - }); - describe('KQL', () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="conversation-selector"]') - .find('[data-test-subj="comboBoxSearchInput"]') - .type(`New conversation-` + Date.now()); + it('should properly propagate esql query to discover when Timeline is active', () => { + openActiveTimeline(); + cy.window().then((win) => { + win.onbeforeunload = null; + }); + goToEsqlTab(); + updateDateRangeInLocalDatePickers(DISCOVER_CONTAINER, INITIAL_START_DATE, INITIAL_END_DATE); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="kibanaCodeEditor"]', `${ESQL_QUERY} | limit 1`); + submitDiscoverSearchBar(); + cy.get(DISCOVER_RESULT_HITS).should('have.text', 1); + }); }); - it('should properly propagate KQL query', () => { - cy.get('[data-test-subj="prompt-textarea"]').type( - 'Below is an `Elasticsearch Query Language` query:' + - '{shift}{enter}' + - '```kql' + - '{shift}{enter}' + - `${KQL_QUERY}` + - '{shift}{enter}' + - '```' - ); - cy.get('[data-test-subj="submit-chat"]').click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="timelineQueryInput"]', KQL_QUERY); - cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); - cy.get('[data-test-subj="server-side-event-count"]') - .filter(':visible') - .should('have.text', 1); - }); - }); + describe('KQL', () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="conversation-selector"]') + .find('[data-test-subj="comboBoxSearchInput"]') + .type(`New conversation-` + Date.now()); + }); - describe('EQL', () => { - beforeEach(() => { - login(); - visitWithTimeRange(ALERTS_URL); - cy.get(AI_ASSISTANT_BUTTON).click(); - cy.get('[data-test-subj="conversation-selector"]') - .find('[data-test-subj="comboBoxSearchInput"]') - .type(`New conversation-` + Date.now()); + it('should properly propagate KQL query', () => { + cy.get('[data-test-subj="prompt-textarea"]').type( + 'Below is an `Elasticsearch Query Language` query:' + + '{shift}{enter}' + + '```kql' + + '{shift}{enter}' + + `${KQL_QUERY}` + + '{shift}{enter}' + + '```' + ); + cy.get('[data-test-subj="submit-chat"]').click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="timelineQueryInput"]', KQL_QUERY); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); + cy.get('[data-test-subj="server-side-event-count"]') + .filter(':visible') + .should('have.text', 1); + }); }); - it('should properly propagate EQL query', () => { - cy.get('[data-test-subj="prompt-textarea"]').type( - 'Below is an `Elasticsearch Query Language` query:' + - '{shift}{enter}' + - '```eql' + - '{shift}{enter}' + - `${EQL_QUERY}` + - '{shift}{enter}' + - '```' - ); - cy.get('[data-test-subj="submit-chat"]').click(); - cy.get('[data-test-subj="messageText"]') - .find('button[aria-label="Investigate in timeline"]') - .click(); - cy.contains('[data-test-subj="eqlQueryBarTextInput"]', `${EQL_QUERY}`); - cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); - cy.get('[data-test-subj="server-side-event-count"]') - .filter(':visible') - .should('have.text', 1); + describe('EQL', () => { + beforeEach(() => { + login(); + visitWithTimeRange(ALERTS_URL); + cy.get(AI_ASSISTANT_BUTTON).click(); + cy.get('[data-test-subj="conversation-selector"]') + .find('[data-test-subj="comboBoxSearchInput"]') + .type(`New conversation-` + Date.now()); + }); + + it('should properly propagate EQL query', () => { + cy.get('[data-test-subj="prompt-textarea"]').type( + 'Below is an `Elasticsearch Query Language` query:' + + '{shift}{enter}' + + '```eql' + + '{shift}{enter}' + + `${EQL_QUERY}` + + '{shift}{enter}' + + '```' + ); + cy.get('[data-test-subj="submit-chat"]').click(); + cy.get('[data-test-subj="messageText"]') + .find('button[aria-label="Investigate in timeline"]') + .click(); + cy.contains('[data-test-subj="eqlQueryBarTextInput"]', `${EQL_QUERY}`); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').filter(':visible').click(); + cy.get('[data-test-subj="server-side-event-count"]') + .filter(':visible') + .should('have.text', 1); + }); }); - }); -}); + } +); From f1abe4f7eb12251ee926bc22de0807c98a2ca82d Mon Sep 17 00:00:00 2001 From: Cristina Amico Date: Mon, 15 Apr 2024 12:05:27 +0200 Subject: [PATCH 5/5] [Fleet] Expose agent logging level in agent policy settings (#180607) Closes https://github.com/elastic/kibana/issues/158861 ## Summary Expose agent logging level in agent policy settings. The new setting is added via the new settings framework and will show up under "advanced settings". It's currently hidden until the agent supports it. ### Testing Enable the settings config: https://github.com/elastic/kibana/pull/180597#discussion_r1562448034 - Go to the agent policy settings form - Under advanced settings there is a new dropdown "Agent logging level". Choose a value and save the policy - The new value should be retained after saving - Go to the agent policies tab and select action "View policy" - The new field should be visible under `agent.logging.level`
Screenshots ![Screenshot 2024-04-12 at 16 21 46](https://github.com/elastic/kibana/assets/16084106/b3083bb5-703a-44c6-a00d-da9d64a2b083) ![Screenshot 2024-04-12 at 16 21 52](https://github.com/elastic/kibana/assets/16084106/bd934262-86f0-4b11-b7b4-d4be72f00715) ![Screenshot 2024-04-12 at 16 22 28](https://github.com/elastic/kibana/assets/16084106/4a352c82-f274-4779-9718-85135f84b0c8) ![Screenshot 2024-04-12 at 16 27 48](https://github.com/elastic/kibana/assets/16084106/11e20051-f91b-44c1-b795-76ef6804cf78)
### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../fleet/common/constants/agent_policy.ts | 16 +++++++++++++ .../common/settings/agent_policy_settings.ts | 19 +++++++++++++++ .../fleet/components/form_settings/index.tsx | 23 ++++++++++++++++++- .../agent_policy_advanced_fields/index.tsx | 3 --- .../components/agent_policy_create_inline.tsx | 1 - .../components/agent_policy_form.tsx | 2 -- .../components/agent_policy_integration.tsx | 5 ---- .../components/agent_logs/constants.tsx | 9 -------- .../agent_logs/filter_log_level.tsx | 2 +- .../agent_logs/select_log_level.tsx | 2 +- .../agent_policies/full_agent_policy.test.ts | 2 ++ 11 files changed, 61 insertions(+), 23 deletions(-) diff --git a/x-pack/plugins/fleet/common/constants/agent_policy.ts b/x-pack/plugins/fleet/common/constants/agent_policy.ts index a52a0cdc7bfcb..b2cbed6bb68e9 100644 --- a/x-pack/plugins/fleet/common/constants/agent_policy.ts +++ b/x-pack/plugins/fleet/common/constants/agent_policy.ts @@ -37,3 +37,19 @@ export const LICENSE_FOR_SCHEDULE_UPGRADE = 'platinum'; export const DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT = 750; export const AGENTLESS_POLICY_ID = 'agentless'; // the policy id defined here: https://github.com/elastic/project-controller/blob/main/internal/project/security/security_kibana_config.go#L86 + +export const AGENT_LOG_LEVELS = { + ERROR: 'error', + WARNING: 'warning', + INFO: 'info', + DEBUG: 'debug', +}; + +export const DEFAULT_LOG_LEVEL = AGENT_LOG_LEVELS.INFO; + +export const agentLoggingLevels = { + Info: 'info', + Debug: 'debug', + Warning: 'warning', + Error: 'error', +} as const; diff --git a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts index ac5c57f9107c5..9d23f948da3e6 100644 --- a/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts +++ b/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts @@ -8,6 +8,8 @@ import { i18n } from '@kbn/i18n'; import { z } from 'zod'; +import { agentLoggingLevels } from '../constants'; + import type { SettingsConfig } from './types'; export const zodStringWithDurationValidation = z @@ -126,4 +128,21 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [ }) .default({}), }, + { + name: 'agent.logging.level', + hidden: true, + title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle', { + defaultMessage: 'Agent Logging Level', + }), + description: i18n.translate( + 'xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelDescription', + { + defaultMessage: 'Set the Agent log level. The default log level is "info".', + } + ), + api_field: { + name: 'agent_logging_level', + }, + schema: z.nativeEnum(agentLoggingLevels), + }, ]; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx index 2836f1a2c8c38..ce725773a462f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/form_settings/index.tsx @@ -7,7 +7,7 @@ import { ZodFirstPartyTypeKind } from 'zod'; import React from 'react'; -import { EuiFieldNumber, EuiFieldText } from '@elastic/eui'; +import { EuiFieldNumber, EuiFieldText, EuiSelect } from '@elastic/eui'; import type { SettingsConfig } from '../../../../../common/settings/types'; @@ -61,6 +61,27 @@ settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodString, (settingsConfig) = ); }); +settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodNativeEnum, (settingsConfig) => { + return ( + ( + ({ + text: level, + value: coercedSchema.enum[level], + }))} + /> + )} + /> + ); +}); + export function ConfiguredSettings({ configuredSettings, }: { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx index 02795f8005bf5..08049f6d81669 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields/index.tsx @@ -63,7 +63,6 @@ interface Props { agentPolicy: Partial; updateAgentPolicy: (u: Partial) => void; validation: ValidationResults; - isEditing?: boolean; disabled?: boolean; } @@ -71,7 +70,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = agentPolicy, updateAgentPolicy, validation, - isEditing = false, disabled = false, }) => { const { docLinks } = useStartServices(); @@ -401,7 +399,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent = }} /> - {AgentTamperProtectionSection} = ({ agentPolicy={newAgentPolicy} updateAgentPolicy={updateNewAgentPolicy} validation={validation} - isEditing={false} /> diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx index 8a0d92b159207..97fc1fc28acf9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx @@ -141,7 +141,6 @@ export const AgentPolicyForm: React.FunctionComponent = ({ agentPolicy={agentPolicy} updateAgentPolicy={updateAgentPolicy} validation={validation} - isEditing={isEditing} /> {advancedPolicySettings ? ( @@ -168,7 +167,6 @@ export const AgentPolicyForm: React.FunctionComponent = ({ agentPolicy={agentPolicy} updateAgentPolicy={updateAgentPolicy} validation={validation} - isEditing={isEditing} disabled={disabled} /> {advancedPolicySettings ? ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx index 759c85b54a181..5de23cd555198 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_integration.tsx @@ -35,8 +35,6 @@ interface Props { withSysMonitoring: boolean; updateSysMonitoring: (newValue: boolean) => void; validation: ValidationResults; - isEditing?: boolean; - onDelete?: () => void; } export const AgentPolicyIntegrationForm: React.FunctionComponent = ({ @@ -45,8 +43,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent = ({ withSysMonitoring, updateSysMonitoring, validation, - isEditing = false, - onDelete = () => {}, }) => { return ( @@ -101,7 +97,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent = ({ agentPolicy={agentPolicy} updateAgentPolicy={updateAgentPolicy} validation={validation} - isEditing={isEditing} /> diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx index bee26f7c5b067..c15c722f7aa4b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/constants.tsx @@ -48,12 +48,3 @@ export const DEFAULT_LOGS_STATE: AgentLogsState = { export const STATE_STORAGE_KEY = '_q'; export const STATE_DATASET_FIELD = 'datasets'; - -export const AGENT_LOG_LEVELS = { - ERROR: 'error', - WARNING: 'warning', - INFO: 'info', - DEBUG: 'debug', -}; - -export const DEFAULT_LOG_LEVEL = AGENT_LOG_LEVELS.INFO; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx index b4971ec4b2209..e565ddccc4b70 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx @@ -10,7 +10,7 @@ import type { EuiSelectableOption } from '@elastic/eui'; import { EuiPopover, EuiFilterButton, EuiSelectable } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AGENT_LOG_LEVELS } from './constants'; +import { AGENT_LOG_LEVELS } from '../../../../../../../../common/constants'; const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx index c442925960977..4c32952339347 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx @@ -13,7 +13,7 @@ import { EuiSelect, EuiFormLabel, EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } fr import type { Agent } from '../../../../../types'; import { sendPostAgentAction, useAuthz, useStartServices } from '../../../../../hooks'; -import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from './constants'; +import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from '../../../../../../../../common/constants'; const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS); diff --git a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts index 3a56bf248bcf4..c85a211fb49a8 100644 --- a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts @@ -719,6 +719,7 @@ describe('getFullAgentPolicy', () => { mockAgentPolicy({ advanced_settings: { agent_limits_go_max_procs: 2, + agent_logging_level: 'debug', }, }); const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy'); @@ -727,6 +728,7 @@ describe('getFullAgentPolicy', () => { id: 'agent-policy', agent: { limits: { go_max_procs: 2 }, + logging: { level: 'debug' }, }, }); });