[ML] Adds serverless functional test for Frozen data tier control and ES|QL data visualizer links (#181193)

## Summary

This PR adds functional test for Frozen data tier control in serverless
(observability and security). It also asserts ES|QL data visualizer
links do not show in serverless projects.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Quynh Nguyen (Quinn) 2024-05-03 11:08:37 -05:00 committed by GitHub
parent 2e9099d31d
commit 72ac7413c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 140 additions and 20 deletions

View file

@ -239,6 +239,7 @@ export const FullTimeRangeSelector: FC<FullTimeRangeSelectorProps> = (props) =>
id={'mlFullTimeRangeSelectorOption'}
button={
<EuiButtonIcon
data-test-subj="mlDatePickerButtonDataTierOptions"
display="base"
size="m"
iconType="boxesVertical"

View file

@ -198,6 +198,7 @@ export const IndexDataVisualizerESQL: FC<IndexDataVisualizerESQLProps> = (dataVi
setLocalQuery(q);
}
}, []);
return (
<EuiPageTemplate
offset={0}

View file

@ -591,23 +591,26 @@ export const useESQLDataVisualizerData = (
[totalCount, overallStatsProgress.loaded, fieldStatsProgress.loaded]
);
const onQueryUpdate = async (q?: AggregateQuery) => {
// When user submits a new query
// resets all current requests and other data
if (cancelOverallStatsRequest) {
cancelOverallStatsRequest();
}
if (cancelFieldStatsRequest) {
cancelFieldStatsRequest();
}
// Reset field stats to fetch state
setFieldStatFieldsToFetch(undefined);
setMetricConfigs(defaults.metricConfigs);
setNonMetricConfigs(defaults.nonMetricConfigs);
if (isESQLQuery(q) && setQuery) {
setQuery(q);
}
};
const onQueryUpdate = useCallback(
async (q?: AggregateQuery) => {
// When user submits a new query
// resets all current requests and other data
if (cancelOverallStatsRequest) {
cancelOverallStatsRequest();
}
if (cancelFieldStatsRequest) {
cancelFieldStatsRequest();
}
// Reset field stats to fetch state
setFieldStatFieldsToFetch(undefined);
setMetricConfigs(defaults.metricConfigs);
setNonMetricConfigs(defaults.nonMetricConfigs);
if (isESQLQuery(q) && setQuery) {
setQuery(q);
}
},
[cancelFieldStatsRequest, cancelOverallStatsRequest, setQuery]
);
return {
totalCount,

View file

@ -455,13 +455,14 @@ export const useESQLOverallStatsData = (
title: fieldStatsErrorTitle,
});
}
setQueryHistoryStatus(false);
// Log error to console for better debugging
// eslint-disable-next-line no-console
console.error(`${fieldStatsErrorTitle}: fetchOverallStats`, error);
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[runRequest, toasts, JSON.stringify({ fieldStatsRequest }), onError]
[JSON.stringify({ fieldStatsRequest })]
);
// auto-update

View file

