CCS Tests for Machine Learning (#144869)

This commit is contained in:
John Dorlus 2022-11-14 11:31:27 -05:00 committed by GitHub
parent 90f6ffb353
commit 045b57093c
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) : []),
],
},
{