diff --git a/.buildkite/ftr_security_serverless_configs.yml b/.buildkite/ftr_security_serverless_configs.yml index 69d4801292cf7..920ecce349356 100644 --- a/.buildkite/ftr_security_serverless_configs.yml +++ b/.buildkite/ftr_security_serverless_configs.yml @@ -19,6 +19,9 @@ disabled: - x-pack/test_serverless/functional/config.base.ts - x-pack/test_serverless/shared/config.base.ts + # MKI only configs files + - x-pack/test_serverless/functional/test_suites/security/config.mki_only.ts + defaultQueue: 'n2-4-spot' enabled: - x-pack/test_serverless/api_integration/test_suites/security/config.ts @@ -32,7 +35,6 @@ enabled: - x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.basic.ts - x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.essentials.ts - x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless.ts - - x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless_api.ts - x-pack/test_serverless/functional/test_suites/security/config.saved_objects_management.ts - x-pack/test_serverless/functional/test_suites/security/config.context_awareness.ts - x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 11b02e536f6d4..9b2b440b28f34 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2102,7 +2102,9 @@ x-pack/test/api_integration/apis/management/index_management/inference_endpoints /x-pack/test/api_integration/services/security_solution_*.gen.ts @elastic/security-solution /x-pack/test/accessibility/apps/group3/security_solution.ts @elastic/security-solution /x-pack/test_serverless/functional/test_suites/security/config.ts @elastic/security-solution @elastic/appex-qa -/x-pack/test_serverless/functional/test_suites/security/config.feature_flags.ts @elastic/security-solution +x-pack/test_serverless/functional/test_suites/security/config.mki_only.ts @elastic/security-solution @elastic/appex-qa +x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts @elastic/security-solution @elastic/appex-qa @elastic/kibana-cloud-security-posture +/x-pack/test_serverless/functional/test_suites/security/config.feature_flags.ts @elastic/security-solution @elastic/kibana-cloud-security-posture /x-pack/test_serverless/api_integration/test_suites/observability/config.feature_flags.ts @elastic/security-solution /x-pack/test_serverless/functional/test_suites/common/spaces/multiple_spaces_enabled.ts @elastic/security-solution /x-pack/test/functional/es_archives/endpoint/ @elastic/security-solution diff --git a/renovate.json b/renovate.json index 2512721d9db33..c9ccd3969e3d6 100644 --- a/renovate.json +++ b/renovate.json @@ -375,6 +375,29 @@ "enabled": true, "minimumReleaseAge": "7 days" }, + { + "groupName": "@elastic/kibana-data-discovery dependencies", + "matchDepNames": [ + "@elastic/datemath", + "diff", + "fastest-levenshtein", + "usng.js", + "@types/diff" + ], + "reviewers": [ + "team:kibana-data-discovery" + ], + "matchBaseBranches": [ + "main" + ], + "labels": [ + "Team:DataDiscovery", + "release_note:skip", + "backport:all-open" + ], + "enabled": true, + "minimumReleaseAge": "7 days" + }, { "groupName": "@elastic/kibana-visualizations test dependencies", "matchDepNames": [ diff --git a/test/functional/apps/discover/group6/_sidebar.ts b/test/functional/apps/discover/group6/_sidebar.ts index a88623bb58d12..01adcb7a0a907 100644 --- a/test/functional/apps/discover/group6/_sidebar.ts +++ b/test/functional/apps/discover/group6/_sidebar.ts @@ -28,10 +28,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const fieldEditor = getService('fieldEditor'); const dataViews = getService('dataViews'); + const queryBar = getService('queryBar'); const retry = getService('retry'); const dataGrid = getService('dataGrid'); + const log = getService('log'); const INITIAL_FIELD_LIST_SUMMARY = '48 available fields. 5 empty fields. 4 meta fields.'; + const expectFieldListDescription = async (expectedNumber: string) => { + return await retry.try(async () => { + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + const ariaDescription = await unifiedFieldList.getSidebarAriaDescription(); + if (ariaDescription !== expectedNumber) { + log.warning( + `Expected Sidebar Aria Description: ${expectedNumber}, got: ${ariaDescription}` + ); + await queryBar.submitQuery(); + } + expect(ariaDescription).to.be(expectedNumber); + }); + }; + describe('discover sidebar', function describeIndexTests() { before(async function () { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); @@ -65,35 +82,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await unifiedFieldList.waitUntilSidebarHasLoaded(); await unifiedFieldList.openSidebarFieldFilter(); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await testSubjects.click('typeFilter-keyword'); - - await retry.waitFor('first updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '6 available fields. 1 empty field. 3 meta fields.' - ); - }); + // first update + await expectFieldListDescription('6 available fields. 1 empty field. 3 meta fields.'); await testSubjects.click('typeFilter-number'); - await retry.waitFor('second updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '10 available fields. 3 empty fields. 4 meta fields.' - ); - }); + // second update + await expectFieldListDescription('10 available fields. 3 empty fields. 4 meta fields.'); await testSubjects.click('fieldListFiltersFieldTypeFilterClearAll'); - await retry.waitFor('reset', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === INITIAL_FIELD_LIST_SUMMARY - ); - }); + // reset + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); it('should show filters by type in ES|QL view', async function () { @@ -114,18 +117,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { options = await find.allByCssSelector('[data-test-subj*="typeFilter"]'); expect(options).to.have.length(6); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '76 available fields. 6 empty fields.' - ); - + await expectFieldListDescription('76 available fields. 6 empty fields.'); await testSubjects.click('typeFilter-number'); - - await retry.waitFor('updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 2 empty fields.' - ); - }); + await expectFieldListDescription('4 available fields. 2 empty fields.'); }); it('should show empty fields in ES|QL view', async function () { @@ -138,52 +132,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await header.waitUntilLoadingHasFinished(); await unifiedFieldList.waitUntilSidebarHasLoaded(); await unifiedFieldList.openSidebarFieldFilter(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '2 selected fields. 1 available field. 1 empty field.' - ); + await expectFieldListDescription('2 selected fields. 1 available field. 1 empty field.'); }); }); describe('search', function () { beforeEach(async () => { - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); afterEach(async () => { const fieldSearch = await testSubjects.find('clearSearchButton'); await fieldSearch.click(); - await retry.waitFor('reset', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === INITIAL_FIELD_LIST_SUMMARY - ); - }); + // reset + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); it('should be able to search by string', async function () { await unifiedFieldList.findFieldByName('i'); - await retry.waitFor('first updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '28 available fields. 2 empty fields. 3 meta fields.' - ); - }); - + await expectFieldListDescription('28 available fields. 2 empty fields. 3 meta fields.'); await unifiedFieldList.findFieldByName('p'); - - await retry.waitFor('second updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('4 available fields. 0 meta fields.'); expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( 'clientip, ip, relatedContent.og:description, relatedContent.twitter:description' @@ -192,13 +163,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to search by wildcard', async function () { await unifiedFieldList.findFieldByName('relatedContent*image'); - - await retry.waitFor('updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '2 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('2 available fields. 0 meta fields.'); expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( 'relatedContent.og:image, relatedContent.twitter:image' @@ -208,12 +173,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to search with spaces as wildcard', async function () { await unifiedFieldList.findFieldByName('relatedContent image'); - await retry.waitFor('updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('4 available fields. 0 meta fields.'); expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( 'relatedContent.og:image, relatedContent.og:image:height, relatedContent.og:image:width, relatedContent.twitter:image' @@ -222,13 +182,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to search with fuzzy search (1 typo)', async function () { await unifiedFieldList.findFieldByName('rel4tedContent.art'); - - await retry.waitFor('updates', async () => { - return ( - (await unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('4 available fields. 0 meta fields.'); expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( 'relatedContent.article:modified_time, relatedContent.article:published_time, relatedContent.article:section, relatedContent.article:tag' @@ -243,9 +197,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // expect no changes in the list - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); }); @@ -345,10 +297,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect((await unifiedFieldList.getSidebarSectionFieldNames('meta')).join(', ')).to.be( '_id, _ignored, _index, _score' ); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); it('should show field list groups excluding subfields when searched from source', async function () { @@ -387,7 +336,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'relatedContent' ); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '48 available fields. 1 unmapped field. 5 empty fields. 4 meta fields.' ); }); @@ -406,7 +355,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(availableFields.includes('extension')).to.be(true); expect(availableFields.includes('@message')).to.be(true); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '2 selected fields. 2 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); @@ -426,52 +375,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '@message, _id, extension' ); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); // verify popular fields were persisted await browser.refresh(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); }); it('should show selected and available fields in ES|QL mode', async function () { - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10000'); await testSubjects.click('querySubmitButton'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '76 available fields. 6 empty fields.' - ); + await expectFieldListDescription('76 available fields. 6 empty fields.'); await unifiedFieldList.clickFieldListItemRemove('extension'); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '76 available fields. 6 empty fields.' - ); + await expectFieldListDescription('76 available fields. 6 empty fields.'); const testQuery = `from logstash-* | limit 10 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '2 selected fields. 2 available fields.' - ); + await expectFieldListDescription('2 selected fields. 2 available fields.'); expect((await unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ')).to.be( 'countB, geo.dest' ); @@ -480,12 +412,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await unifiedSearch.switchDataView('discover-dataView-switch-link', 'logstash-*'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '48 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('48 available fields. 5 empty fields. 4 meta fields.'); }); it('should work correctly for a data view for a missing index', async function () { @@ -494,20 +421,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' ); await browser.refresh(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('with-timefield'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '0 available fields. 0 meta fields.' - ); + await expectFieldListDescription('0 available fields. 0 meta fields.'); await testSubjects.missingOrFail( `${unifiedFieldList.getSidebarSectionSelector('available')}-fetchWarning` ); @@ -517,12 +435,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataViews.switchToAndValidate('logstash-*'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' ); @@ -537,41 +450,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('without-timefield'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '6 available fields. 4 meta fields.' - ); + await expectFieldListDescription('6 available fields. 4 meta fields.'); await dataViews.switchToAndValidate('with-timefield'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '0 available fields. 7 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('0 available fields. 7 empty fields. 4 meta fields.'); await testSubjects.existOrFail( `${unifiedFieldList.getSidebarSectionSelector('available')}NoFieldsCallout-noFieldsMatch` ); await dataViews.switchToAndValidate('logstash-*'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' @@ -583,11 +477,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should work when filters change', async () => { - await header.waitUntilLoadingHasFinished(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be( @@ -595,12 +485,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'jpg' }); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); // check that the filter was passed down to the sidebar await unifiedFieldList.clickFieldListItem('extension'); @@ -614,29 +500,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('indices-stats*'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '6873 available fields. 4 meta fields.' - ); + await expectFieldListDescription('6873 available fields. 4 meta fields.'); await dataViews.switchToAndValidate('logstash-*'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/many_fields_data_view' @@ -650,12 +522,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: true, }); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await discover.addRuntimeField( '_bytes-runtimefield', @@ -666,12 +534,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return !(await testSubjects.exists('fieldEditor')); }); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '49 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('49 available fields. 5 empty fields. 4 meta fields.'); let allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield')).to.be(true); @@ -685,23 +548,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return !(await testSubjects.exists('fieldEditor')); }); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '49 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('49 available fields. 5 empty fields. 4 meta fields.'); allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield2')).to.be(true); expect(allFields.includes('_bytes-runtimefield')).to.be(false); await discover.removeField('_bytes-runtimefield'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield2')).to.be(false); @@ -709,11 +562,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render even when retrieving documents failed with an error', async () => { - await header.waitUntilLoadingHasFinished(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await discover.addRuntimeField('_invalid-runtimefield', `emit(‘’);`); @@ -725,9 +574,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await unifiedFieldList.waitUntilSidebarHasLoaded(); // check that the sidebar is rendered - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '49 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('49 available fields. 5 empty fields. 4 meta fields.'); let allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_invalid-runtimefield')).to.be(true); @@ -754,20 +601,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('with-timefield'); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '0 available fields. 7 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('0 available fields. 7 empty fields. 4 meta fields.'); await testSubjects.existOrFail( `${unifiedFieldList.getSidebarSectionSelector('available')}NoFieldsCallout-noFieldsMatch` ); @@ -777,12 +615,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Sep 23, 2019 @ 00:00:00.000' ); - await header.waitUntilLoadingHasFinished(); - await unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( - '7 available fields. 4 meta fields.' - ); + await expectFieldListDescription('7 available fields. 4 meta fields.'); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/group6/_sidebar.ts b/x-pack/test_serverless/functional/test_suites/common/discover/group6/_sidebar.ts index 61cd9728223d1..e7be4ab2859f5 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/group6/_sidebar.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/group6/_sidebar.ts @@ -27,12 +27,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); + const queryBar = getService('queryBar'); + const log = getService('log'); const INITIAL_FIELD_LIST_SUMMARY = '48 available fields. 5 empty fields. 4 meta fields.'; - describe('discover sidebar', function describeIndexTests() { - // see details: https://github.com/elastic/kibana/issues/195100 - this.tags(['failsOnMKI']); + const expectFieldListDescription = async (expectedNumber: string) => { + return await retry.try(async () => { + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + const ariaDescription = await PageObjects.unifiedFieldList.getSidebarAriaDescription(); + if (ariaDescription !== expectedNumber) { + log.warning( + `Expected Sidebar Aria Description: ${expectedNumber}, got: ${ariaDescription}` + ); + await queryBar.submitQuery(); + } + expect(ariaDescription).to.be(expectedNumber); + }); + }; + describe('discover sidebar', function describeIndexTests() { before(async function () { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await PageObjects.svlCommonPage.loginAsAdmin(); @@ -66,36 +80,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); await PageObjects.unifiedFieldList.openSidebarFieldFilter(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await testSubjects.click('typeFilter-keyword'); - - await retry.waitFor('first updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '6 available fields. 1 empty field. 3 meta fields.' - ); - }); + // first update + await expectFieldListDescription('6 available fields. 1 empty field. 3 meta fields.'); await testSubjects.click('typeFilter-number'); - await retry.waitFor('second updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '10 available fields. 3 empty fields. 4 meta fields.' - ); - }); + // second update + await expectFieldListDescription('10 available fields. 3 empty fields. 4 meta fields.'); await testSubjects.click('fieldListFiltersFieldTypeFilterClearAll'); - await retry.waitFor('reset', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - INITIAL_FIELD_LIST_SUMMARY - ); - }); + // reset + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); // TODO: ES|QL tests removed since ES|QL isn't supported in Serverless @@ -103,44 +102,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('search', function () { beforeEach(async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); afterEach(async () => { const fieldSearch = await testSubjects.find('clearSearchButton'); await fieldSearch.click(); - await retry.waitFor('reset', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - INITIAL_FIELD_LIST_SUMMARY - ); - }); + // reset + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); it('should be able to search by string', async function () { await PageObjects.unifiedFieldList.findFieldByName('i'); - await retry.waitFor('first updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '28 available fields. 2 empty fields. 3 meta fields.' - ); - }); - + await expectFieldListDescription('28 available fields. 2 empty fields. 3 meta fields.'); await PageObjects.unifiedFieldList.findFieldByName('p'); - - await retry.waitFor('second updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('4 available fields. 0 meta fields.'); expect( (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') @@ -149,13 +127,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to search by wildcard', async function () { await PageObjects.unifiedFieldList.findFieldByName('relatedContent*image'); - - await retry.waitFor('updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '2 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('2 available fields. 0 meta fields.'); expect( (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') @@ -165,12 +137,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to search with spaces as wildcard', async function () { await PageObjects.unifiedFieldList.findFieldByName('relatedContent image'); - await retry.waitFor('updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('4 available fields. 0 meta fields.'); expect( (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') @@ -181,13 +148,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to search with fuzzy search (1 typo)', async function () { await PageObjects.unifiedFieldList.findFieldByName('rel4tedContent.art'); - - await retry.waitFor('updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '4 available fields. 0 meta fields.' - ); - }); + await expectFieldListDescription('4 available fields. 0 meta fields.'); expect( (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') @@ -204,9 +165,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // expect no changes in the list - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); }); @@ -311,9 +270,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('meta')).join(', ') ).to.be('_id, _ignored, _index, _score'); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); }); it('should show field list groups excluding subfields when searched from source', async function () { @@ -354,7 +311,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('unmapped')).join(', ') ).to.be('relatedContent'); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '48 available fields. 1 unmapped field. 5 empty fields. 4 meta fields.' ); }); @@ -375,7 +332,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(availableFields.includes('extension')).to.be(true); expect(availableFields.includes('@message')).to.be(true); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '2 selected fields. 2 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); @@ -395,7 +352,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('popular')).join(', ') ).to.be('@message, _id, extension'); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + await expectFieldListDescription( '3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); }); @@ -408,20 +365,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' ); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); - + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '0 available fields. 0 meta fields.' - ); + await expectFieldListDescription('0 available fields. 0 meta fields.'); await testSubjects.missingOrFail( `${PageObjects.unifiedFieldList.getSidebarSectionSelector('available')}-fetchWarning` ); @@ -433,12 +380,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' ); @@ -453,29 +395,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('without-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '6 available fields. 4 meta fields.' - ); + await expectFieldListDescription('6 available fields. 4 meta fields.'); await dataViews.switchToAndValidate('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await expectFieldListDescription('0 available fields. 7 empty fields. 4 meta fields.'); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '0 available fields. 7 empty fields. 4 meta fields.' - ); await testSubjects.existOrFail( `${PageObjects.unifiedFieldList.getSidebarSectionSelector( 'available' @@ -484,12 +413,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' @@ -501,11 +425,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should work when filters change', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await PageObjects.unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be( @@ -516,9 +436,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); // check that the filter was passed down to the sidebar await PageObjects.unifiedFieldList.clickFieldListItem('extension'); @@ -530,31 +448,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/many_fields_data_view' ); - + await dataViews.switchToAndValidate('logstash-*'); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('indices-stats*'); - - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '6873 available fields. 4 meta fields.' - ); + await expectFieldListDescription('6873 available fields. 4 meta fields.'); await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/many_fields_data_view' @@ -569,12 +472,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await PageObjects.discover.addRuntimeField( '_bytes-runtimefield', @@ -585,12 +483,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return !(await testSubjects.exists('fieldEditor')); }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '49 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('49 available fields. 5 empty fields. 4 meta fields.'); let allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield')).to.be(true); @@ -604,23 +497,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return !(await testSubjects.exists('fieldEditor')); }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '49 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('49 available fields. 5 empty fields. 4 meta fields.'); allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield2')).to.be(true); expect(allFields.includes('_bytes-runtimefield')).to.be(false); await PageObjects.discover.removeField('_bytes-runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield2')).to.be(false); @@ -628,11 +511,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render even when retrieving documents failed with an error', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await PageObjects.discover.addRuntimeField('_invalid-runtimefield', `emit(‘’);`); @@ -641,12 +520,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // error in fetching documents because of the invalid runtime field await PageObjects.discover.showsErrorCallout(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - // check that the sidebar is rendered - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '49 available fields. 5 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('49 available fields. 5 empty fields. 4 meta fields.'); + let allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_invalid-runtimefield')).to.be(true); @@ -671,22 +547,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' ); - await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - INITIAL_FIELD_LIST_SUMMARY - ); + await expectFieldListDescription(INITIAL_FIELD_LIST_SUMMARY); await dataViews.switchToAndValidate('with-timefield'); - - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '0 available fields. 7 empty fields. 4 meta fields.' - ); + await expectFieldListDescription('0 available fields. 7 empty fields. 4 meta fields.'); await testSubjects.existOrFail( `${PageObjects.unifiedFieldList.getSidebarSectionSelector( 'available' @@ -698,12 +563,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Sep 23, 2019 @ 00:00:00.000' ); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '7 available fields. 4 meta fields.' - ); + await expectFieldListDescription('7 available fields. 4 meta fields.'); await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' diff --git a/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless.ts b/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless.ts index 692ae096265fb..b203bc6427ed2 100644 --- a/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless.ts +++ b/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless.ts @@ -16,6 +16,8 @@ export default createTestConfig({ reportName: 'Serverless Security Cloud Security Agentless Onboarding Functional Tests', }, kbnServerArgs: [ + `--xpack.cloud.serverless.project_id=some_fake_project_id`, + `--xpack.fleet.packages.0.name=cloud_security_posture`, `--xpack.fleet.packages.0.version=${CLOUD_CREDENTIALS_PACKAGE_VERSION}`, `--xpack.fleet.agentless.enabled=true`, @@ -26,11 +28,10 @@ export default createTestConfig({ `--xpack.fleet.agentPolicies.0.id=agentless`, `--xpack.fleet.agentPolicies.0.name=agentless`, `--xpack.fleet.agentPolicies.0.package_policies=[]`, - `--xpack.cloud.serverless.project_id=some_fake_project_id`, `--xpack.fleet.agentPolicies.0.is_default=true`, `--xpack.fleet.agentPolicies.0.is_default_fleet_server=true`, - // Serverless Agentless API + `--xpack.fleet.agentless.enabled=true`, `--xpack.fleet.agentless.api.url=http://localhost:8089`, `--xpack.fleet.agentless.api.tls.certificate=${KBN_CERT_PATH}`, `--xpack.fleet.agentless.api.tls.key=${KBN_KEY_PATH}`, diff --git a/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless_api.ts b/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless_api.ts deleted file mode 100644 index 0f37f224197ef..0000000000000 --- a/x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.agentless_api.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { CLOUD_CREDENTIALS_PACKAGE_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; -import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils'; -import { createTestConfig } from '../../config.base'; - -export default createTestConfig({ - serverlessProject: 'security', - junit: { - reportName: 'Serverless Security Cloud Security Agentless API Onboarding Functional Tests', - }, - kbnServerArgs: [ - `--xpack.fleet.packages.0.name=cloud_security_posture`, - `--xpack.fleet.packages.0.version=${CLOUD_CREDENTIALS_PACKAGE_VERSION}`, - - `--xpack.fleet.agents.fleet_server.hosts=["https://ftr.kibana:8220"]`, - `--xpack.fleet.internal.fleetServerStandalone=true`, - - // Agentless Configuration based on Serverless Security Dev Yaml - config/serverless.security.dev.yml - `--xpack.fleet.agentless.enabled=true`, - `--xpack.fleet.agentless.api.url=http://localhost:8089`, - `--xpack.fleet.agentless.api.tls.certificate=${KBN_CERT_PATH}`, - `--xpack.fleet.agentless.api.tls.key=${KBN_KEY_PATH}`, - `--xpack.fleet.agentless.api.tls.ca=${CA_CERT_PATH}`, - `--xpack.cloud.serverless.project_id=some_fake_project_id`, - ], - // load tests in the index file - testFiles: [require.resolve('./ftr/cloud_security_posture/agentless_api')], -}); diff --git a/x-pack/test_serverless/functional/test_suites/security/config.mki_only.ts b/x-pack/test_serverless/functional/test_suites/security/config.mki_only.ts new file mode 100644 index 0000000000000..36d3bd6c7dd93 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/config.mki_only.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils'; +import { createTestConfig } from '../../config.base'; + +export default createTestConfig({ + serverlessProject: 'security', + testFiles: [require.resolve('./index.mki_only.ts')], + junit: { + reportName: 'Serverless Security MKI Functional Tests', + }, + suiteTags: { exclude: ['skipSvlSec'] }, + + // include settings from project controller + // https://github.com/elastic/project-controller/blob/main/internal/project/security/config/elasticsearch.yml + esServerArgs: ['xpack.ml.nlp.enabled=true'], + kbnServerArgs: [ + '--xpack.dataUsage.enabled=true', + '--xpack.dataUsage.enableExperimental=[]', + // dataUsage.autoops* config is set in kibana controller + '--xpack.dataUsage.autoops.enabled=true', + '--xpack.dataUsage.autoops.api.url=http://localhost:9000', + `--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`, + `--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`, + ], +}); diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_aws.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_aws.ts index e669545d135f9..ea499f96da585 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_aws.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_aws.ts @@ -8,7 +8,7 @@ import { CLOUD_CREDENTIALS_PACKAGE_VERSION } from '@kbn/cloud-security-posture-p import expect from '@kbn/expect'; import * as http from 'http'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; -import { setupMockServer } from '../agentless_api/mock_agentless_api'; +import { setupMockServer } from './mock_agentless_api'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const mockAgentlessApiService = setupMockServer(); const pageObjects = getPageObjects([ diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_gcp.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_gcp.ts index 95f855697c5bd..897a6e589fdb3 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_gcp.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/cis_integration_gcp.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { CLOUD_CREDENTIALS_PACKAGE_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; import * as http from 'http'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; -import { setupMockServer } from '../agentless_api/mock_agentless_api'; +import { setupMockServer } from './mock_agentless_api'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const pageObjects = getPageObjects(['common', 'svlCommonPage', 'cisAddIntegration', 'header']); diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/create_agent.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/create_agent.ts similarity index 73% rename from x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/create_agent.ts rename to x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/create_agent.ts index bf9fd31b9e266..14351439ac68f 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/create_agent.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/create_agent.ts @@ -8,12 +8,9 @@ import { CLOUD_CREDENTIALS_PACKAGE_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; import * as http from 'http'; import expect from '@kbn/expect'; -import equals from 'fast-deep-equal'; import { setupMockServer } from './mock_agentless_api'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const agentCreationTimeout = 1000 * 60 * 1; // 1 minute - const retry = getService('retry'); const mockAgentlessApiService = setupMockServer(); const pageObjects = getPageObjects([ 'svlCommonPage', @@ -28,12 +25,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const AWS_SINGLE_ACCOUNT_TEST_ID = 'awsSingleTestId'; describe('Agentless API Serverless', function () { + this.tags(['skipMKI', 'cloud_security_posture_agentless']); let mockApiServer: http.Server; let cisIntegration: typeof pageObjects.cisAddIntegration; before(async () => { - // If process.env.TEST_CLOUD is set, then the test is running in the Serverless Quality Gates - // and this MSW server will be listening for a request that will never come. mockApiServer = mockAgentlessApiService.listen(8089); // Start the usage api mock server on port 8089 await pageObjects.svlCommonPage.loginAsAdmin(); cisIntegration = pageObjects.cisAddIntegration; @@ -57,22 +53,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await cisIntegration.selectSetupTechnology('agentless'); await cisIntegration.selectAwsCredentials('direct'); - if ( - process.env.TEST_CLOUD && - process.env.CSPM_AWS_ACCOUNT_ID && - process.env.CSPM_AWS_SECRET_KEY - ) { - await cisIntegration.fillInTextField( - cisIntegration.testSubjectIds.DIRECT_ACCESS_KEY_ID_TEST_ID, - process.env.CSPM_AWS_ACCOUNT_ID - ); - - await cisIntegration.fillInTextField( - cisIntegration.testSubjectIds.DIRECT_ACCESS_SECRET_KEY_TEST_ID, - process.env.CSPM_AWS_SECRET_KEY - ); - } - await pageObjects.header.waitUntilLoadingHasFinished(); await cisIntegration.clickSaveButton(); @@ -85,13 +65,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { integrationPolicyName ); - // wait for eventually Pending or Healthy status - // purpose of this retry is to wait for the agent to be created and the status to be updated - // not to wait for the agent to be healthy - await retry.tryForTime(agentCreationTimeout, async () => { - const resStatus = await cisIntegration.getFirstCspmIntegrationPageAgentlessStatus(); - expect(equals(resStatus, 'Healthy') || equals(resStatus, 'Pending')).to.be(true); - }); + const resStatus = await cisIntegration.getFirstCspmIntegrationPageAgentlessStatus(); + // The status can only be Pending because the agentless agent will never be created + expect(resStatus).to.be('Pending'); }); it(`should create default agent-based agent`, async () => { diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/index.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/index.ts index 235757c508c16..875dd630f2ade 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/index.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/index.ts @@ -12,5 +12,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { this.tags(['cloud_security_posture_agentless']); loadTestFile(require.resolve('./cis_integration_aws')); loadTestFile(require.resolve('./cis_integration_gcp')); + loadTestFile(require.resolve('./create_agent')); }); } diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/mock_agentless_api.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/mock_agentless_api.ts similarity index 100% rename from x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/mock_agentless_api.ts rename to x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless/mock_agentless_api.ts diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/README.md b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/README.md new file mode 100644 index 0000000000000..9af4048016c79 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/README.md @@ -0,0 +1,15 @@ +# MKI Serverless Quality Gates + +This folder contains tests that **ONLY** run in the MKI Serverless Quality Gates. These tests are designed to ensure the security and functionality of the system in a serverless environment. + +## Contributing + +Please prefix the tests in this folder with `mki_` so that is clear to the following developer that these tests run only in MKI and Serverless Quality Gates. + +New MKI only test files should be loaded from the root index.ts file of the mki_only directory + +``` +x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/index.ts +``` + +If you would like to contribute to these tests, please follow the contribution guidelines outlined in the main project repository. diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/agentless/mki_create_agent.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/agentless/mki_create_agent.ts new file mode 100644 index 0000000000000..4b357eb8c0f4b --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/agentless/mki_create_agent.ts @@ -0,0 +1,104 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { CLOUD_CREDENTIALS_PACKAGE_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; +import expect from '@kbn/expect'; +import type { FtrProviderContext } from '../../../../../../ftr_provider_context'; +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const testSubjects = getService('testSubjects'); + const pageObjects = getPageObjects([ + 'svlCommonPage', + 'cspSecurity', + 'security', + 'header', + 'cisAddIntegration', + ]); + + const CIS_AWS_OPTION_TEST_ID = 'cisAwsTestId'; + + const AWS_SINGLE_ACCOUNT_TEST_ID = 'awsSingleTestId'; + + // This test suite is only running in the Serverless Quality Gates environment + describe('Agentless API Serverless MKI only', function () { + this.tags(['cloud_security_posture_agentless']); + let cisIntegration: typeof pageObjects.cisAddIntegration; + + before(async () => { + await pageObjects.svlCommonPage.loginAsAdmin(); + cisIntegration = pageObjects.cisAddIntegration; + }); + + it(`should create agentless-agent`, async () => { + const integrationPolicyName = `cloud_security_posture-${new Date().toISOString()}`; + await cisIntegration.navigateToAddIntegrationCspmWithVersionPage( + CLOUD_CREDENTIALS_PACKAGE_VERSION + ); + + await cisIntegration.clickOptionButton(CIS_AWS_OPTION_TEST_ID); + await cisIntegration.clickOptionButton(AWS_SINGLE_ACCOUNT_TEST_ID); + + await cisIntegration.inputIntegrationName(integrationPolicyName); + + await cisIntegration.selectSetupTechnology('agentless'); + await cisIntegration.selectAwsCredentials('direct'); + + await pageObjects.header.waitUntilLoadingHasFinished(); + + if (process.env.CSPM_AWS_ACCOUNT_ID && process.env.CSPM_AWS_SECRET_KEY) { + await cisIntegration.fillInTextField( + cisIntegration.testSubjectIds.DIRECT_ACCESS_KEY_ID_TEST_ID, + process.env.CSPM_AWS_ACCOUNT_ID + ); + + await cisIntegration.fillInTextField( + cisIntegration.testSubjectIds.DIRECT_ACCESS_SECRET_KEY_TEST_ID, + process.env.CSPM_AWS_SECRET_KEY + ); + } + + await cisIntegration.clickSaveButton(); + await pageObjects.header.waitUntilLoadingHasFinished(); + + await cisIntegration.navigateToIntegrationCspList(); + await pageObjects.header.waitUntilLoadingHasFinished(); + + expect(await cisIntegration.getFirstCspmIntegrationPageAgentlessIntegration()).to.be( + integrationPolicyName + ); + + const agentStatusBadge = testSubjects.find('agentlessStatusBadge'); + // The status badge could be either "Pending", "Healthy", or "Unhealthy" so we are just checking that it exists + expect(agentStatusBadge).to.be.ok(); + }); + + it(`should create default agent-based agent`, async () => { + const integrationPolicyName = `cloud_security_posture-${new Date().toISOString()}`; + + await cisIntegration.navigateToAddIntegrationCspmWithVersionPage( + CLOUD_CREDENTIALS_PACKAGE_VERSION + ); + + await cisIntegration.clickOptionButton(CIS_AWS_OPTION_TEST_ID); + await cisIntegration.clickOptionButton(AWS_SINGLE_ACCOUNT_TEST_ID); + + await cisIntegration.inputIntegrationName(integrationPolicyName); + + await cisIntegration.clickSaveButton(); + await pageObjects.header.waitUntilLoadingHasFinished(); + + const agentPolicyName = await cisIntegration.getAgentBasedPolicyValue(); + + await cisIntegration.navigateToIntegrationCspList(); + await pageObjects.header.waitUntilLoadingHasFinished(); + + expect(await cisIntegration.getFirstCspmIntegrationPageIntegration()).to.be( + integrationPolicyName + ); + expect(await cisIntegration.getFirstCspmIntegrationPageAgent()).to.be(agentPolicyName); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/index.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/index.ts similarity index 71% rename from x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/index.ts rename to x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/index.ts index 0aa5f978445f1..a1b5798f831b3 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/agentless_api/index.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/mki_only/index.ts @@ -9,7 +9,9 @@ import { FtrProviderContext } from '../../../../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('cloud_security_posture', function () { - this.tags(['failsOnMKI', 'cloud_security_posture']); - loadTestFile(require.resolve('./create_agent')); + this.tags(['cloud_security_posture']); + + // do not resolve files which are ending with `.essentials.ts` + loadTestFile(require.resolve('./agentless/mki_create_agent')); }); } diff --git a/x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts b/x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts new file mode 100644 index 0000000000000..baff65fb737f6 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('serverless security UI MKI only', function () { + this.tags(['security-mki-only ']); + loadTestFile(require.resolve('./ftr/cloud_security_posture/mki_only')); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/index.ts b/x-pack/test_serverless/functional/test_suites/security/index.ts index 833df2edb78cd..30f35c52295ce 100644 --- a/x-pack/test_serverless/functional/test_suites/security/index.ts +++ b/x-pack/test_serverless/functional/test_suites/security/index.ts @@ -8,8 +8,6 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { - const isCloud = !!process.env.TEST_CLOUD; - describe('serverless security UI', function () { this.tags(['esGate']); @@ -17,9 +15,5 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./ftr/cases')); loadTestFile(require.resolve('./ftr/advanced_settings')); loadTestFile(require.resolve('./ml')); - if (isCloud) { - // only run the agentless API tests in the Serverless Quality Gates - loadTestFile(require.resolve('./ftr/cloud_security_posture/agentless_api')); - } }); }