@ -117,6 +117,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job creation navigates through the categorization wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -280,6 +280,7 @@ export default function ({ getService }: FtrProviderContext) {
it('multi-metric job creation navigates through the multi-metric job wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -114,6 +114,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job creation navigates through the multi metric wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -128,6 +128,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job creation navigates through the population wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -308,6 +308,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job creation navigates through the multi metric wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -122,6 +122,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job creation navigates through the single metric wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -89,6 +89,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job creation navigates through the single metric wizard and sets all needed fields', async () => {
await ml.testExecution.logTestStep('job creation displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
await ml.testExecution.logTestStep('job creation sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(

View file

@ -134,6 +134,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.dataVisualizerIndexBased.clickUseFullDataButton(
testData.expected.totalDocCountFormatted
);
await ml.commonUI.assertDatePickerDataTierOptionsVisible(true);
}
async function checkPageDetails(testData: TestData) {

View file

@ -561,6 +561,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await transform.testExecution.logTestStep('again displays an empty index preview');
await transform.wizard.assertIndexPreviewEmpty();
await transform.datePicker.assertDatePickerDataTierOptionsVisible(true);
await transform.testExecution.logTestStep(
`clicks the 'Use full data' button to auto-select time range`

View file

@ -438,5 +438,14 @@ export function MachineLearningCommonUIProvider({
}
});
},
async assertDatePickerDataTierOptionsVisible(shouldBeVisible: boolean) {
const selector = 'mlDatePickerButtonDataTierOptions';
if (shouldBeVisible === true) {
await testSubjects.existOrFail(selector);
} else {
await testSubjects.missingOrFail(selector);
}
},
};
}

View file

@ -534,6 +534,15 @@ export function MachineLearningJobWizardCommonProvider(
});
},
async assertUseFullDataButtonVisible(shouldBeVisible: boolean) {
const selector = 'mlDatePickerButtonUseFullData';
if (shouldBeVisible === true) {
await testSubjects.existOrFail(selector);
} else {
await testSubjects.missingOrFail(selector);
}
},
async clickUseFullDataButton(expectedStartDate: string, expectedEndDate: string) {
await testSubjects.clickWhenNotDisabledWithoutRetry('mlDatePickerButtonUseFullData');
await this.assertDateRangeSelection(expectedStartDate, expectedEndDate);

View file

@ -49,6 +49,23 @@ export function TransformDatePickerProvider({ getService, getPageObjects }: FtrP
await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
},
async assertUseFullDataButtonVisible(shouldBeVisible: boolean) {
const selector = 'mlDatePickerButtonUseFullData';
if (shouldBeVisible === true) {
await testSubjects.existOrFail(selector);
} else {
await testSubjects.missingOrFail(selector);
}
},
async assertDatePickerDataTierOptionsVisible(shouldBeVisible: boolean) {
const selector = 'mlDatePickerButtonDataTierOptions';
if (shouldBeVisible === true) {
await testSubjects.existOrFail(selector);
} else {
await testSubjects.missingOrFail(selector);
}
},
async clickUseFullDataButton(expectedTimeConfig: { start: string; end: string }) {
await testSubjects.existOrFail('mlDatePickerButtonUseFullData');
await testSubjects.clickWhenNotDisabledWithoutRetry('mlDatePickerButtonUseFullData');

View file

@ -13,17 +13,30 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const browser = getService('browser');
const security = getService('security');
const transform = getService('transform');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
describe('Transform List', function () {
before(async () => {
await security.testUser.setRoles(['transform_user']);
await pageObjects.svlCommonPage.loginAsAdmin();
// Load logstash* data and create dataview for logstash*, logstash-2015.09.22
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/visualize/default'
);
// For this test to work, make sure there are no pre-existing transform present.
// For example, solutions might set up transforms automatically.
await transform.api.cleanTransformIndices();
});
after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.savedObjects.cleanStandardList();
});
it('renders the transform list', async () => {
await transform.testExecution.logTestStep('should load the Transform list page');
await transform.navigation.navigateTo();
@ -39,10 +52,17 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await transform.management.assertNoTransformsFoundMessageExists();
await transform.testExecution.logTestStep(
'should display a disabled "Create first transform" button'
'should display an enabled "Create first transform" button'
);
await transform.management.assertCreateFirstTransformButtonExists();
await transform.management.assertCreateFirstTransformButtonEnabled(true);
});
it('opens transform creation wizard', async () => {
await transform.management.startTransformCreation();
await transform.sourceSelection.selectSource('logstash-2015.09.22');
await transform.datePicker.assertUseFullDataButtonVisible(true);
await transform.datePicker.assertDatePickerDataTierOptionsVisible(false);
});
});
};

View file

