[8.5] CCS Tests for Machine Learning (#144869) (#146190)

# Backport

This will backport the following commits from `main` to `8.5`:
- [CCS Tests for Machine Learning
(#144869)](https://github.com/elastic/kibana/pull/144869)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"John
Dorlus","email":"jsdorlus@elastic.co"},"sourceCommit":{"committedDate":"2022-11-14T16:31:27Z","message":"CCS
Tests for Machine Learning
(#144869)","sha":"045b57093cc6ce7425ee265b8c1e2cd0de1bc152","branchLabelMapping":{"^v8.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","test_ui_functional","test_xpack_functional","release_note:skip","Feature:Functional
Testing","Team:ML","backport:prev-minor","v8.7.0","v8.5.2","v8.6.1"],"number":144869,"url":"https://github.com/elastic/kibana/pull/144869","mergeCommit":{"message":"CCS
Tests for Machine Learning
(#144869)","sha":"045b57093cc6ce7425ee265b8c1e2cd0de1bc152"}},"sourceBranch":"main","suggestedTargetBranches":["8.5","8.6"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.5","label":"v8.5.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
This commit is contained in:
John Dorlus 2022-11-23 12:40:15 -05:00 committed by GitHub
parent 862983b1a1
commit e71506d3ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 20 deletions

View file

@ -8,7 +8,9 @@
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const config = getService('config');
const isCcs = config.get('esTestCluster.ccs');
const esNode = isCcs ? getService('remoteEsArchiver' as 'esArchiver') : getService('esArchiver');
const ml = getService('ml');
describe('machine learning - anomaly detection', function () {
@ -17,6 +19,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
before(async () => {
await ml.securityCommon.createMlRoles();
await ml.securityCommon.createMlUsers();
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
@ -26,22 +29,25 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
await ml.securityCommon.cleanMlUsers();
await ml.securityCommon.cleanMlRoles();
await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/categorization_small');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/event_rate_nanos');
await esNode.unload('x-pack/test/functional/es_archives/ml/farequote');
await esNode.unload('x-pack/test/functional/es_archives/ml/ecommerce');
await esNode.unload('x-pack/test/functional/es_archives/ml/categorization_small');
await esNode.unload('x-pack/test/functional/es_archives/ml/event_rate_nanos');
await ml.testResources.resetKibanaTimeZone();
});
loadTestFile(require.resolve('./single_metric_job'));
loadTestFile(require.resolve('./single_metric_job_without_datafeed_start'));
loadTestFile(require.resolve('./multi_metric_job'));
loadTestFile(require.resolve('./population_job'));
loadTestFile(require.resolve('./saved_search_job'));
loadTestFile(require.resolve('./advanced_job'));
loadTestFile(require.resolve('./categorization_job'));
loadTestFile(require.resolve('./date_nanos_job'));
loadTestFile(require.resolve('./custom_urls'));
if (!isCcs) {
loadTestFile(require.resolve('./single_metric_job_without_datafeed_start'));
loadTestFile(require.resolve('./multi_metric_job'));
loadTestFile(require.resolve('./population_job'));
loadTestFile(require.resolve('./saved_search_job'));
loadTestFile(require.resolve('./advanced_job'));
loadTestFile(require.resolve('./categorization_job'));
loadTestFile(require.resolve('./date_nanos_job'));
loadTestFile(require.resolve('./custom_urls'));
}
});
}

View file

@ -8,7 +8,10 @@
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const config = getService('config');
const esNode = config.get('esTestCluster.ccs')
? getService('remoteEsArchiver' as 'esArchiver')
: getService('esArchiver');
const ml = getService('ml');
const browser = getService('browser');
@ -70,12 +73,17 @@ export default function ({ getService }: FtrProviderContext) {
}
const calendarId = `wizard-test-calendar_${Date.now()}`;
const remoteName = 'ftr-remote:';
const indexPatternName = 'ft_farequote';
const indexPatternString = config.get('esTestCluster.ccs')
? remoteName + indexPatternName
: indexPatternName;
describe('single metric', function () {
this.tags(['ml']);
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await esNode.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
await ml.testResources.createIndexPatternIfNeeded(indexPatternString, '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createCalendar(calendarId);
@ -84,7 +92,7 @@ export default function ({ getService }: FtrProviderContext) {
after(async () => {
await ml.api.cleanMlIndices();
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');
await ml.testResources.deleteIndexPatternByTitle(indexPatternString);
});
it('job creation loads the single metric wizard for the source data', async () => {
@ -96,7 +104,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.jobManagement.navigateToNewJobSourceSelection();
await ml.testExecution.logTestStep('job creation loads the job type selection page');
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_farequote');
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(indexPatternString);
await ml.testExecution.logTestStep('job creation loads the single metric job wizard page');
await ml.jobTypeSelection.selectSingleMetricJob();
@ -204,7 +212,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job cloning fails in the single metric wizard if a matching data view does not exist', async () => {
await ml.testExecution.logTestStep('delete data view used by job');
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');
await ml.testResources.deleteIndexPatternByTitle(indexPatternString);
// Refresh page to ensure page has correct cache of data views
await browser.refresh();
@ -217,7 +225,7 @@ export default function ({ getService }: FtrProviderContext) {
it('job cloning opens the existing job in the single metric wizard', async () => {
await ml.testExecution.logTestStep('recreate data view used by job');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.createIndexPatternIfNeeded(indexPatternString, '@timestamp');
// Refresh page to ensure page has correct cache of data views
await browser.refresh();

View file

@ -20,6 +20,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
require.resolve('./apps/lens/group1'),
require.resolve('./apps/remote_clusters/ccs/remote_clusters_index_management_flow'),
require.resolve('./apps/rollup_job'),
require.resolve('./apps/ml/anomaly_detection_jobs'),
],
junit: {

View file

@ -24,7 +24,9 @@ export enum USER {
}
export function MachineLearningSecurityCommonProvider({ getService }: FtrProviderContext) {
const config = getService('config');
const security = getService('security');
const remoteEsRoles: undefined | Record<string, any> = config.get('security.remoteEsRoles');
const roles = [
{
@ -172,6 +174,7 @@ export function MachineLearningSecurityCommonProvider({ getService }: FtrProvide
'ft_ml_source',
'ft_ml_dest',
'ft_ml_ui_extras',
...(remoteEsRoles ? Object.keys(remoteEsRoles) : []),
],
},
{