Skip to content

Commit

Permalink
[ML] Add functional tests for Transform start/delete (#92314)
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 authored Feb 24, 2021
1 parent 0d486ae commit 96e34d9
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const DeleteActionModal: FC<DeleteAction> = ({

return (
<EuiConfirmModal
data-test-subj="transformDeleteModal"
title={isBulkAction === true ? bulkDeleteModalTitle : deleteModalTitle}
onCancel={closeModal}
onConfirm={deleteAndCloseModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const StartActionModal: FC<StartAction> = ({ closeModal, items, startAndC

return (
<EuiConfirmModal
data-test-subj="transformStartModal"
title={isBulkAction === true ? bulkStartModalTitle : startModalTitle}
onCancel={closeModal}
onConfirm={startAndCloseModal}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/transform/cloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.table.filterWithSearchString(testData.originalConfig.id, 1);

await transform.testExecution.logTestStep('should show the actions popover');
await transform.table.assertTransformRowActions(false);
await transform.table.assertTransformRowActions(testData.originalConfig.id, false);

await transform.testExecution.logTestStep('should display the define pivot step');
await transform.table.clickTransformRowAction('Clone');
Expand Down
136 changes: 136 additions & 0 deletions x-pack/test/functional/apps/transform/deleting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { TRANSFORM_STATE } from '../../../../plugins/transform/common/constants';

import { FtrProviderContext } from '../../ftr_provider_context';
import { getLatestTransformConfig, getPivotTransformConfig } from './index';

export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const transform = getService('transform');

describe('deleting', function () {
const PREFIX = 'deleting';

const testDataList = [
{
suiteTitle: 'batch transform with pivot configuration',
originalConfig: getPivotTransformConfig(PREFIX, false),
expected: {
row: {
status: TRANSFORM_STATE.STOPPED,
mode: 'batch',
progress: 100,
},
},
},
{
suiteTitle: 'continuous transform with pivot configuration',
originalConfig: getPivotTransformConfig(PREFIX, true),
expected: {
row: {
status: TRANSFORM_STATE.STOPPED,
mode: 'continuous',
progress: undefined,
},
},
},
{
suiteTitle: 'batch transform with latest configuration',
originalConfig: getLatestTransformConfig(PREFIX),
transformDescription: 'updated description',
transformDocsPerSecond: '1000',
transformFrequency: '10m',
expected: {
messageText: 'updated transform.',
row: {
status: TRANSFORM_STATE.STOPPED,
mode: 'batch',
progress: 100,
},
},
},
];

before(async () => {
await esArchiver.loadIfNeeded('ml/ecommerce');
await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');

for (const testData of testDataList) {
await transform.api.createAndRunTransform(
testData.originalConfig.id,
testData.originalConfig
);
}

await transform.testResources.setKibanaTimeZoneToUTC();
await transform.securityUI.loginAsTransformPowerUser();
});

after(async () => {
for (const testData of testDataList) {
await transform.testResources.deleteIndexPatternByTitle(testData.originalConfig.dest.index);
await transform.api.deleteIndices(testData.originalConfig.dest.index);
}
await transform.api.cleanTransformIndices();
});

for (const testData of testDataList) {
describe(`${testData.suiteTitle}`, function () {
it('delete transform', async () => {
await transform.testExecution.logTestStep('should load the home page');
await transform.navigation.navigateTo();
await transform.management.assertTransformListPageExists();

await transform.testExecution.logTestStep('should display the transforms table');
await transform.management.assertTransformsTableExists();

if (testData.expected.row.mode === 'continuous') {
await transform.testExecution.logTestStep('should have the delete action disabled');
await transform.table.assertTransformRowActionEnabled(
testData.originalConfig.id,
'Delete',
false
);

await transform.testExecution.logTestStep('should stop the transform');
await transform.table.clickTransformRowActionWithRetry(
testData.originalConfig.id,
'Stop'
);
}

await transform.testExecution.logTestStep('should display the stopped transform');
await transform.table.assertTransformRowFields(testData.originalConfig.id, {
id: testData.originalConfig.id,
description: testData.originalConfig.description,
status: testData.expected.row.status,
mode: testData.expected.row.mode,
progress: testData.expected.row.progress,
});

await transform.testExecution.logTestStep('should show the delete modal');
await transform.table.assertTransformRowActionEnabled(
testData.originalConfig.id,
'Delete',
true
);
await transform.table.clickTransformRowActionWithRetry(
testData.originalConfig.id,
'Delete'
);
await transform.table.assertTransformDeleteModalExists();

await transform.testExecution.logTestStep('should delete the transform');
await transform.table.confirmDeleteTransform();
await transform.table.assertTransformRowNotExists(testData.originalConfig.id);
});
});
}
});
}
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/transform/editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.table.filterWithSearchString(testData.originalConfig.id, 1);

await transform.testExecution.logTestStep('should show the actions popover');
await transform.table.assertTransformRowActions(false);
await transform.table.assertTransformRowActions(testData.originalConfig.id, false);

await transform.testExecution.logTestStep('should show the edit flyout');
await transform.table.clickTransformRowAction('Edit');
Expand Down
39 changes: 35 additions & 4 deletions x-pack/test/functional/apps/transform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
*/

import { FtrProviderContext } from '../../ftr_provider_context';
import { TransformLatestConfig } from '../../../../plugins/transform/common/types/transform';
import {
TransformLatestConfig,
TransformPivotConfig,
} from '../../../../plugins/transform/common/types/transform';

export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
Expand Down Expand Up @@ -41,6 +44,8 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./cloning'));
loadTestFile(require.resolve('./editing'));
loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./deleting'));
loadTestFile(require.resolve('./starting'));
});
}
export interface ComboboxOption {
Expand Down Expand Up @@ -80,20 +85,46 @@ export function isLatestTransformTestData(arg: any): arg is LatestTransformTestD
return arg.type === 'latest';
}

export function getLatestTransformConfig(): TransformLatestConfig {
export function getPivotTransformConfig(
prefix: string,
continuous?: boolean
): TransformPivotConfig {
const timestamp = Date.now();
return {
id: `ec_cloning_2_${timestamp}`,
id: `ec_${prefix}_pivot_${timestamp}_${continuous ? 'cont' : 'batch'}`,
source: { index: ['ft_ecommerce'] },
pivot: {
group_by: { category: { terms: { field: 'category.keyword' } } },
aggregations: { 'products.base_price.avg': { avg: { field: 'products.base_price' } } },
},
description: `ecommerce ${
continuous ? 'continuous' : 'batch'
} transform with avg(products.base_price) grouped by terms(category.keyword)`,
dest: { index: `user-ec_2_${timestamp}` },
...(continuous ? { sync: { time: { field: 'order_date', delay: '60s' } } } : {}),
};
}

export function getLatestTransformConfig(
prefix: string,
continuous?: boolean
): TransformLatestConfig {
const timestamp = Date.now();
return {
id: `ec_${prefix}_latest_${timestamp}_${continuous ? 'cont' : 'batch'}`,
source: { index: ['ft_ecommerce'] },
latest: {
unique_key: ['category.keyword'],
sort: 'order_date',
},
description: 'ecommerce batch transform with category unique key and sorted by order date',
description: `ecommerce ${
continuous ? 'continuous' : 'batch'
} transform with category unique key and sorted by order date`,
frequency: '3s',
settings: {
max_page_search_size: 250,
},
dest: { index: `user-ec_3_${timestamp}` },
...(continuous ? { sync: { time: { field: 'order_date', delay: '60s' } } } : {}),
};
}
106 changes: 106 additions & 0 deletions x-pack/test/functional/apps/transform/starting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';
import { TRANSFORM_STATE } from '../../../../plugins/transform/common/constants';
import { getLatestTransformConfig, getPivotTransformConfig } from './index';

export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const transform = getService('transform');

describe('starting', function () {
const PREFIX = 'starting';
const testDataList = [
{
suiteTitle: 'batch transform with pivot configuration',
originalConfig: getPivotTransformConfig(PREFIX, false),
mode: 'batch',
},
{
suiteTitle: 'continuous transform with pivot configuration',
originalConfig: getPivotTransformConfig(PREFIX, true),
mode: 'continuous',
},
{
suiteTitle: 'batch transform with latest configuration',
originalConfig: getLatestTransformConfig(PREFIX, false),
mode: 'batch',
},
{
suiteTitle: 'continuous transform with latest configuration',
originalConfig: getLatestTransformConfig(PREFIX, true),
mode: 'continuous',
},
];

before(async () => {
await esArchiver.loadIfNeeded('ml/ecommerce');
await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date');

for (const testData of testDataList) {
await transform.api.createTransform(testData.originalConfig.id, testData.originalConfig);
}
await transform.testResources.setKibanaTimeZoneToUTC();
await transform.securityUI.loginAsTransformPowerUser();
});

after(async () => {
for (const testData of testDataList) {
await transform.testResources.deleteIndexPatternByTitle(testData.originalConfig.dest.index);
await transform.api.deleteIndices(testData.originalConfig.dest.index);
}

await transform.api.cleanTransformIndices();
});

for (const testData of testDataList) {
const transformId = testData.originalConfig.id;

describe(`${testData.suiteTitle}`, function () {
it('start transform', async () => {
await transform.testExecution.logTestStep('should load the home page');
await transform.navigation.navigateTo();
await transform.management.assertTransformListPageExists();

await transform.testExecution.logTestStep('should display the transforms table');
await transform.management.assertTransformsTableExists();

await transform.testExecution.logTestStep(
'should display the original transform in the transform list'
);
await transform.table.filterWithSearchString(transformId, 1);

await transform.testExecution.logTestStep('should start the transform');
await transform.table.assertTransformRowActionEnabled(transformId, 'Start', true);
await transform.table.clickTransformRowActionWithRetry(transformId, 'Start');
await transform.table.confirmStartTransform();
await transform.table.clearSearchString(testDataList.length);

if (testData.mode === 'continuous') {
await transform.testExecution.logTestStep('should display the started transform');
await transform.table.assertTransformRowStatusNotEql(
testData.originalConfig.id,
TRANSFORM_STATE.STOPPED
);
} else {
await transform.table.assertTransformRowProgressGreaterThan(transformId, 0);
}

await transform.table.assertTransformRowStatusNotEql(
testData.originalConfig.id,
TRANSFORM_STATE.FAILED
);
await transform.table.assertTransformRowStatusNotEql(
testData.originalConfig.id,
TRANSFORM_STATE.ABORTING
);
});
});
}
});
}
3 changes: 3 additions & 0 deletions x-pack/test/functional/services/transform/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
* 2.0.
*/

import { ProvidedType } from '@kbn/test/types/ftr';
import { FtrProviderContext } from '../../ftr_provider_context';

export type TransformManagement = ProvidedType<typeof TransformManagementProvider>;

export function TransformManagementProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');

Expand Down
Loading

0 comments on commit 96e34d9

Please sign in to comment.