@ -12,6 +12,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const svlMl = getService('svlMl');
const PageObjects = getPageObjects(['svlCommonPage']);
const adJobId = 'fq_single_permission';
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
describe('Anomaly detection jobs list', function () {
// Error: Failed to delete all indices with pattern [.ml-*]
@ -19,6 +21,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async () => {
await PageObjects.svlCommonPage.login();
// Load logstash* data and create dataview for logstash*, logstash-2015.09.22
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/visualize/default'
);
await ml.api.createAnomalyDetectionJob(ml.commonConfig.getADFqMultiMetricJobConfig(adJobId));
});
@ -26,6 +34,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.svlCommonPage.forceLogout();
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.savedObjects.cleanStandardList();
});
describe('page navigation', () => {
@ -49,6 +59,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.jobTable.assertJobActionSingleMetricViewerButtonEnabled(adJobId, true);
await ml.jobTable.assertJobActionAnomalyExplorerButtonEnabled(adJobId, true);
});
describe('job creation', () => {
it('does not show exclude frozen data tier control in wizard', async () => {
await ml.testExecution.logTestStep('loads the anomaly detection creation wizard');
await ml.navigation.navigateToMl();
await svlMl.navigation.observability.navigateToAnomalyDetection();
await ml.jobManagement.navigateToNewJobSourceSelection();
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('logstash-2015.09.22');
await ml.jobTypeSelection.selectCategorizationJob();
await ml.testExecution.logTestStep('shows full data button, but not data tier control');
await ml.jobWizardCommon.assertUseFullDataButtonVisible(true);
await ml.commonUI.assertDatePickerDataTierOptionsVisible(false);
});
});
});
});
}

View file

@ -34,6 +34,7 @@ export default function ({ getPageObjects }: FtrProviderContext) {
{ label: 'Machine Learning / Data Visualizer', expected: true },
{ label: 'Machine Learning / File Upload', expected: true },
{ label: 'Machine Learning / Index Data Visualizer', expected: true },
{ label: 'Machine Learning / ES|QL Data Visualizer', expected: true },
{ label: 'Machine Learning / Data Drift', expected: true },
{ label: 'Alerts and Insights / Machine Learning', expected: true },
];

View file

@ -34,6 +34,7 @@ export default function ({ getPageObjects }: FtrProviderContext) {
{ label: 'Machine Learning / Data Visualizer', expected: true },
{ label: 'Machine Learning / File Upload', expected: true },
{ label: 'Machine Learning / Index Data Visualizer', expected: true },
{ label: 'Machine Learning / ES|QL Data Visualizer', expected: true },
{ label: 'Machine Learning / Data Drift', expected: true },
{ label: 'Alerts and Insights / Machine Learning', expected: true },
];

View file

@ -11,13 +11,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const svlMl = getService('svlMl');
const PageObjects = getPageObjects(['svlCommonPage']);
const adJobId = 'fq_single_permission';
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
describe('Anomaly detection jobs list', function () {
// Error: Failed to delete all indices with pattern [.ml-*]
this.tags(['failsOnMKI']);
before(async () => {
await PageObjects.svlCommonPage.login();
// Load logstash* data and create dataview for logstash*, logstash-2015.09.22
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/visualize/default'
);
await ml.api.createAnomalyDetectionJob(ml.commonConfig.getADFqMultiMetricJobConfig(adJobId));
});
@ -25,6 +31,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.svlCommonPage.forceLogout();
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.savedObjects.cleanStandardList();
});
describe('page navigation', () => {
@ -50,5 +58,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.jobTable.assertJobActionAnomalyExplorerButtonEnabled(adJobId, true);
});
});
describe('job creation', () => {
it('does not show exclude frozen data tier control in wizard', async () => {
await ml.testExecution.logTestStep('loads the anomaly detection creation wizard');
await ml.navigation.navigateToMl();
await svlMl.navigation.security.navigateToAnomalyDetection();
await ml.jobManagement.navigateToNewJobSourceSelection();
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('logstash-2015.09.22');
await ml.jobTypeSelection.selectSingleMetricJob();
await ml.testExecution.logTestStep('shows full data button, but not data tier control');
await ml.jobWizardCommon.assertUseFullDataButtonVisible(true);
await ml.commonUI.assertDatePickerDataTierOptionsVisible(false);
});
});
});
}

View file

@ -34,6 +34,7 @@ export default function ({ getPageObjects }: FtrProviderContext) {
{ label: 'Machine Learning / Data Visualizer', expected: true },
{ label: 'Machine Learning / File Upload', expected: true },
{ label: 'Machine Learning / Index Data Visualizer', expected: true },
{ label: 'Machine Learning / ES|QL Data Visualizer', expected: true },
{ label: 'Machine Learning / Data Drift', expected: true },
{ label: 'Alerts and Insights / Machine Learning', expected: true },
];