Skip to content

Commit

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

# Backport

This will backport the following commits from `main` to `8.10`:
- [[ML] Fix continuous with the latest function transform test
(#164497)](#164497)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Quynh Nguyen
(Quinn)","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-08-23T18:57:24Z","message":"[ML]
Fix continuous with the latest function transform test
(#164497)","sha":"e651a6f87599d1bba72e9ebecf5e5c16979c4571","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","v8.10.0","v8.11.0"],"number":164497,"url":"https://github.com/elastic/kibana/pull/164497","mergeCommit":{"message":"[ML]
Fix continuous with the latest function transform test
(#164497)","sha":"e651a6f87599d1bba72e9ebecf5e5c16979c4571"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164497","number":164497,"mergeCommit":{"message":"[ML]
Fix continuous with the latest function transform test
(#164497)","sha":"e651a6f87599d1bba72e9ebecf5e5c16979c4571"}}]}]
BACKPORT-->

Co-authored-by: Quynh Nguyen (Quinn) <[email protected]>
  • Loading branch information
kibanamachine and qn895 authored Aug 23, 2023
1 parent 651f80a commit 7552ff2
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 7552ff2

Please sign in to comment.