Skip to content

Commit

Permalink
[ML] Extend stop transforms assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Sep 10, 2020
1 parent 2320fbc commit efcf9b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions x-pack/test/api_integration/apis/transform/stop_transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import expect from '@kbn/expect';

import type { PutTransformsRequestSchema } from '../../../../plugins/transform/common/api_schemas/transforms';
import type { StopTransformsRequestSchema } from '../../../../plugins/transform/common/api_schemas/stop_transforms';
import { isStopTransformsResponseSchema } from '../../../../plugins/transform/common/api_schemas/type_guards';

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

import { COMMON_REQUEST_HEADERS } from '../../../functional/services/ml/common_api';
Expand Down Expand Up @@ -72,14 +74,14 @@ export default ({ getService }: FtrProviderContext) => {
.send(reqBody)
.expect(200);

expect(isStopTransformsResponseSchema(body)).to.eql(true);
expect(body[transformId].success).to.eql(true);
expect(typeof body[transformId].error).to.eql('undefined');
await transform.api.waitForTransformState(transformId, TRANSFORM_STATE.STOPPED);
await transform.api.waitForIndicesToExist(destinationIndex);
});

it('should return 200 with success:false for unauthorized user', async () => {
await transform.api.waitForTransformStateNotToBe(transformId, TRANSFORM_STATE.STOPPED);

const reqBody: StopTransformsRequestSchema = [
{ id: transformId, state: TRANSFORM_STATE.STARTED },
];
Expand All @@ -93,6 +95,7 @@ export default ({ getService }: FtrProviderContext) => {
.send(reqBody)
.expect(200);

expect(isStopTransformsResponseSchema(body)).to.eql(true);
expect(body[transformId].success).to.eql(false);
expect(typeof body[transformId].error).to.eql('string');

Expand All @@ -116,6 +119,7 @@ export default ({ getService }: FtrProviderContext) => {
.send(reqBody)
.expect(200);

expect(isStopTransformsResponseSchema(body)).to.eql(true);
expect(body.invalid_transform_id.success).to.eql(false);
expect(body.invalid_transform_id).to.have.property('error');
});
Expand Down Expand Up @@ -152,8 +156,11 @@ export default ({ getService }: FtrProviderContext) => {
.send(reqBody)
.expect(200);

expect(isStopTransformsResponseSchema(body)).to.eql(true);

await asyncForEach(reqBody, async ({ id: transformId }: { id: string }, idx: number) => {
expect(body[transformId].success).to.eql(true);
await transform.api.waitForTransformState(transformId, TRANSFORM_STATE.STOPPED);
await transform.api.waitForIndicesToExist(destinationIndices[idx]);
});
});
Expand All @@ -174,8 +181,11 @@ export default ({ getService }: FtrProviderContext) => {
])
.expect(200);

expect(isStopTransformsResponseSchema(body)).to.eql(true);

await asyncForEach(reqBody, async ({ id: transformId }: { id: string }, idx: number) => {
expect(body[transformId].success).to.eql(true);
await transform.api.waitForTransformState(transformId, TRANSFORM_STATE.STOPPED);
await transform.api.waitForIndicesToExist(destinationIndices[idx]);
});

Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/api_integration/apis/transform/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default ({ getService }: FtrProviderContext) => {
}

function assertTransformsResponseBody(body: GetTransformsResponseSchema) {
expect(isGetTransformsResponseSchema(body)).to.be(true);
expect(isGetTransformsResponseSchema(body)).to.eql(true);

expect(body.count).to.eql(expected.apiTransformTransforms.count);
expect(body.transforms).to.have.length(expected.apiTransformTransforms.count);
Expand All @@ -60,7 +60,7 @@ export default ({ getService }: FtrProviderContext) => {
}

function assertSingleTransformResponseBody(body: GetTransformsResponseSchema) {
expect(isGetTransformsResponseSchema(body)).to.be(true);
expect(isGetTransformsResponseSchema(body)).to.eql(true);

expect(body.count).to.eql(expected.apiTransformTransformsTransformId.count);
expect(body.transforms).to.have.length(expected.apiTransformTransformsTransformId.count);
Expand Down

0 comments on commit efcf9b3

Please sign in to comment.