mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[ML] Functional tests - reenable clone and edit tests for transform latest (#99306)
This PR fixes the data grid parsing and re-enables the clone and edit tests for transform latest.
This commit is contained in:
parent
fa13af90be
commit
beaa4e78fb
3 changed files with 84 additions and 76 deletions
|
@ -11,6 +11,7 @@ import {
|
|||
isPivotTransform,
|
||||
TransformPivotConfig,
|
||||
} from '../../../../plugins/transform/common/types/transform';
|
||||
import { getLatestTransformConfig } from './index';
|
||||
|
||||
interface TestData {
|
||||
type: 'pivot' | 'latest';
|
||||
|
@ -85,7 +86,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
describe('cloning', function () {
|
||||
const transformConfigWithPivot = getTransformConfig();
|
||||
const transformConfigWithRuntimeMapping = getTransformConfigWithRuntimeMappings();
|
||||
// const transformConfigWithLatest = getLatestTransformConfig();
|
||||
const transformConfigWithLatest = getLatestTransformConfig('cloning');
|
||||
|
||||
before(async () => {
|
||||
await esArchiver.loadIfNeeded('ml/ecommerce');
|
||||
|
@ -99,10 +100,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
transformConfigWithRuntimeMapping
|
||||
);
|
||||
|
||||
// await transform.api.createAndRunTransform(
|
||||
// transformConfigWithLatest.id,
|
||||
// transformConfigWithLatest
|
||||
// );
|
||||
await transform.api.createAndRunTransform(
|
||||
transformConfigWithLatest.id,
|
||||
transformConfigWithLatest
|
||||
);
|
||||
await transform.testResources.setKibanaTimeZoneToUTC();
|
||||
|
||||
await transform.securityUI.loginAsTransformPowerUser();
|
||||
|
@ -114,10 +115,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
transformConfigWithRuntimeMapping.dest.index
|
||||
);
|
||||
|
||||
// await transform.testResources.deleteIndexPatternByTitle(transformConfigWithLatest.dest.index);
|
||||
await transform.testResources.deleteIndexPatternByTitle(transformConfigWithLatest.dest.index);
|
||||
await transform.api.deleteIndices(transformConfigWithPivot.dest.index);
|
||||
await transform.api.deleteIndices(transformConfigWithRuntimeMapping.dest.index);
|
||||
// await transform.api.deleteIndices(transformConfigWithLatest.dest.index);
|
||||
await transform.api.deleteIndices(transformConfigWithLatest.dest.index);
|
||||
await transform.api.cleanTransformIndices();
|
||||
});
|
||||
|
||||
|
@ -186,33 +187,30 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
},
|
||||
},
|
||||
// TODO enable tests when https://github.com/elastic/elasticsearch/issues/67148 is resolved
|
||||
// {
|
||||
// type: 'latest' as const,
|
||||
// suiteTitle: 'clone transform with latest function',
|
||||
// originalConfig: transformConfigWithLatest,
|
||||
// transformId: `clone_${transformConfigWithLatest.id}`,
|
||||
// transformDescription: `a cloned transform`,
|
||||
// get destinationIndex(): string {
|
||||
// return `user-${this.transformId}`;
|
||||
// },
|
||||
// expected: {
|
||||
// indexPreview: {
|
||||
// columns: 10,
|
||||
// rows: 5,
|
||||
// },
|
||||
// transformPreview: {
|
||||
// column: 0,
|
||||
// values: [
|
||||
// 'July 12th 2019, 22:16:19',
|
||||
// 'July 12th 2019, 22:50:53',
|
||||
// 'July 12th 2019, 23:06:43',
|
||||
// 'July 12th 2019, 23:15:22',
|
||||
// 'July 12th 2019, 23:31:12',
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
{
|
||||
type: 'latest' as const,
|
||||
suiteTitle: 'clone transform with latest function',
|
||||
originalConfig: transformConfigWithLatest,
|
||||
transformId: `clone_${transformConfigWithLatest.id}`,
|
||||
transformDescription: `a cloned transform`,
|
||||
get destinationIndex(): string {
|
||||
return `user-${this.transformId}`;
|
||||
},
|
||||
expected: {
|
||||
indexPreview: {
|
||||
columns: 10,
|
||||
rows: 5,
|
||||
},
|
||||
transformPreview: {
|
||||
column: 0,
|
||||
values: [
|
||||
'July 12th 2019, 23:06:43',
|
||||
'July 12th 2019, 23:31:12',
|
||||
'July 12th 2019, 23:45:36',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const testData of testDataList) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import { TransformPivotConfig } from '../../../../plugins/transform/common/types
|
|||
import { TRANSFORM_STATE } from '../../../../plugins/transform/common/constants';
|
||||
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import { getLatestTransformConfig } from './index';
|
||||
|
||||
function getTransformConfig(): TransformPivotConfig {
|
||||
const date = Date.now();
|
||||
|
@ -31,7 +32,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
describe('editing', function () {
|
||||
const transformConfigWithPivot = getTransformConfig();
|
||||
// const transformConfigWithLatest = getLatestTransformConfig();
|
||||
const transformConfigWithLatest = getLatestTransformConfig('editing');
|
||||
|
||||
before(async () => {
|
||||
await esArchiver.loadIfNeeded('ml/ecommerce');
|
||||
|
@ -41,10 +42,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
transformConfigWithPivot.id,
|
||||
transformConfigWithPivot
|
||||
);
|
||||
// await transform.api.createAndRunTransform(
|
||||
// transformConfigWithLatest.id,
|
||||
// transformConfigWithLatest
|
||||
// );
|
||||
await transform.api.createAndRunTransform(
|
||||
transformConfigWithLatest.id,
|
||||
transformConfigWithLatest
|
||||
);
|
||||
|
||||
await transform.testResources.setKibanaTimeZoneToUTC();
|
||||
await transform.securityUI.loginAsTransformPowerUser();
|
||||
|
@ -53,8 +54,8 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
after(async () => {
|
||||
await transform.testResources.deleteIndexPatternByTitle(transformConfigWithPivot.dest.index);
|
||||
await transform.api.deleteIndices(transformConfigWithPivot.dest.index);
|
||||
// await transform.testResources.deleteIndexPatternByTitle(transformConfigWithLatest.dest.index);
|
||||
// await transform.api.deleteIndices(transformConfigWithLatest.dest.index);
|
||||
await transform.testResources.deleteIndexPatternByTitle(transformConfigWithLatest.dest.index);
|
||||
await transform.api.deleteIndices(transformConfigWithLatest.dest.index);
|
||||
await transform.api.cleanTransformIndices();
|
||||
});
|
||||
|
||||
|
@ -74,22 +75,21 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
},
|
||||
},
|
||||
// TODO enable tests when https://github.com/elastic/elasticsearch/issues/67148 is resolved
|
||||
// {
|
||||
// suiteTitle: 'edit transform with latest configuration',
|
||||
// originalConfig: transformConfigWithLatest,
|
||||
// transformDescription: 'updated description',
|
||||
// transformDocsPerSecond: '1000',
|
||||
// transformFrequency: '10m',
|
||||
// expected: {
|
||||
// messageText: 'updated transform.',
|
||||
// row: {
|
||||
// status: TRANSFORM_STATE.STOPPED,
|
||||
// mode: 'batch',
|
||||
// progress: '100',
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
{
|
||||
suiteTitle: 'edit transform with latest configuration',
|
||||
originalConfig: transformConfigWithLatest,
|
||||
transformDescription: 'updated description',
|
||||
transformDocsPerSecond: '1000',
|
||||
transformFrequency: '10m',
|
||||
expected: {
|
||||
messageText: 'updated transform.',
|
||||
row: {
|
||||
status: TRANSFORM_STATE.STOPPED,
|
||||
mode: 'batch',
|
||||
progress: '100',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const testData of testDataList) {
|
||||
|
@ -141,7 +141,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
await transform.testExecution.logTestStep('should update the transform frequency');
|
||||
await transform.editFlyout.assertTransformEditFlyoutInputExists('Frequency');
|
||||
await transform.editFlyout.assertTransformEditFlyoutInputValue('Frequency', '');
|
||||
await transform.editFlyout.assertTransformEditFlyoutInputValue(
|
||||
'Frequency',
|
||||
testData.originalConfig.frequency || ''
|
||||
);
|
||||
await transform.editFlyout.setTransformEditFlyoutInputValue(
|
||||
'Frequency',
|
||||
testData.transformFrequency
|
||||
|
|
|
@ -96,28 +96,32 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
|
|||
await testSubjects.missingOrFail('transformPivotPreviewHistogramButton');
|
||||
},
|
||||
|
||||
async parseEuiDataGrid(tableSubj: string) {
|
||||
async parseEuiDataGrid(tableSubj: string, maxColumnsToParse: number) {
|
||||
const table = await testSubjects.find(`~${tableSubj}`);
|
||||
const $ = await table.parseDomContent();
|
||||
|
||||
// find columns to help determine number of rows
|
||||
const columns = $('.euiDataGridHeaderCell__content')
|
||||
.toArray()
|
||||
.map((cell) => $(cell).text());
|
||||
|
||||
// Get the content of each cell and divide them up into rows
|
||||
// Get the content of each cell and divide them up into rows.
|
||||
// Virtualized cells outside the view area are not present in the DOM until they
|
||||
// are scroilled into view, so we're limiting the number of parsed columns.
|
||||
// To determine row and column of a cell, we're utilizing the screen reader
|
||||
// help text, which enumerates the rows and columns 1-based.
|
||||
const cells = $.findTestSubjects('dataGridRowCell')
|
||||
.find('.euiDataGridRowCell__truncate')
|
||||
.toArray()
|
||||
.map((cell) =>
|
||||
$(cell)
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/Row: \d+, Column: \d+:$/g, '')
|
||||
);
|
||||
|
||||
const rows = chunk(cells, columns.length);
|
||||
.map((cell) => {
|
||||
const cellText = $(cell).text();
|
||||
const pattern = /^(.*)Row: (\d+), Column: (\d+):$/;
|
||||
const matches = cellText.match(pattern);
|
||||
expect(matches).to.not.eql(null, `Cell text should match pattern '${pattern}'`);
|
||||
return { text: matches![1], row: Number(matches![2]), column: Number(matches![3]) };
|
||||
})
|
||||
.filter((cell) => cell?.column <= maxColumnsToParse)
|
||||
.sort(function (a, b) {
|
||||
return a.row - b.row || a.column - b.column;
|
||||
})
|
||||
.map((cell) => cell.text);
|
||||
|
||||
const rows = chunk(cells, maxColumnsToParse);
|
||||
return rows;
|
||||
},
|
||||
|
||||
|
@ -128,7 +132,8 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
|
|||
) {
|
||||
await retry.tryForTime(2000, async () => {
|
||||
// get a 2D array of rows and cell values
|
||||
const rows = await this.parseEuiDataGrid(tableSubj);
|
||||
// only parse columns up to the one we want to assert
|
||||
const rows = await this.parseEuiDataGrid(tableSubj, column + 1);
|
||||
|
||||
// reduce the rows data to an array of unique values in the specified column
|
||||
const uniqueColumnValues = rows
|
||||
|
@ -149,7 +154,8 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
|
|||
async assertEuiDataGridColumnValuesNotEmpty(tableSubj: string, column: number) {
|
||||
await retry.tryForTime(2000, async () => {
|
||||
// get a 2D array of rows and cell values
|
||||
const rows = await this.parseEuiDataGrid(tableSubj);
|
||||
// only parse columns up to the one we want to assert
|
||||
const rows = await this.parseEuiDataGrid(tableSubj, column + 1);
|
||||
|
||||
// reduce the rows data to an array of unique values in the specified column
|
||||
const uniqueColumnValues = rows
|
||||
|
@ -167,7 +173,8 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
|
|||
async assertIndexPreview(columns: number, expectedNumberOfRows: number) {
|
||||
await retry.tryForTime(2000, async () => {
|
||||
// get a 2D array of rows and cell values
|
||||
const rowsData = await this.parseEuiDataGrid('transformIndexPreview');
|
||||
// only parse the first column as this is sufficient to get assert the row count
|
||||
const rowsData = await this.parseEuiDataGrid('transformIndexPreview', 1);
|
||||
|
||||
expect(rowsData).to.length(
|
||||
expectedNumberOfRows,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue