Skip to content

Commit

Permalink
[ML] Fix continuous with the latest function transform test (elastic#…
Browse files Browse the repository at this point in the history
…164497)

(cherry picked from commit e651a6f)
  • Loading branch information
qn895 committed Aug 23, 2023
1 parent f02c4c3 commit f9700fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { TRANSFORM_STATE } from '@kbn/transform-plugin/common/constants';

import type { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
import type { FtrProviderContext } from '../../../../ftr_provider_context';
import {
GroupByEntry,
Expand Down Expand Up @@ -224,8 +225,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
];

for (const testData of testDataList) {
// FLAKY: https://github.com/elastic/kibana/issues/158612
describe.skip(`${testData.suiteTitle}`, function () {
describe(`${testData.suiteTitle}`, function () {
before(async () => {
// Add explicit mapping for destination index https://github.com/elastic/elasticsearch/issues/67148
if (testData.type === 'latest') {
const destIndexMappings: MappingTypeMapping = {
properties: {
products: {
properties: {
base_price: {
type: 'float',
},
},
},
},
};

await transform.api.createIndices(testData.destinationIndex, {
mappings: destIndexMappings,
});
}
});
after(async () => {
await transform.api.deleteIndices(testData.destinationIndex);
await transform.testResources.deleteIndexPatternByTitle(testData.destinationIndex);
Expand Down
16 changes: 10 additions & 6 deletions x-pack/test/functional/services/transform/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import type { PutTransformsRequestSchema } from '@kbn/transform-plugin/common/ap
import { TransformState, TRANSFORM_STATE } from '@kbn/transform-plugin/common/constants';
import type { TransformStats } from '@kbn/transform-plugin/common/types/transform_stats';

import { GetTransformsResponseSchema } from '@kbn/transform-plugin/common/api_schemas/transforms';
import { PostTransformsUpdateRequestSchema } from '@kbn/transform-plugin/common/api_schemas/update_transforms';
import { TransformPivotConfig } from '@kbn/transform-plugin/common/types/transform';
import { FtrProviderContext } from '../../ftr_provider_context';
import type { GetTransformsResponseSchema } from '@kbn/transform-plugin/common/api_schemas/transforms';
import type { PostTransformsUpdateRequestSchema } from '@kbn/transform-plugin/common/api_schemas/update_transforms';
import type { TransformPivotConfig } from '@kbn/transform-plugin/common/types/transform';
import type { IndicesCreateRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { FtrProviderContext } from '../../ftr_provider_context';

export async function asyncForEach(array: any[], callback: Function) {
for (let index = 0; index < array.length; index++) {
Expand All @@ -39,14 +40,17 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
);
},

async createIndices(indices: string) {
async createIndices(
indices: string,
params: IndicesCreateRequest['body'] = {} as NonNullable<IndicesCreateRequest['body']>
) {
log.debug(`Creating indices: '${indices}'...`);
if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === true) {
log.debug(`Indices '${indices}' already exist. Nothing to create.`);
return;
}

const createResponse = await es.indices.create({ index: indices });
const createResponse = await es.indices.create({ index: indices, ...params });
expect(createResponse)
.to.have.property('acknowledged')
.eql(true, 'Response for create request indices should be acknowledged.');
Expand Down

0 comments on commit f9700fe

Please sign in to comment.