[ML] Functional tests - refactor test resources (#63724)

This PR changes the way how test resources like indices and saved objects are used in ML and Transform functional tests. No actual test logic is changed.
This commit is contained in:
Robert Oskamp 2020-04-17 18:10:46 +02:00 committed by GitHub
parent fb1ff02ed3
commit 1992716086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 727 additions and 11720 deletions

View file

@ -28,7 +28,7 @@ export default ({ getService }: FtrProviderContext) => {
aggTypes: ['avg'],
duration: { start: 1560297859000, end: 1562975136000 },
fields: ['taxless_total_price'],
index: 'ecommerce',
index: 'ft_ecommerce',
query: { bool: { must: [{ match_all: {} }] } },
timeField: 'order_date',
},
@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => {
aggTypes: ['avg', 'sum'],
duration: { start: 1560297859000, end: 1562975136000 },
fields: ['products.base_price', 'products.base_unit_price'],
index: 'ecommerce',
index: 'ft_ecommerce',
query: { bool: { must: [{ match_all: {} }] } },
timeField: 'order_date',
},
@ -60,7 +60,7 @@ export default ({ getService }: FtrProviderContext) => {
aggTypes: ['avg'],
duration: { start: 1560297859000, end: 1562975136000 },
fields: ['taxless_total_price'],
index: 'ecommerce',
index: 'ft_ecommerce',
query: { bool: { must: [{ match_all: {} }] } },
splitField: 'customer_first_name.keyword',
timeField: 'order_date',
@ -78,7 +78,7 @@ export default ({ getService }: FtrProviderContext) => {
duration: { start: 1560297859000, end: 1562975136000 },
fields: ['taxless_total_price'],
filters: [],
index: 'ecommerce',
index: 'ft_ecommerce',
query: { bool: { must: [{ match_all: {} }] } },
timeField: 'order_date',
},
@ -91,11 +91,8 @@ export default ({ getService }: FtrProviderContext) => {
describe('bucket span estimator', function() {
before(async () => {
await esArchiver.load('ml/ecommerce');
});
after(async () => {
await esArchiver.unload('ml/ecommerce');
await esArchiver.loadIfNeeded('ml/ecommerce');
await ml.testResources.setKibanaTimeZoneToUTC();
});
describe('with default settings', function() {

View file

@ -22,7 +22,7 @@ export default ({ getService }: FtrProviderContext) => {
testTitleSuffix: 'when no partition field is provided with regular function',
user: USER.ML_POWERUSER,
requestBody: {
indexPattern: 'ecommerce',
indexPattern: 'ft_ecommerce',
analysisConfig: {
bucket_span: '15m',
detectors: [
@ -51,7 +51,7 @@ export default ({ getService }: FtrProviderContext) => {
testTitleSuffix: 'with 1 metric and 1 influencer same as split field',
user: USER.ML_POWERUSER,
requestBody: {
indexPattern: 'ecommerce',
indexPattern: 'ft_ecommerce',
analysisConfig: {
bucket_span: '15m',
detectors: [
@ -77,7 +77,7 @@ export default ({ getService }: FtrProviderContext) => {
testTitleSuffix: 'with 3 influencers, split by city',
user: USER.ML_POWERUSER,
requestBody: {
indexPattern: 'ecommerce',
indexPattern: 'ft_ecommerce',
analysisConfig: {
bucket_span: '15m',
detectors: [
@ -104,7 +104,7 @@ export default ({ getService }: FtrProviderContext) => {
'2 detectors split by city and manufacturer, 4 influencers, filtering by country code',
user: USER.ML_POWERUSER,
requestBody: {
indexPattern: 'ecommerce',
indexPattern: 'ft_ecommerce',
analysisConfig: {
bucket_span: '2d',
detectors: [
@ -148,11 +148,8 @@ export default ({ getService }: FtrProviderContext) => {
describe('calculate model memory limit', function() {
before(async () => {
await esArchiver.load('ml/ecommerce');
});
after(async () => {
await esArchiver.unload('ml/ecommerce');
await esArchiver.loadIfNeeded('ml/ecommerce');
await ml.testResources.setKibanaTimeZoneToUTC();
});
for (const testData of testDataList) {

View file

@ -66,7 +66,7 @@ const analyzer = {
],
};
const defaultRequestBody = {
indexPatternTitle: 'categorization_functional_test',
indexPatternTitle: 'ft_categorization',
query: { bool: { must: [{ match_all: {} }] } },
size: 5,
timeField: '@timestamp',
@ -289,11 +289,8 @@ export default ({ getService }: FtrProviderContext) => {
describe('Categorization example endpoint - ', function() {
before(async () => {
await esArchiver.load('ml/categorization');
});
after(async () => {
await esArchiver.unload('ml/categorization');
await esArchiver.loadIfNeeded('ml/categorization');
await ml.testResources.setKibanaTimeZoneToUTC();
});
for (const testData of testDataList) {

View file

@ -50,6 +50,10 @@ export default ({ getService }: FtrProviderContext) => {
}
describe('get_module', function() {
before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
});
it('lists all modules', async () => {
const rspBody = await executeGetModuleRequest('', USER.ML_POWERUSER, 200);
expect(rspBody).to.be.an(Array);

View file

@ -7,6 +7,7 @@
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
describe('Machine Learning', function() {
@ -20,6 +21,14 @@ export default function({ getService, loadTestFile }: FtrProviderContext) {
after(async () => {
await ml.securityCommon.cleanMlUsers();
await ml.securityCommon.cleanMlRoles();
await ml.testResources.deleteIndexPattern('kibana_sample_data_logs');
await esArchiver.unload('ml/ecommerce');
await esArchiver.unload('ml/categorization');
await esArchiver.unload('ml/sample_logs');
await ml.testResources.resetKibanaTimeZone();
});
loadTestFile(require.resolve('./bucket_span_estimator'));

View file

@ -32,7 +32,6 @@ export default ({ getService }: FtrProviderContext) => {
},
{
testTitleSuffix: 'for non existent index pattern',
sourceDataArchive: 'empty_kibana',
indexPattern: 'non-existent-index-pattern',
user: USER.ML_POWERUSER,
expected: {
@ -53,14 +52,16 @@ export default ({ getService }: FtrProviderContext) => {
}
describe('module recognizer', function() {
before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
});
for (const testData of testDataList) {
describe('lists matching modules', function() {
before(async () => {
await esArchiver.load(testData.sourceDataArchive);
});
after(async () => {
await esArchiver.unload(testData.sourceDataArchive);
if (testData.hasOwnProperty('sourceDataArchive')) {
await esArchiver.loadIfNeeded(testData.sourceDataArchive!);
}
});
it(testData.testTitleSuffix, async () => {

View file

@ -25,6 +25,7 @@ export default ({ getService }: FtrProviderContext) => {
{
testTitleSuffix: 'for sample logs dataset with prefix and startDatafeed false',
sourceDataArchive: 'ml/sample_logs',
indexPattern: { name: 'kibana_sample_data_logs', timeField: '@timestamp' },
module: 'sample_data_weblogs',
user: USER.ML_POWERUSER,
requestBody: {
@ -58,7 +59,6 @@ export default ({ getService }: FtrProviderContext) => {
const testDataListNegative = [
{
testTitleSuffix: 'for non existent index pattern',
sourceDataArchive: 'empty_kibana',
module: 'sample_data_weblogs',
user: USER.ML_POWERUSER,
requestBody: {
@ -75,6 +75,7 @@ export default ({ getService }: FtrProviderContext) => {
{
testTitleSuffix: 'for unauthorized user',
sourceDataArchive: 'ml/sample_logs',
indexPattern: { name: 'kibana_sample_data_logs', timeField: '@timestamp' },
module: 'sample_data_weblogs',
user: USER.ML_UNAUTHORIZED,
requestBody: {
@ -118,14 +119,21 @@ export default ({ getService }: FtrProviderContext) => {
}
describe('module setup', function() {
before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
});
for (const testData of testDataListPositive) {
describe('sets up module data', function() {
before(async () => {
await esArchiver.load(testData.sourceDataArchive);
await esArchiver.loadIfNeeded(testData.sourceDataArchive);
await ml.testResources.createIndexPatternIfNeeded(
testData.indexPattern.name,
testData.indexPattern.timeField
);
});
after(async () => {
await esArchiver.unload(testData.sourceDataArchive);
await ml.api.cleanMlIndices();
});
@ -199,11 +207,18 @@ export default ({ getService }: FtrProviderContext) => {
for (const testData of testDataListNegative) {
describe('rejects request', function() {
before(async () => {
await esArchiver.load(testData.sourceDataArchive);
if (testData.hasOwnProperty('sourceDataArchive')) {
await esArchiver.loadIfNeeded(testData.sourceDataArchive!);
}
if (testData.hasOwnProperty('indexPattern')) {
await ml.testResources.createIndexPatternIfNeeded(
testData.indexPattern!.name as string,
testData.indexPattern!.timeField as string
);
}
});
after(async () => {
await esArchiver.unload(testData.sourceDataArchive);
await ml.api.cleanMlIndices();
});

View file

@ -9,14 +9,17 @@ import { FtrProviderContext } from '../../functional/ftr_provider_context';
import {
MachineLearningAPIProvider,
MachineLearningSecurityCommonProvider,
MachineLearningTestResourcesProvider,
} from '../../functional/services/machine_learning';
export function MachineLearningProvider(context: FtrProviderContext) {
const api = MachineLearningAPIProvider(context);
const securityCommon = MachineLearningSecurityCommonProvider(context);
const testResources = MachineLearningTestResourcesProvider(context);
return {
api,
securityCommon,
testResources,
};
}

View file

@ -110,13 +110,13 @@ export default function({ getService }: FtrProviderContext) {
const testDataList = [
{
suiteTitle: 'with multiple metric detectors and custom datafeed settings',
jobSource: 'ecommerce',
jobSource: 'ft_ecommerce',
jobId: `ec_advanced_1_${Date.now()}`,
get jobIdClone(): string {
return `${this.jobId}_clone`;
},
jobDescription:
'Create advanced job from ecommerce dataset with multiple metric detectors and custom datafeed settings',
'Create advanced job from ft_ecommerce dataset with multiple metric detectors and custom datafeed settings',
jobGroups: ['automated', 'ecommerce', 'advanced'],
get jobGroupsClone(): string[] {
return [...this.jobGroups, 'clone'];
@ -207,13 +207,13 @@ export default function({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'with categorization detector and default datafeed settings',
jobSource: 'ecommerce',
jobSource: 'ft_ecommerce',
jobId: `ec_advanced_2_${Date.now()}`,
get jobIdClone(): string {
return `${this.jobId}_clone`;
},
jobDescription:
'Create advanced job from ecommerce dataset with a categorization detector and default datafeed settings',
'Create advanced job from ft_ecommerce dataset with a categorization detector and default datafeed settings',
jobGroups: ['automated', 'ecommerce', 'advanced'],
get jobGroupsClone(): string[] {
return [...this.jobGroups, 'clone'];
@ -274,16 +274,20 @@ export default function({ getService }: FtrProviderContext) {
},
];
const calendarId = `wizard-test-calendar_${Date.now()}`;
describe('advanced job', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/ecommerce');
await ml.api.createCalendar('wizard-test-calendar');
await esArchiver.loadIfNeeded('ml/ecommerce');
await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createCalendar(calendarId);
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/ecommerce');
await ml.api.cleanMlIndices();
});
@ -475,7 +479,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation assigns calendars', async () => {
await ml.jobWizardCommon.addCalendar('wizard-test-calendar');
await ml.jobWizardCommon.addCalendar(calendarId);
});
it('job creation displays the model plot switch', async () => {
@ -734,7 +738,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job cloning persists assigned calendars', async () => {
await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']);
await ml.jobWizardCommon.assertCalendarsSelection([calendarId]);
});
it('job cloning pre-fills the model plot switch', async () => {

View file

@ -29,7 +29,7 @@ const JOB_CONFIG: Job = {
const DATAFEED_CONFIG: Datafeed = {
datafeed_id: 'datafeed-fq_multi_1_se',
indices: ['farequote'],
indices: ['ft_farequote'],
job_id: 'fq_multi_1_ae',
query: { bool: { must: [{ match_all: {} }] } },
};
@ -59,12 +59,11 @@ export default function({ getService }: FtrProviderContext) {
describe('anomaly explorer', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/farequote');
await ml.securityUI.loginAsMlPowerUser();
});
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.securityUI.loginAsMlPowerUser();
});
for (const testData of testDataList) {

View file

@ -16,7 +16,7 @@ export default function({ getService }: FtrProviderContext) {
const jobId = `categorization_${Date.now()}`;
const jobIdClone = `${jobId}_clone`;
const jobDescription =
'Create categorization job based on the categorization_functional_test dataset with a count rare';
'Create categorization job based on the ft_categorization dataset with a count rare';
const jobGroups = ['automated', 'categorization'];
const jobGroupsClone = [...jobGroups, 'clone'];
const detectorTypeIdentifier = 'Rare';
@ -74,16 +74,20 @@ export default function({ getService }: FtrProviderContext) {
};
}
const calendarId = `wizard-test-calendar_${Date.now()}`;
describe('categorization', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/categorization');
await ml.api.createCalendar('wizard-test-calendar');
await esArchiver.loadIfNeeded('ml/categorization');
await ml.testResources.createIndexPatternIfNeeded('ft_categorization', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createCalendar(calendarId);
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/categorization');
await ml.api.cleanMlIndices();
});
@ -97,9 +101,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation loads the job type selection page', async () => {
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(
'categorization_functional_test'
);
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_categorization');
});
it('job creation loads the categorization job wizard page', async () => {
@ -178,7 +180,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation assigns calendars', async () => {
await ml.jobWizardCommon.addCalendar('wizard-test-calendar');
await ml.jobWizardCommon.addCalendar(calendarId);
});
it('job creation opens the advanced section', async () => {
@ -310,7 +312,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job cloning persists assigned calendars', async () => {
await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']);
await ml.jobWizardCommon.assertCalendarsSelection([calendarId]);
});
it('job cloning opens the advanced section', async () => {

View file

@ -104,7 +104,7 @@ export default function({ getService }: FtrProviderContext) {
const testDataList = [
{
suiteTitle: 'with count detector and model plot disabled',
jobSource: 'event_rate_gen_trend_nanos',
jobSource: 'ft_event_rate_gen_trend_nanos',
jobId: `event_rate_nanos_count_1_${Date.now()}`,
jobDescription:
'Create advanced job based on the event rate dataset with a date_nanos time field, 30m bucketspan and count',
@ -168,12 +168,18 @@ export default function({ getService }: FtrProviderContext) {
describe('job on data set with date_nanos time field', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/event_rate_nanos');
await esArchiver.loadIfNeeded('ml/event_rate_nanos');
await ml.testResources.createIndexPatternIfNeeded(
'ft_event_rate_gen_trend_nanos',
'@timestamp'
);
await ml.testResources.setKibanaTimeZoneToUTC();
await esArchiver.loadIfNeeded('ml/event_rate_nanos');
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/event_rate_nanos');
await ml.api.cleanMlIndices();
});

View file

@ -71,16 +71,20 @@ export default function({ getService }: FtrProviderContext) {
};
}
const calendarId = `wizard-test-calendar_${Date.now()}`;
describe('multi metric', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/farequote');
await ml.api.createCalendar('wizard-test-calendar');
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createCalendar(calendarId);
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.api.cleanMlIndices();
});
@ -94,7 +98,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation loads the job type selection page', async () => {
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('farequote');
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_farequote');
});
it('job creation loads the multi metric job wizard page', async () => {
@ -181,7 +185,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation assigns calendars', async () => {
await ml.jobWizardCommon.addCalendar('wizard-test-calendar');
await ml.jobWizardCommon.addCalendar(calendarId);
});
it('job creation opens the advanced section', async () => {
@ -329,7 +333,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job cloning persists assigned calendars', async () => {
await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']);
await ml.jobWizardCommon.assertCalendarsSelection([calendarId]);
});
it('job cloning opens the advanced section', async () => {

View file

@ -85,16 +85,20 @@ export default function({ getService }: FtrProviderContext) {
};
}
const calendarId = `wizard-test-calendar_${Date.now()}`;
describe('population', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/ecommerce');
await ml.api.createCalendar('wizard-test-calendar');
await esArchiver.loadIfNeeded('ml/ecommerce');
await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createCalendar(calendarId);
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.api.cleanMlIndices();
});
@ -108,7 +112,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation loads the job type selection page', async () => {
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ecommerce');
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_ecommerce');
});
it('job creation loads the population job wizard page', async () => {
@ -208,7 +212,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation assigns calendars', async () => {
await ml.jobWizardCommon.addCalendar('wizard-test-calendar');
await ml.jobWizardCommon.addCalendar(calendarId);
});
it('job creation opens the advanced section', async () => {
@ -367,7 +371,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job cloning persists assigned calendars', async () => {
await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']);
await ml.jobWizardCommon.assertCalendarsSelection([calendarId]);
});
it('job cloning opens the advanced section', async () => {

View file

@ -15,7 +15,7 @@ export default function({ getService }: FtrProviderContext) {
const testDataList = [
{
suiteTitle: 'with filter',
jobSource: 'farequote_filter',
jobSource: 'ft_farequote_filter',
jobId: `fq_saved_search_1_${Date.now()}`,
jobDescription: 'Create multi metric job based on a saved search with filter',
jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'],
@ -66,7 +66,7 @@ export default function({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'with lucene query',
jobSource: 'farequote_lucene',
jobSource: 'ft_farequote_lucene',
jobId: `fq_saved_search_2_${Date.now()}`,
jobDescription: 'Create multi metric job based on a saved search with lucene query',
jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'],
@ -117,7 +117,7 @@ export default function({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'with kuery query',
jobSource: 'farequote_kuery',
jobSource: 'ft_farequote_kuery',
jobId: `fq_saved_search_3_${Date.now()}`,
jobDescription: 'Create multi metric job based on a saved search with kuery query',
jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'],
@ -168,7 +168,7 @@ export default function({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'with filter and lucene query',
jobSource: 'farequote_filter_and_lucene',
jobSource: 'ft_farequote_filter_and_lucene',
jobId: `fq_saved_search_4_${Date.now()}`,
jobDescription:
'Create multi metric job based on a saved search with filter and lucene query',
@ -220,7 +220,7 @@ export default function({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'with filter and kuery query',
jobSource: 'farequote_filter_and_kuery',
jobSource: 'ft_farequote_filter_and_kuery',
jobId: `fq_saved_search_5_${Date.now()}`,
jobDescription: 'Create multi metric job based on a saved search with filter and kuery query',
jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'],
@ -274,12 +274,19 @@ export default function({ getService }: FtrProviderContext) {
describe('saved search', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/farequote');
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.createSavedSearchFarequoteFilterIfNeeded();
await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded();
await ml.testResources.createSavedSearchFarequoteKueryIfNeeded();
await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded();
await ml.testResources.createSavedSearchFarequoteFilterAndKueryIfNeeded();
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.api.cleanMlIndices();
});

View file

@ -70,16 +70,20 @@ export default function({ getService }: FtrProviderContext) {
};
}
const calendarId = `wizard-test-calendar_${Date.now()}`;
describe('single metric', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/farequote');
await ml.api.createCalendar('wizard-test-calendar');
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createCalendar(calendarId);
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.api.cleanMlIndices();
});
@ -93,7 +97,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation loads the job type selection page', async () => {
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('farequote');
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_farequote');
});
it('job creation loads the single metric job wizard page', async () => {
@ -162,7 +166,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job creation assigns calendars', async () => {
await ml.jobWizardCommon.addCalendar('wizard-test-calendar');
await ml.jobWizardCommon.addCalendar(calendarId);
});
it('job creation opens the advanced section', async () => {
@ -294,7 +298,7 @@ export default function({ getService }: FtrProviderContext) {
});
it('job cloning persists assigned calendars', async () => {
await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']);
await ml.jobWizardCommon.assertCalendarsSelection([calendarId]);
});
it('job cloning opens the advanced section', async () => {

View file

@ -29,7 +29,7 @@ const JOB_CONFIG: Job = {
const DATAFEED_CONFIG: Datafeed = {
datafeed_id: 'datafeed-fq_single_1_smv',
indices: ['farequote'],
indices: ['ft_farequote'],
job_id: 'fq_single_1_smv',
query: { bool: { must: [{ match_all: {} }] } },
};
@ -42,13 +42,15 @@ export default function({ getService }: FtrProviderContext) {
describe('single metric viewer', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/farequote');
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.api.createAndRunAnomalyDetectionLookbackJob(JOB_CONFIG, DATAFEED_CONFIG);
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.api.cleanMlIndices();
});

View file

@ -14,13 +14,15 @@ export default function({ getService }: FtrProviderContext) {
describe('classification creation', function() {
this.tags(['smoke']);
before(async () => {
await esArchiver.load('ml/bm_classification');
await esArchiver.loadIfNeeded('ml/bm_classification');
await ml.testResources.createIndexPatternIfNeeded('ft_bank_marketing', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await ml.api.cleanMlIndices();
await esArchiver.unload('ml/bm_classification');
});
const testDataList = [
@ -29,8 +31,8 @@ export default function({ getService }: FtrProviderContext) {
jobType: 'classification',
jobId: `bm_1_${Date.now()}`,
jobDescription:
"Classification job based on 'bank-marketing' dataset with dependentVariable 'y' and trainingPercent '20'",
source: 'bank-marketing*',
"Classification job based on 'ft_bank_marketing' dataset with dependentVariable 'y' and trainingPercent '20'",
source: 'ft_bank_marketing',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
@ -51,6 +53,7 @@ export default function({ getService }: FtrProviderContext) {
describe(`${testData.suiteTitle}`, function() {
after(async () => {
await ml.api.deleteIndices(testData.destinationIndex);
await ml.testResources.deleteIndexPattern(testData.destinationIndex);
});
it('loads the data frame analytics page', async () => {

View file

@ -19,6 +19,7 @@ export default function({ getService }: FtrProviderContext) {
const testDataList: Array<{
suiteTitle: string;
archive: string;
indexPattern: { name: string; timeField: string };
job: DeepPartial<DataFrameAnalyticsConfig>;
}> = (() => {
const timestamp = Date.now();
@ -27,12 +28,13 @@ export default function({ getService }: FtrProviderContext) {
{
suiteTitle: 'classification job supported by the form',
archive: 'ml/bm_classification',
indexPattern: { name: 'ft_bank_marketing', timeField: '@timestamp' },
job: {
id: `bm_1_${timestamp}`,
description:
"Classification job based on 'bank-marketing' dataset with dependentVariable 'y' and trainingPercent '20'",
"Classification job based on 'ft_bank_marketing' dataset with dependentVariable 'y' and trainingPercent '20'",
source: {
index: ['bank-marketing*'],
index: ['ft_bank_marketing'],
query: {
match_all: {},
},
@ -60,11 +62,12 @@ export default function({ getService }: FtrProviderContext) {
{
suiteTitle: 'outlier detection job supported by the form',
archive: 'ml/ihp_outlier',
indexPattern: { name: 'ft_ihp_outlier', timeField: '@timestamp' },
job: {
id: `ihp_1_${timestamp}`,
description: 'This is the job description',
source: {
index: ['ihp_outlier'],
index: ['ft_ihp_outlier'],
query: {
match_all: {},
},
@ -88,11 +91,12 @@ export default function({ getService }: FtrProviderContext) {
{
suiteTitle: 'regression job supported by the form',
archive: 'ml/egs_regression',
indexPattern: { name: 'ft_egs_regression', timeField: '@timestamp' },
job: {
id: `egs_1_${timestamp}`,
description: 'This is the job description',
source: {
index: ['egs_regression'],
index: ['ft_egs_regression'],
query: {
match_all: {},
},
@ -120,6 +124,7 @@ export default function({ getService }: FtrProviderContext) {
})();
before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});
@ -133,7 +138,11 @@ export default function({ getService }: FtrProviderContext) {
const cloneDestIndex = `${testData.job!.dest!.index}_clone`;
before(async () => {
await esArchiver.load(testData.archive);
await esArchiver.loadIfNeeded(testData.archive);
await ml.testResources.createIndexPatternIfNeeded(
testData.indexPattern.name,
testData.indexPattern.timeField
);
await ml.api.createDataFrameAnalyticsJob(testData.job as DataFrameAnalyticsConfig);
await ml.navigation.navigateToMl();
@ -146,7 +155,7 @@ export default function({ getService }: FtrProviderContext) {
after(async () => {
await ml.api.deleteIndices(cloneDestIndex);
await ml.api.deleteIndices(testData.job.dest!.index as string);
await esArchiver.unload(testData.archive);
await ml.testResources.deleteIndexPattern(testData.job.dest!.index as string);
});
it('should open the flyout with a proper header', async () => {

View file

@ -14,13 +14,15 @@ export default function({ getService }: FtrProviderContext) {
describe('outlier detection creation', function() {
this.tags(['smoke']);
before(async () => {
await esArchiver.load('ml/ihp_outlier');
await esArchiver.loadIfNeeded('ml/ihp_outlier');
await ml.testResources.createIndexPatternIfNeeded('ft_ihp_outlier', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await ml.api.cleanMlIndices();
await esArchiver.unload('ml/ihp_outlier');
});
const testDataList = [
@ -29,7 +31,7 @@ export default function({ getService }: FtrProviderContext) {
jobType: 'outlier_detection',
jobId: `ihp_1_${Date.now()}`,
jobDescription: 'This is the job description',
source: 'ihp_outlier',
source: 'ft_ihp_outlier',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
@ -49,6 +51,7 @@ export default function({ getService }: FtrProviderContext) {
describe(`${testData.suiteTitle}`, function() {
after(async () => {
await ml.api.deleteIndices(testData.destinationIndex);
await ml.testResources.deleteIndexPattern(testData.destinationIndex);
});
it('loads the data frame analytics page', async () => {

View file

@ -14,13 +14,15 @@ export default function({ getService }: FtrProviderContext) {
describe('regression creation', function() {
this.tags(['smoke']);
before(async () => {
await esArchiver.load('ml/egs_regression');
await esArchiver.loadIfNeeded('ml/egs_regression');
await ml.testResources.createIndexPatternIfNeeded('ft_egs_regression', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await ml.api.cleanMlIndices();
await esArchiver.unload('ml/egs_regression');
});
const testDataList = [
@ -29,7 +31,7 @@ export default function({ getService }: FtrProviderContext) {
jobType: 'regression',
jobId: `egs_1_${Date.now()}`,
jobDescription: 'This is the job description',
source: 'egs_regression',
source: 'ft_egs_regression',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
@ -51,6 +53,7 @@ export default function({ getService }: FtrProviderContext) {
describe(`${testData.suiteTitle}`, function() {
after(async () => {
await ml.api.deleteIndices(testData.destinationIndex);
await ml.testResources.deleteIndexPattern(testData.destinationIndex);
});
it('loads the data frame analytics page', async () => {

View file

@ -36,6 +36,8 @@ export default function({ getService }: FtrProviderContext) {
describe('file based', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
await ml.navigation.navigateToMl();
});

View file

@ -45,7 +45,7 @@ export default function({ getService }: FtrProviderContext) {
const farequoteIndexPatternTestData: TestData = {
suiteTitle: 'index pattern',
sourceIndexOrSavedSearch: 'farequote',
sourceIndexOrSavedSearch: 'ft_farequote',
advancedJobWizardDatafeedQuery: `{
"bool": {
"must": [
@ -128,7 +128,7 @@ export default function({ getService }: FtrProviderContext) {
const farequoteKQLSearchTestData: TestData = {
suiteTitle: 'KQL saved search',
sourceIndexOrSavedSearch: 'farequote_kuery',
sourceIndexOrSavedSearch: 'ft_farequote_kuery',
advancedJobWizardDatafeedQuery: `{
"bool": {
"must": [
@ -211,7 +211,7 @@ export default function({ getService }: FtrProviderContext) {
const farequoteLuceneSearchTestData: TestData = {
suiteTitle: 'lucene saved search',
sourceIndexOrSavedSearch: 'farequote_lucene',
sourceIndexOrSavedSearch: 'ft_farequote_lucene',
advancedJobWizardDatafeedQuery: `{
"bool": {
"must": [
@ -378,12 +378,13 @@ export default function({ getService }: FtrProviderContext) {
describe('index based', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('ml/farequote');
await ml.securityUI.loginAsMlPowerUser();
});
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded();
await ml.testResources.createSavedSearchFarequoteKueryIfNeeded();
await ml.testResources.setKibanaTimeZoneToUTC();
after(async () => {
await esArchiver.unload('ml/farequote');
await ml.securityUI.loginAsMlPowerUser();
});
// TODO - add tests for

View file

@ -7,15 +7,12 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function({ getPageObjects, getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const security = getService('security');
const appsMenu = getService('appsMenu');
const PageObjects = getPageObjects(['common', 'security']);
describe('security', function() {
before(async () => {
await esArchiver.load('empty_kibana');
await security.role.create('global_all_role', {
elasticsearch: {
indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }],
@ -33,7 +30,6 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
});
after(async () => {
await esArchiver.unload('empty_kibana');
await security.role.delete('global_all_role');
// logout, so the other tests don't accidentally run as the custom users we're testing below

View file

@ -7,21 +7,12 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function({ getPageObjects, getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const spacesService = getService('spaces');
const PageObjects = getPageObjects(['common', 'dashboard', 'security', 'error']);
const appsMenu = getService('appsMenu');
const testSubjects = getService('testSubjects');
describe('spaces', () => {
before(async () => {
await esArchiver.load('empty_kibana');
});
after(async () => {
await esArchiver.unload('empty_kibana');
});
describe('space with no features disabled', () => {
before(async () => {
await spacesService.create({

View file

@ -6,6 +6,7 @@
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
describe('machine learning', function() {
@ -19,6 +20,26 @@ export default function({ getService, loadTestFile }: FtrProviderContext) {
after(async () => {
await ml.securityCommon.cleanMlUsers();
await ml.securityCommon.cleanMlRoles();
await ml.testResources.deleteSavedSearches();
await ml.testResources.deleteIndexPattern('ft_farequote');
await ml.testResources.deleteIndexPattern('ft_ecommerce');
await ml.testResources.deleteIndexPattern('ft_categorization');
await ml.testResources.deleteIndexPattern('ft_event_rate_gen_trend_nanos');
await ml.testResources.deleteIndexPattern('ft_bank_marketing');
await ml.testResources.deleteIndexPattern('ft_ihp_outlier');
await ml.testResources.deleteIndexPattern('ft_egs_regression');
await esArchiver.unload('ml/farequote');
await esArchiver.unload('ml/ecommerce');
await esArchiver.unload('ml/categorization');
await esArchiver.unload('ml/event_rate_nanos');
await esArchiver.unload('ml/bm_classification');
await esArchiver.unload('ml/ihp_outlier');
await esArchiver.unload('ml/egs_regression');
await ml.testResources.resetKibanaTimeZone();
});
loadTestFile(require.resolve('./feature_controls'));

View file

@ -7,20 +7,15 @@
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
describe('page navigation', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await esArchiver.load('empty_kibana');
await ml.api.cleanMlIndices();
await ml.securityUI.loginAsMlPowerUser();
});
after(async () => {
await esArchiver.unload('empty_kibana');
});
it('loads the home page', async () => {
await ml.navigation.navigateToMl();
});

View file

@ -11,7 +11,7 @@ function getTransformConfig(): TransformPivotConfig {
const date = Date.now();
return {
id: `ec_2_${date}`,
source: { index: ['ecommerce'] },
source: { index: ['ft_ecommerce'] },
pivot: {
group_by: { category: { terms: { field: 'category.keyword' } } },
aggregations: { 'products.base_price.avg': { avg: { field: 'products.base_price' } } },
@ -31,13 +31,16 @@ export default function({ getService }: FtrProviderContext) {
const transformConfig = getTransformConfig();
before(async () => {
await esArchiver.load('ml/ecommerce');
await esArchiver.loadIfNeeded('ml/ecommerce');
await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');
await transform.api.createAndRunTransform(transformConfig);
await transform.testResources.setKibanaTimeZoneToUTC();
await transform.securityUI.loginAsTransformPowerUser();
});
after(async () => {
await esArchiver.unload('ml/ecommerce');
await transform.testResources.deleteIndexPattern(transformConfig.dest.index);
await transform.api.deleteIndices(transformConfig.dest.index);
await transform.api.cleanTransformIndices();
});

View file

@ -20,19 +20,21 @@ export default function({ getService }: FtrProviderContext) {
describe('creation_index_pattern', function() {
this.tags(['smoke']);
before(async () => {
await esArchiver.load('ml/ecommerce');
await esArchiver.loadIfNeeded('ml/ecommerce');
await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');
await transform.testResources.setKibanaTimeZoneToUTC();
await transform.securityUI.loginAsTransformPowerUser();
});
after(async () => {
await esArchiver.unload('ml/ecommerce');
await transform.api.cleanTransformIndices();
});
const testDataList = [
{
suiteTitle: 'batch transform with terms+date_histogram groups and avg agg',
source: 'ecommerce',
source: 'ft_ecommerce',
groupByEntries: [
{
identifier: 'terms(category.keyword)',
@ -96,7 +98,7 @@ export default function({ getService }: FtrProviderContext) {
},
{
suiteTitle: 'batch transform with terms group and percentiles agg',
source: 'ecommerce',
source: 'ft_ecommerce',
groupByEntries: [
{
identifier: 'terms(geoip.country_iso_code)',
@ -154,6 +156,7 @@ export default function({ getService }: FtrProviderContext) {
describe(`${testData.suiteTitle}`, function() {
after(async () => {
await transform.api.deleteIndices(testData.destinationIndex);
await transform.testResources.deleteIndexPattern(testData.destinationIndex);
});
it('loads the home page', async () => {

View file

@ -20,19 +20,22 @@ export default function({ getService }: FtrProviderContext) {
describe('creation_saved_search', function() {
this.tags(['smoke']);
before(async () => {
await esArchiver.load('ml/farequote');
await esArchiver.loadIfNeeded('ml/farequote');
await transform.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await transform.testResources.createSavedSearchFarequoteFilterIfNeeded();
await transform.testResources.setKibanaTimeZoneToUTC();
await transform.securityUI.loginAsTransformPowerUser();
});
after(async () => {
await esArchiver.unload('ml/farequote');
await transform.api.cleanTransformIndices();
});
const testDataList = [
{
suiteTitle: 'batch transform with terms groups and avg agg with saved search filter',
source: 'farequote_filter',
source: 'ft_farequote_filter',
groupByEntries: [
{
identifier: 'terms(airline)',
@ -61,7 +64,7 @@ export default function({ getService }: FtrProviderContext) {
mode: 'batch',
progress: '100',
},
sourceIndex: 'farequote',
sourceIndex: 'ft_farequote',
sourcePreview: {
column: 2,
values: ['ASA'],
@ -74,6 +77,7 @@ export default function({ getService }: FtrProviderContext) {
describe(`${testData.suiteTitle}`, function() {
after(async () => {
await transform.api.deleteIndices(testData.destinationIndex);
await transform.testResources.deleteIndexPattern(testData.destinationIndex);
});
it('loads the home page', async () => {

View file

@ -6,6 +6,7 @@
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const transform = getService('transform');
describe('transform', function() {
@ -19,6 +20,16 @@ export default function({ getService, loadTestFile }: FtrProviderContext) {
after(async () => {
await transform.securityCommon.cleanTransformUsers();
await transform.securityCommon.cleanTransformRoles();
await transform.testResources.deleteSavedSearches();
await transform.testResources.deleteIndexPattern('ft_farequote');
await transform.testResources.deleteIndexPattern('ft_ecommerce');
await esArchiver.unload('ml/farequote');
await esArchiver.unload('ml/ecommerce');
await transform.testResources.resetKibanaTimeZone();
});
loadTestFile(require.resolve('./creation_index_pattern'));

View file

@ -2,7 +2,7 @@
"type": "index",
"value": {
"aliases": {},
"index": "categorization_functional_test",
"index": "ft_categorization",
"mappings": {
"properties": {
"@timestamp": {
@ -39,835 +39,3 @@
}
}
}
{
"type": "index",
"value": {
"aliases": {
".kibana": {}
},
"index": ".kibana_1",
"mappings": {
"_meta": {
"migrationMappingPropertyHashes": {
"action": "c0c235fba02ebd2a2412bcda79009b58",
"action_task_params": "a9d49f184ee89641044be0ca2950fa3a",
"alert": "e588043a01d3d43477e7cad7efa0f5d8",
"apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd",
"apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90",
"config": "87aca8fdb053154f11383fce3dbf3edf",
"dashboard": "d00f614b29a80360e1190193fd333bab",
"file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e",
"index-pattern": "66eccb05066c5a89924f48a9e9736499",
"kql-telemetry": "d12a98a6f19a2d273696597547e064ee",
"lens": "21c3ea0763beb1ecb0162529706b88c5",
"lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327",
"map": "23d7aa4a720d4938ccde3983f87bd58d",
"maps-telemetry": "268da3a48066123fc5baf35abaa55014",
"migrationVersion": "4a1746014a75ade3a714e1db5763276f",
"ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9",
"namespace": "2f4316de49999235636386fe51dc06c1",
"query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9",
"references": "7997cf5a56cc02bdc9c93361bde732b0",
"sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4",
"search": "181661168bbadd1eff5902361e2a0d5c",
"server": "ec97f1c5da1a19609a60874e5af1100c",
"space": "c5ca8acafa0beaa4d08d014a97b6bc6b",
"telemetry": "358ffaa88ba34a97d55af0933a117de4",
"timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf",
"tsvb-validation-telemetry": "3a37ef6c8700ae6fc97d5c7da00e9215",
"type": "2f4316de49999235636386fe51dc06c1",
"ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3",
"updated_at": "00da57df13e94e9d98437d13ace4bfe0",
"upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6",
"upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b",
"url": "c7f66a0df8b1b52f17c28c4adb111105",
"visualization": "52d7a13ad68a150c4525b292d23e12cc"
}
},
"dynamic": "strict",
"properties": {
"action": {
"properties": {
"actionTypeId": {
"type": "keyword"
},
"config": {
"enabled": false,
"type": "object"
},
"name": {
"type": "text"
},
"secrets": {
"type": "binary"
}
}
},
"action_task_params": {
"properties": {
"actionId": {
"type": "keyword"
},
"apiKey": {
"type": "binary"
},
"params": {
"enabled": false,
"type": "object"
}
}
},
"alert": {
"properties": {
"actions": {
"properties": {
"actionRef": {
"type": "keyword"
},
"actionTypeId": {
"type": "keyword"
},
"group": {
"type": "keyword"
},
"params": {
"enabled": false,
"type": "object"
}
},
"type": "nested"
},
"alertTypeId": {
"type": "keyword"
},
"apiKey": {
"type": "binary"
},
"apiKeyOwner": {
"type": "keyword"
},
"consumer": {
"type": "keyword"
},
"createdAt": {
"type": "date"
},
"createdBy": {
"type": "keyword"
},
"enabled": {
"type": "boolean"
},
"muteAll": {
"type": "boolean"
},
"mutedInstanceIds": {
"type": "keyword"
},
"name": {
"type": "text"
},
"params": {
"enabled": false,
"type": "object"
},
"schedule": {
"properties": {
"interval": {
"type": "keyword"
}
}
},
"scheduledTaskId": {
"type": "keyword"
},
"tags": {
"type": "keyword"
},
"throttle": {
"type": "keyword"
},
"updatedBy": {
"type": "keyword"
}
}
},
"apm-indices": {
"properties": {
"apm_oss": {
"properties": {
"errorIndices": {
"type": "keyword"
},
"metricsIndices": {
"type": "keyword"
},
"onboardingIndices": {
"type": "keyword"
},
"sourcemapIndices": {
"type": "keyword"
},
"spanIndices": {
"type": "keyword"
},
"transactionIndices": {
"type": "keyword"
}
}
}
}
},
"apm-services-telemetry": {
"properties": {
"has_any_services": {
"type": "boolean"
},
"services_per_agent": {
"properties": {
"dotnet": {
"null_value": 0,
"type": "long"
},
"go": {
"null_value": 0,
"type": "long"
},
"java": {
"null_value": 0,
"type": "long"
},
"js-base": {
"null_value": 0,
"type": "long"
},
"nodejs": {
"null_value": 0,
"type": "long"
},
"python": {
"null_value": 0,
"type": "long"
},
"ruby": {
"null_value": 0,
"type": "long"
},
"rum-js": {
"null_value": 0,
"type": "long"
}
}
}
}
},
"config": {
"dynamic": "true",
"properties": {
"buildNum": {
"type": "keyword"
},
"dateFormat:tz": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"defaultIndex": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"dashboard": {
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"optionsJSON": {
"type": "text"
},
"panelsJSON": {
"type": "text"
},
"refreshInterval": {
"properties": {
"display": {
"type": "keyword"
},
"pause": {
"type": "boolean"
},
"section": {
"type": "integer"
},
"value": {
"type": "integer"
}
}
},
"timeFrom": {
"type": "keyword"
},
"timeRestore": {
"type": "boolean"
},
"timeTo": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"file-upload-telemetry": {
"properties": {
"filesUploadedTotalCount": {
"type": "long"
}
}
},
"index-pattern": {
"properties": {
"fieldFormatMap": {
"type": "text"
},
"fields": {
"type": "text"
},
"intervalName": {
"type": "keyword"
},
"notExpandable": {
"type": "boolean"
},
"sourceFilters": {
"type": "text"
},
"timeFieldName": {
"type": "keyword"
},
"title": {
"type": "text"
},
"type": {
"type": "keyword"
},
"typeMeta": {
"type": "keyword"
}
}
},
"kql-telemetry": {
"properties": {
"optInCount": {
"type": "long"
},
"optOutCount": {
"type": "long"
}
}
},
"lens": {
"properties": {
"expression": {
"index": false,
"type": "keyword"
},
"state": {
"type": "keyword"
},
"title": {
"type": "text"
},
"visualizationType": {
"type": "keyword"
}
}
},
"lens-ui-telemetry": {
"properties": {
"count": {
"type": "integer"
},
"date": {
"type": "date"
},
"name": {
"type": "keyword"
},
"type": {
"type": "keyword"
}
}
},
"map": {
"properties": {
"bounds": {
"type": "geo_shape"
},
"description": {
"type": "text"
},
"layerListJSON": {
"type": "text"
},
"mapStateJSON": {
"type": "text"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"maps-telemetry": {
"properties": {
"attributesPerMap": {
"properties": {
"dataSourcesCount": {
"properties": {
"avg": {
"type": "long"
},
"max": {
"type": "long"
},
"min": {
"type": "long"
}
}
},
"emsVectorLayersCount": {
"dynamic": "true",
"type": "object"
},
"layerTypesCount": {
"dynamic": "true",
"type": "object"
},
"layersCount": {
"properties": {
"avg": {
"type": "long"
},
"max": {
"type": "long"
},
"min": {
"type": "long"
}
}
}
}
},
"indexPatternsWithGeoFieldCount": {
"type": "long"
},
"mapsTotalCount": {
"type": "long"
},
"settings": {
"properties": {
"showMapVisualizationTypes": {
"type": "boolean"
}
}
},
"timeCaptured": {
"type": "date"
}
}
},
"migrationVersion": {
"dynamic": "true",
"properties": {
"index-pattern": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"space": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"ml-telemetry": {
"properties": {
"file_data_visualizer": {
"properties": {
"index_creation_count": {
"type": "long"
}
}
}
}
},
"namespace": {
"type": "keyword"
},
"query": {
"properties": {
"description": {
"type": "text"
},
"filters": {
"enabled": false,
"type": "object"
},
"query": {
"properties": {
"language": {
"type": "keyword"
},
"query": {
"index": false,
"type": "keyword"
}
}
},
"timefilter": {
"enabled": false,
"type": "object"
},
"title": {
"type": "text"
}
}
},
"references": {
"properties": {
"id": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"type": {
"type": "keyword"
}
},
"type": "nested"
},
"sample-data-telemetry": {
"properties": {
"installCount": {
"type": "long"
},
"unInstallCount": {
"type": "long"
}
}
},
"search": {
"properties": {
"columns": {
"type": "keyword"
},
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"sort": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"server": {
"properties": {
"uuid": {
"type": "keyword"
}
}
},
"space": {
"properties": {
"_reserved": {
"type": "boolean"
},
"color": {
"type": "keyword"
},
"description": {
"type": "text"
},
"disabledFeatures": {
"type": "keyword"
},
"imageUrl": {
"index": false,
"type": "text"
},
"initials": {
"type": "keyword"
},
"name": {
"fields": {
"keyword": {
"ignore_above": 2048,
"type": "keyword"
}
},
"type": "text"
}
}
},
"telemetry": {
"properties": {
"enabled": {
"type": "boolean"
},
"lastReported": {
"type": "date"
},
"lastVersionChecked": {
"ignore_above": 256,
"type": "keyword"
},
"sendUsageFrom": {
"ignore_above": 256,
"type": "keyword"
},
"userHasSeenNotice": {
"type": "boolean"
}
}
},
"timelion-sheet": {
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"timelion_chart_height": {
"type": "integer"
},
"timelion_columns": {
"type": "integer"
},
"timelion_interval": {
"type": "keyword"
},
"timelion_other_interval": {
"type": "keyword"
},
"timelion_rows": {
"type": "integer"
},
"timelion_sheet": {
"type": "text"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"tsvb-validation-telemetry": {
"properties": {
"failedRequests": {
"type": "long"
}
}
},
"type": {
"type": "keyword"
},
"ui-metric": {
"properties": {
"count": {
"type": "integer"
}
}
},
"updated_at": {
"type": "date"
},
"upgrade-assistant-reindex-operation": {
"dynamic": "true",
"properties": {
"indexName": {
"type": "keyword"
},
"status": {
"type": "integer"
}
}
},
"upgrade-assistant-telemetry": {
"properties": {
"features": {
"properties": {
"deprecation_logging": {
"properties": {
"enabled": {
"null_value": true,
"type": "boolean"
}
}
}
}
},
"ui_open": {
"properties": {
"cluster": {
"null_value": 0,
"type": "long"
},
"indices": {
"null_value": 0,
"type": "long"
},
"overview": {
"null_value": 0,
"type": "long"
}
}
},
"ui_reindex": {
"properties": {
"close": {
"null_value": 0,
"type": "long"
},
"open": {
"null_value": 0,
"type": "long"
},
"start": {
"null_value": 0,
"type": "long"
},
"stop": {
"null_value": 0,
"type": "long"
}
}
}
}
},
"url": {
"properties": {
"accessCount": {
"type": "long"
},
"accessDate": {
"type": "date"
},
"createDate": {
"type": "date"
},
"url": {
"fields": {
"keyword": {
"ignore_above": 2048,
"type": "keyword"
}
},
"type": "text"
}
}
},
"visualization": {
"properties": {
"description": {
"type": "text"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"savedSearchRefName": {
"type": "keyword"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
},
"visState": {
"type": "text"
}
}
}
}
},
"settings": {
"index": {
"auto_expand_replicas": "0-1",
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -30,3 +30,4 @@ export { MachineLearningSecurityCommonProvider } from './security_common';
export { MachineLearningSecurityUIProvider } from './security_ui';
export { MachineLearningSettingsProvider } from './settings';
export { MachineLearningSingleMetricViewerProvider } from './single_metric_viewer';
export { MachineLearningTestResourcesProvider } from './test_resources';

View file

@ -0,0 +1,219 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { ProvidedType } from '@kbn/test/types/ftr';
import { savedSearches } from './test_resources_data';
import { FtrProviderContext } from '../../ftr_provider_context';
const COMMON_HEADERS = {
'kbn-xsrf': 'some-xsrf-token',
};
export enum SavedObjectType {
CONFIG = 'config',
DASHBOARD = 'dashboard',
INDEX_PATTERN = 'index-pattern',
SEARCH = 'search',
VISUALIZATION = 'visualization',
}
export type MlTestResourcesi = ProvidedType<typeof MachineLearningTestResourcesProvider>;
export function MachineLearningTestResourcesProvider({ getService }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const log = getService('log');
const supertest = getService('supertest');
return {
async setKibanaTimeZoneToUTC() {
await kibanaServer.uiSettings.update({
'dateFormat:tz': 'UTC',
});
},
async resetKibanaTimeZone() {
await kibanaServer.uiSettings.unset('dateFormat:tz');
},
async savedObjectExists(id: string, objectType: SavedObjectType): Promise<boolean> {
const response = await supertest.get(`/api/saved_objects/${objectType}/${id}`);
return response.status === 200;
},
async getSavedObjectIdByTitle(
title: string,
objectType: SavedObjectType
): Promise<string | undefined> {
log.debug(`Searching for '${objectType}' with title '${title}'...`);
const findResponse = await supertest
.get(`/api/saved_objects/_find?type=${objectType}`)
.set(COMMON_HEADERS)
.expect(200)
.then((res: any) => res.body);
for (const savedObject of findResponse.saved_objects) {
const objectTitle = savedObject.attributes.title;
if (objectTitle === title) {
log.debug(` > Found '${savedObject.id}'`);
return savedObject.id;
}
}
log.debug(` > Not found`);
},
async getIndexPatternId(title: string): Promise<string | undefined> {
return this.getSavedObjectIdByTitle(title, SavedObjectType.INDEX_PATTERN);
},
async getSavedSearchId(title: string): Promise<string | undefined> {
return this.getSavedObjectIdByTitle(title, SavedObjectType.SEARCH);
},
async createIndexPattern(title: string, timeFieldName?: string): Promise<string> {
log.debug(
`Creating index pattern with title '${title}'${
timeFieldName !== undefined ? ` and time field '${timeFieldName}'` : ''
}`
);
const createResponse = await supertest
.post(`/api/saved_objects/${SavedObjectType.INDEX_PATTERN}`)
.set(COMMON_HEADERS)
.send({ attributes: { title, timeFieldName } })
.expect(200)
.then((res: any) => res.body);
log.debug(` > Created with id '${createResponse.id}'`);
return createResponse.id;
},
async createIndexPatternIfNeeded(title: string, timeFieldName?: string): Promise<string> {
const indexPatternId = await this.getIndexPatternId(title);
if (indexPatternId !== undefined) {
log.debug(`Index pattern with title '${title}' already exists. Nothing to create.`);
return indexPatternId;
} else {
return await this.createIndexPattern(title, timeFieldName);
}
},
async createSavedSearch(title: string, body: object): Promise<string> {
log.debug(`Creating saved search with title '${title}'`);
const createResponse = await supertest
.post(`/api/saved_objects/${SavedObjectType.SEARCH}`)
.set(COMMON_HEADERS)
.send(body)
.expect(200)
.then((res: any) => res.body);
log.debug(` > Created with id '${createResponse.id}'`);
return createResponse.id;
},
async createSavedSearchIfNeeded(savedSearch: any): Promise<string> {
const title = savedSearch.requestBody.attributes.title;
const savedSearchId = await this.getSavedSearchId(title);
if (savedSearchId !== undefined) {
log.debug(`Saved search with title '${title}' already exists. Nothing to create.`);
return savedSearchId;
} else {
const body = await this.updateSavedSearchRequestBody(
savedSearch.requestBody,
savedSearch.indexPatternTitle
);
return await this.createSavedSearch(title, body);
}
},
async updateSavedSearchRequestBody(body: object, indexPatternTitle: string): Promise<object> {
const indexPatternId = await this.getIndexPatternId(indexPatternTitle);
if (indexPatternId === undefined) {
throw new Error(
`Index pattern '${indexPatternTitle}' to base saved search on does not exist. `
);
}
// inject index pattern id
const updatedBody = JSON.parse(JSON.stringify(body), (_key, value) => {
if (value === 'INDEX_PATTERN_ID_PLACEHOLDER') {
return indexPatternId;
} else {
return value;
}
});
// make searchSourceJSON node a string
const searchSourceJsonNode = updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON;
const searchSourceJsonString = JSON.stringify(searchSourceJsonNode);
updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON = searchSourceJsonString;
return updatedBody;
},
async createSavedSearchFarequoteFilterIfNeeded() {
await this.createSavedSearchIfNeeded(savedSearches.farequoteFilter);
},
async createSavedSearchFarequoteLuceneIfNeeded() {
await this.createSavedSearchIfNeeded(savedSearches.farequoteLucene);
},
async createSavedSearchFarequoteKueryIfNeeded() {
await this.createSavedSearchIfNeeded(savedSearches.farequoteKuery);
},
async createSavedSearchFarequoteFilterAndLuceneIfNeeded() {
await this.createSavedSearchIfNeeded(savedSearches.farequoteFilterAndLucene);
},
async createSavedSearchFarequoteFilterAndKueryIfNeeded() {
await this.createSavedSearchIfNeeded(savedSearches.farequoteFilterAndKuery);
},
async deleteIndexPattern(title: string) {
log.debug(`Deleting index pattern with title '${title}'...`);
const indexPatternId = await this.getIndexPatternId(title);
if (indexPatternId === undefined) {
log.debug(`Index pattern with title '${title}' does not exists. Nothing to delete.`);
return;
} else {
await supertest
.delete(`/api/saved_objects/${SavedObjectType.INDEX_PATTERN}/${indexPatternId}`)
.set(COMMON_HEADERS)
.expect(200);
log.debug(` > Deleted index pattern with id '${indexPatternId}'`);
}
},
async deleteSavedSearch(title: string) {
log.debug(`Deleting saved search with title '${title}'...`);
const savedSearchId = await this.getSavedSearchId(title);
if (savedSearchId === undefined) {
log.debug(`Saved search with title '${title}' does not exists. Nothing to delete.`);
return;
} else {
await supertest
.delete(`/api/saved_objects/${SavedObjectType.SEARCH}/${savedSearchId}`)
.set(COMMON_HEADERS)
.expect(200);
log.debug(` > Deleted saved searchwith id '${savedSearchId}'`);
}
},
async deleteSavedSearches() {
for (const search of Object.values(savedSearches)) {
await this.deleteSavedSearch(search.requestBody.attributes.title);
}
},
};
}

View file

@ -0,0 +1,249 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
export const savedSearches = {
farequoteFilter: {
indexPatternTitle: 'ft_farequote',
requestBody: {
attributes: {
title: 'ft_farequote_filter',
description: '',
hits: 0,
columns: ['_source'],
sort: ['@timestamp', 'desc'],
version: 1,
kibanaSavedObjectMeta: {
searchSourceJSON: {
highlightAll: true,
version: true,
query: {
query: '',
language: 'lucene',
},
filter: [
{
meta: {
index: 'INDEX_PATTERN_ID_PLACEHOLDER',
negate: false,
disabled: false,
alias: null,
type: 'phrase',
key: 'airline',
value: 'ASA',
params: {
query: 'ASA',
type: 'phrase',
},
},
query: {
match: {
airline: {
query: 'ASA',
type: 'phrase',
},
},
},
$state: {
store: 'appState',
},
},
],
indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index',
},
},
},
references: [
{
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
type: 'index-pattern',
id: 'INDEX_PATTERN_ID_PLACEHOLDER',
},
],
},
},
farequoteLucene: {
indexPatternTitle: 'ft_farequote',
requestBody: {
attributes: {
title: 'ft_farequote_lucene',
description: '',
hits: 0,
columns: ['_source'],
sort: ['@timestamp', 'desc'],
version: 1,
kibanaSavedObjectMeta: {
searchSourceJSON: {
highlightAll: true,
version: true,
query: {
query: 'airline:A*',
language: 'lucene',
},
filter: [],
indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index',
},
},
},
references: [
{
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
type: 'index-pattern',
id: 'INDEX_PATTERN_ID_PLACEHOLDER',
},
],
},
},
farequoteKuery: {
indexPatternTitle: 'ft_farequote',
requestBody: {
attributes: {
title: 'ft_farequote_kuery',
description: '',
hits: 0,
columns: ['_source'],
sort: ['@timestamp', 'desc'],
version: 1,
kibanaSavedObjectMeta: {
searchSourceJSON: {
highlightAll: true,
version: true,
query: {
query: 'airline: A* and responsetime > 5',
language: 'kuery',
},
filter: [],
indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index',
},
},
},
references: [
{
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
type: 'index-pattern',
id: 'INDEX_PATTERN_ID_PLACEHOLDER',
},
],
},
},
farequoteFilterAndLucene: {
indexPatternTitle: 'ft_farequote',
requestBody: {
attributes: {
title: 'ft_farequote_filter_and_lucene',
description: '',
hits: 0,
columns: ['_source'],
sort: ['@timestamp', 'desc'],
version: 1,
kibanaSavedObjectMeta: {
searchSourceJSON: {
highlightAll: true,
version: true,
query: {
query: 'responsetime:>50',
language: 'lucene',
},
filter: [
{
meta: {
index: 'INDEX_PATTERN_ID_PLACEHOLDER',
negate: false,
disabled: false,
alias: null,
type: 'phrase',
key: 'airline',
value: 'ASA',
params: {
query: 'ASA',
type: 'phrase',
},
},
query: {
match: {
airline: {
query: 'ASA',
type: 'phrase',
},
},
},
$state: {
store: 'appState',
},
},
],
indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index',
},
},
},
references: [
{
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
type: 'index-pattern',
id: 'INDEX_PATTERN_ID_PLACEHOLDER',
},
],
},
},
farequoteFilterAndKuery: {
indexPatternTitle: 'ft_farequote',
requestBody: {
attributes: {
title: 'ft_farequote_filter_and_kuery',
description: '',
hits: 0,
columns: ['_source'],
sort: ['@timestamp', 'desc'],
version: 1,
kibanaSavedObjectMeta: {
searchSourceJSON: {
highlightAll: true,
version: true,
query: {
query: 'responsetime > 49',
language: 'kuery',
},
filter: [
{
meta: {
index: 'INDEX_PATTERN_ID_PLACEHOLDER',
negate: false,
disabled: false,
alias: null,
type: 'phrase',
key: 'airline',
value: 'ASA',
params: {
query: 'ASA',
type: 'phrase',
},
},
query: {
match: {
airline: {
query: 'ASA',
type: 'phrase',
},
},
},
$state: {
store: 'appState',
},
},
],
indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index',
},
},
},
references: [
{
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
type: 'index-pattern',
id: 'INDEX_PATTERN_ID_PLACEHOLDER',
},
],
},
},
};

View file

@ -33,6 +33,7 @@ import {
MachineLearningSecurityUIProvider,
MachineLearningSettingsProvider,
MachineLearningSingleMetricViewerProvider,
MachineLearningTestResourcesProvider,
} from './machine_learning';
export function MachineLearningProvider(context: FtrProviderContext) {
@ -67,6 +68,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const securityUI = MachineLearningSecurityUIProvider(context, securityCommon);
const settings = MachineLearningSettingsProvider(context);
const singleMetricViewer = MachineLearningSingleMetricViewerProvider(context);
const testResources = MachineLearningTestResourcesProvider(context);
return {
anomaliesTable,
@ -95,5 +97,6 @@ export function MachineLearningProvider(context: FtrProviderContext) {
securityUI,
settings,
singleMetricViewer,
testResources,
};
}

View file

@ -17,6 +17,8 @@ import {
TransformWizardProvider,
} from './transform_ui';
import { MachineLearningTestResourcesProvider } from './machine_learning';
export function TransformProvider(context: FtrProviderContext) {
const api = TransformAPIProvider(context);
const management = TransformManagementProvider(context);
@ -25,6 +27,7 @@ export function TransformProvider(context: FtrProviderContext) {
const securityUI = TransformSecurityUIProvider(context, securityCommon);
const sourceSelection = TransformSourceSelectionProvider(context);
const table = TransformTableProvider(context);
const testResources = MachineLearningTestResourcesProvider(context);
const wizard = TransformWizardProvider(context);
return {
@ -35,6 +38,7 @@ export function TransformProvider(context: FtrProviderContext) {
securityUI,
sourceSelection,
table,
testResources,
wizard,
};
}