Skip to content

Commit

Permalink
[ML] Rename index pattern references to data view. (#171627)
Browse files Browse the repository at this point in the history
Renames references to index pattern to data views.

- Updates references in `data-test-subj` attributes for data frame
analytics.
- Renames methods in the ` ml.testResources` service used in tests.
- `IndexPattern` references in testing code referring to single indices
were renamed to use `IndexName`. For variable names still using
`IndexPattern` they were prefixed with e.g. `esIndexPattern` to avoid
ambiguity with the legacy data view name.

Note there are still references in the state management code of the data
frame analytics creation wizard, this wasn't picked up in this PR since
it focuses mostly on test related code.
  • Loading branch information
walterra authored Nov 23, 2023
1 parent 358cff4 commit 11acc02
Show file tree
Hide file tree
Showing 102 changed files with 396 additions and 426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const CreateStep: FC<Props> = ({ actions, state, step }) => {
>
<EuiCheckbox
disabled={isJobCreated || canCreateDataView === false}
name="mlDataFrameAnalyticsCreateIndexPattern"
name="mlDataFrameAnalyticsCreateDataView"
id={'dataframe-create-data-view-checkbox'}
label={i18n.translate(
'xpack.ml.dataframe.analytics.create.createDataViewLabel',
Expand All @@ -173,7 +173,7 @@ export const CreateStep: FC<Props> = ({ actions, state, step }) => {
)}
checked={createIndexPattern === true}
onChange={() => setFormState({ createIndexPattern: !createIndexPattern })}
data-test-subj="mlAnalyticsCreateJobWizardCreateIndexPatternCheckbox"
data-test-subj="mlAnalyticsCreateJobWizardCreateDataViewCheckbox"
/>
</EuiFormRow>
</EuiFlexItem>
Expand Down
34 changes: 17 additions & 17 deletions x-pack/test/accessibility/apps/ml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export default function ({ getService }: FtrProviderContext) {

describe('with data loaded', function () {
const dfaOutlierResultsJobId = 'iph_outlier_a11y';
const ecIndexPattern = 'ft_module_sample_ecommerce';
const ihpIndexPattern = 'ft_ihp_outlier';
const egsIndexPattern = 'ft_egs_regression';
const bmIndexPattern = 'ft_bank_marketing';
const ecIndexName = 'ft_module_sample_ecommerce';
const ihpIndexName = 'ft_ihp_outlier';
const egsIndexName = 'ft_egs_regression';
const bmIndexName = 'ft_bank_marketing';
const ecExpectedTotalCount = '287';

const dfaOutlierJobType = 'outlier_detection';
Expand All @@ -78,10 +78,10 @@ export default function ({ getService }: FtrProviderContext) {
await esArchiver.loadIfNeeded(
'x-pack/test/functional/es_archives/ml/module_sample_ecommerce'
);
await ml.testResources.createIndexPatternIfNeeded(ihpIndexPattern);
await ml.testResources.createIndexPatternIfNeeded(egsIndexPattern);
await ml.testResources.createIndexPatternIfNeeded(bmIndexPattern);
await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date');
await ml.testResources.createDataViewIfNeeded(ihpIndexName);
await ml.testResources.createDataViewIfNeeded(egsIndexName);
await ml.testResources.createDataViewIfNeeded(bmIndexName);
await ml.testResources.createDataViewIfNeeded(ecIndexName, 'order_date');
await ml.testResources.setKibanaTimeZoneToUTC();

await ml.api.createAndRunDFAJob(
Expand All @@ -93,10 +93,10 @@ export default function ({ getService }: FtrProviderContext) {
await ml.api.cleanMlIndices();
await ml.api.deleteIndices(`user-${dfaOutlierResultsJobId}`);

await ml.testResources.deleteIndexPatternByTitle(ihpIndexPattern);
await ml.testResources.deleteIndexPatternByTitle(egsIndexPattern);
await ml.testResources.deleteIndexPatternByTitle(bmIndexPattern);
await ml.testResources.deleteIndexPatternByTitle(ecIndexPattern);
await ml.testResources.deleteDataViewByTitle(ihpIndexName);
await ml.testResources.deleteDataViewByTitle(egsIndexName);
await ml.testResources.deleteDataViewByTitle(bmIndexName);
await ml.testResources.deleteDataViewByTitle(ecIndexName);
await esArchiver.unload('x-pack/test/functional/es_archives/ml/ihp_outlier');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/egs_regression');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/bm_classification');
Expand Down Expand Up @@ -134,7 +134,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testExecution.logTestStep(
'job creation selects the source data and loads the DFA job wizard page'
);
await ml.jobSourceSelection.selectSourceForAnalyticsJob(ihpIndexPattern);
await ml.jobSourceSelection.selectSourceForAnalyticsJob(ihpIndexName);
await ml.dataFrameAnalyticsCreation.assertConfigurationStepActive();
await a11y.testAppSnapshot();
});
Expand Down Expand Up @@ -180,7 +180,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.navigation.navigateToMl();
await ml.navigation.navigateToDataFrameAnalytics();
await ml.dataFrameAnalytics.startAnalyticsCreation();
await ml.jobSourceSelection.selectSourceForAnalyticsJob(egsIndexPattern);
await ml.jobSourceSelection.selectSourceForAnalyticsJob(egsIndexName);
await ml.dataFrameAnalyticsCreation.assertConfigurationStepActive();
await ml.testExecution.logTestStep('selects the regression job type');
await ml.dataFrameAnalyticsCreation.assertJobTypeSelectExists();
Expand Down Expand Up @@ -227,7 +227,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.navigation.navigateToMl();
await ml.navigation.navigateToDataFrameAnalytics();
await ml.dataFrameAnalytics.startAnalyticsCreation();
await ml.jobSourceSelection.selectSourceForAnalyticsJob(bmIndexPattern);
await ml.jobSourceSelection.selectSourceForAnalyticsJob(bmIndexName);
await ml.dataFrameAnalyticsCreation.assertConfigurationStepActive();
await ml.testExecution.logTestStep('selects the classification job type');
await ml.dataFrameAnalyticsCreation.assertJobTypeSelectExists();
Expand Down Expand Up @@ -275,12 +275,12 @@ export default function ({ getService }: FtrProviderContext) {
});

it('index data visualizer select index pattern page', async () => {
await ml.dataVisualizer.navigateToIndexPatternSelection();
await ml.dataVisualizer.navigateToDataViewSelection();
await a11y.testAppSnapshot();
});

it('index data visualizer page for selected index', async () => {
await ml.jobSourceSelection.selectSourceForIndexBasedDataVisualizer(ecIndexPattern);
await ml.jobSourceSelection.selectSourceForIndexBasedDataVisualizer(ecIndexName);

await ml.testExecution.logTestStep('should display the time range step');
await ml.dataVisualizerIndexBased.assertTimeRangeSelectorSectionExists();
Expand Down
39 changes: 17 additions & 22 deletions x-pack/test/accessibility/apps/ml_anomaly_detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export default function ({ getService }: FtrProviderContext) {
const eventDescription = 'calendar_event_a11y';
const filterId = 'filter_a11y';
const filterItems = ['filter_item_a11y'];
const fqIndexPattern = 'ft_farequote';
const ecIndexPattern = 'ft_module_sample_ecommerce';
const fqIndexName = 'ft_farequote';
const ecIndexName = 'ft_module_sample_ecommerce';

const categorizationIndexPattern = 'ft_categorization_small';
const categorizationIndexName = 'ft_categorization_small';

const adJobAggAndFieldIdentifier = 'Mean(responsetime)';
const adJobBucketSpan = '30m';
Expand All @@ -87,12 +87,12 @@ export default function ({ getService }: FtrProviderContext) {

const advancedJobTestData = {
suiteTitle: 'with multiple metric detectors and custom datafeed settings',
jobSource: ecIndexPattern,
jobSource: ecIndexName,
jobId: `ec_advanced_1_${Date.now()}`,
get jobIdClone(): string {
return `${this.jobId}_clone`;
},
jobDescription: `Create advanced job from ${ecIndexPattern} dataset with multiple metric detectors and custom datafeed settings`,
jobDescription: `Create advanced job from ${ecIndexName} dataset with multiple metric detectors and custom datafeed settings`,
jobGroups: ['automated', 'ecommerce', 'advanced'],
get jobGroupsClone(): string[] {
return [...this.jobGroups, 'clone'];
Expand Down Expand Up @@ -149,7 +149,7 @@ export default function ({ getService }: FtrProviderContext) {
};
const populationJobTestData = {
suiteTitle: 'population job',
jobSource: ecIndexPattern,
jobSource: ecIndexName,
jobId: `ec_population_1_${Date.now()}`,
get jobIdClone(): string {
return `${this.jobId}_clone`;
Expand Down Expand Up @@ -201,12 +201,9 @@ export default function ({ getService }: FtrProviderContext) {
await esArchiver.loadIfNeeded(
'x-pack/test/functional/es_archives/ml/categorization_small'
);
await ml.testResources.createIndexPatternIfNeeded(fqIndexPattern, '@timestamp');
await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date');
await ml.testResources.createIndexPatternIfNeeded(
'ft_categorization_small',
'@timestamp'
);
await ml.testResources.createDataViewIfNeeded(fqIndexName, '@timestamp');
await ml.testResources.createDataViewIfNeeded(ecIndexName, 'order_date');
await ml.testResources.createDataViewIfNeeded('ft_categorization_small', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();

await ml.api.createAndRunAnomalyDetectionLookbackJob(
Expand Down Expand Up @@ -238,9 +235,9 @@ export default function ({ getService }: FtrProviderContext) {
await ml.api.deleteCalendar(calendarId);
await ml.api.deleteFilter(filterId);

await ml.testResources.deleteIndexPatternByTitle(fqIndexPattern);
await ml.testResources.deleteIndexPatternByTitle(ecIndexPattern);
await ml.testResources.deleteIndexPatternByTitle(categorizationIndexPattern);
await ml.testResources.deleteDataViewByTitle(fqIndexName);
await ml.testResources.deleteDataViewByTitle(ecIndexName);
await ml.testResources.deleteDataViewByTitle(categorizationIndexName);
await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_ecommerce');
await esArchiver.unload('x-pack/test/functional/es_archives/ml/categorization_small');
Expand All @@ -259,7 +256,7 @@ export default function ({ getService }: FtrProviderContext) {
});

it('anomaly detection create job select type page', async () => {
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(fqIndexPattern);
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(fqIndexName);
await a11y.testAppSnapshot();
});

Expand Down Expand Up @@ -308,7 +305,7 @@ export default function ({ getService }: FtrProviderContext) {
// as the other steps have already been tested for the single metric job
await ml.navigation.navigateToAnomalyDetection();
await ml.jobManagement.navigateToNewJobSourceSelection();
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(fqIndexPattern);
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(fqIndexName);
await ml.jobTypeSelection.selectMultiMetricJob();
await ml.testExecution.logTestStep('job creation set the time range');
await ml.jobWizardCommon.clickUseFullDataButton(
Expand Down Expand Up @@ -442,7 +439,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.navigation.navigateToJobManagement();
await ml.jobManagement.navigateToNewJobSourceSelection();

await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(ecIndexPattern);
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(ecIndexName);

await ml.testExecution.logTestStep('job creation loads the population job wizard page');
await ml.jobTypeSelection.selectPopulationJob();
Expand Down Expand Up @@ -509,9 +506,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.navigation.navigateToJobManagement();
await ml.jobManagement.navigateToNewJobSourceSelection();

await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(
categorizationIndexPattern
);
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(categorizationIndexName);

await ml.testExecution.logTestStep(
'job creation loads the categorization job wizard page'
Expand Down Expand Up @@ -566,7 +561,7 @@ export default function ({ getService }: FtrProviderContext) {
it('anomaly detection create job from data recognizer module open wizard', async () => {
await ml.navigation.navigateToJobManagement();
await ml.jobManagement.navigateToNewJobSourceSelection();
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(ecIndexPattern);
await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob(ecIndexName);
await ml.testExecution.logTestStep(
`job creation loads the data recognizer job wizard page for the ${adRecognizerJobModuleId} module`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.securityCommon.createMlUsers();

await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.createDataViewIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});
Expand Down
14 changes: 7 additions & 7 deletions x-pack/test/accessibility/apps/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function ({ getService }: FtrProviderContext) {
});

describe('with data loaded', function () {
const ecIndexPattern = 'ft_ecommerce';
const ecIndexName = 'ft_ecommerce';

const pivotGroupByEntries = [
{
Expand Down Expand Up @@ -85,17 +85,17 @@ export default function ({ getService }: FtrProviderContext) {

before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce');
await transform.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date');
await transform.testResources.createDataViewIfNeeded(ecIndexName, 'order_date');
await transform.testResources.setKibanaTimeZoneToUTC();
});

after(async () => {
await transform.api.cleanTransformIndices();
await transform.api.deleteIndices(pivotTransformDestinationIndex);
await transform.api.deleteIndices(latestTransformDestinationIndex);
await transform.testResources.deleteIndexPatternByTitle(pivotTransformDestinationIndex);
await transform.testResources.deleteIndexPatternByTitle(latestTransformDestinationIndex);
await transform.testResources.deleteIndexPatternByTitle(ecIndexPattern);
await transform.testResources.deleteDataViewByTitle(pivotTransformDestinationIndex);
await transform.testResources.deleteDataViewByTitle(latestTransformDestinationIndex);
await transform.testResources.deleteDataViewByTitle(ecIndexName);
await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce');
await transform.testResources.resetKibanaTimeZone();
});
Expand All @@ -110,7 +110,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.testExecution.logTestStep(
'transform creation selects the source data and loads the Transform wizard page'
);
await transform.sourceSelection.selectSource(ecIndexPattern);
await transform.sourceSelection.selectSource(ecIndexName);

await transform.testExecution.logTestStep(
`sets the date picker to the default '15 minutes ago'`
Expand Down Expand Up @@ -201,7 +201,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.testExecution.logTestStep(
'selects the source data and loads the Transform wizard page'
);
await transform.sourceSelection.selectSource(ecIndexPattern);
await transform.sourceSelection.selectSource(ecIndexName);

await transform.testExecution.logTestStep(
`sets the date picker to the default '15 minutes ago'`
Expand Down
24 changes: 12 additions & 12 deletions x-pack/test/api_integration/apis/ml/data_frame_analytics/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default ({ getService }: FtrProviderContext) => {
const testJobConfigs: Array<DeepPartial<DataFrameAnalyticsConfig>> = [
'Test delete job only',
'Test delete job and target index',
'Test delete job and index pattern',
'Test delete job, target index, and index pattern',
'Test delete job and data view',
'Test delete job, target index, and data view',
].map((description, idx) => {
const analyticsId = `${jobId}_${idx + 1}`;
return {
Expand Down Expand Up @@ -159,15 +159,15 @@ export default ({ getService }: FtrProviderContext) => {
const destinationIndex = generateDestinationIndex(analyticsId);

before(async () => {
// Mimic real job by creating index pattern after job is created
await ml.testResources.createIndexPatternIfNeeded(destinationIndex);
// Mimic real job by creating data view after job is created
await ml.testResources.createDataViewIfNeeded(destinationIndex);
});

after(async () => {
await ml.testResources.deleteIndexPatternByTitle(destinationIndex);
await ml.testResources.deleteDataViewByTitle(destinationIndex);
});

it('should delete job and index pattern by id', async () => {
it('should delete job and data view by id', async () => {
const { body, status } = await supertest
.delete(`/internal/ml/data_frame/analytics/${analyticsId}`)
.query({ deleteDestIndexPattern: true })
Expand All @@ -179,7 +179,7 @@ export default ({ getService }: FtrProviderContext) => {
expect(body.destIndexDeleted.success).to.eql(false);
expect(body.destIndexPatternDeleted.success).to.eql(true);
await ml.api.waitForDataFrameAnalyticsJobNotToExist(analyticsId);
await ml.testResources.assertIndexPatternNotExist(destinationIndex);
await ml.testResources.assertDataViewNotExist(destinationIndex);
});
});

Expand All @@ -188,18 +188,18 @@ export default ({ getService }: FtrProviderContext) => {
const destinationIndex = generateDestinationIndex(analyticsId);

before(async () => {
// Mimic real job by creating target index & index pattern after DFA job is created
// Mimic real job by creating target index & data view after DFA job is created
await ml.api.createIndex(destinationIndex);
await ml.api.assertIndicesExist(destinationIndex);
await ml.testResources.createIndexPatternIfNeeded(destinationIndex);
await ml.testResources.createDataViewIfNeeded(destinationIndex);
});

after(async () => {
await ml.api.deleteIndices(destinationIndex);
await ml.testResources.deleteIndexPatternByTitle(destinationIndex);
await ml.testResources.deleteDataViewByTitle(destinationIndex);
});

it('should delete job, target index, and index pattern by id', async () => {
it('should delete job, target index, and data view by id', async () => {
const { body, status } = await supertest
.delete(`/internal/ml/data_frame/analytics/${analyticsId}`)
.query({ deleteDestIndex: true, deleteDestIndexPattern: true })
Expand All @@ -212,7 +212,7 @@ export default ({ getService }: FtrProviderContext) => {
expect(body.destIndexPatternDeleted.success).to.eql(true);
await ml.api.waitForDataFrameAnalyticsJobNotToExist(analyticsId);
await ml.api.assertIndicesNotToExist(destinationIndex);
await ml.testResources.assertIndexPatternNotExist(destinationIndex);
await ml.testResources.assertDataViewNotExist(destinationIndex);
});
});
});
Expand Down
Loading

0 comments on commit 11acc02

Please sign in to comment.