Skip to content

Commit

Permalink
[Transform] Update tests to include waitForIndicesToExist
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jun 5, 2020
1 parent 47ec2cc commit d8f901c
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions x-pack/test/api_integration/apis/transform/delete_transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default ({ getService }: FtrProviderContext) => {
expect(body[transformId].destIndexDeleted.success).to.eql(false);
expect(body[transformId].destIndexPatternDeleted.success).to.eql(false);
await transform.api.waitForTransformNotToExist(transformId);
await transform.api.waitForIndicesToExist(destinationIndex);
});

it('should return 403 for unauthorized user', async () => {
Expand All @@ -96,11 +97,12 @@ export default ({ getService }: FtrProviderContext) => {
})
.expect(403);
await transform.api.waitForTransformToExist(transformId);
await transform.api.waitForIndicesToExist(destinationIndex);
});
});

describe('single transform deletion with invalid transformId', function () {
it('should return 404 with error message if invalid transformId', async () => {
it('should return 200 with error in response if invalid transformId', async () => {
const transformsInfo: TransformEndpointRequest[] = [{ id: 'invalid_transform_id' }];
const { body } = await supertest
.post(`/api/transform/delete_transforms`)
Expand Down Expand Up @@ -150,12 +152,16 @@ export default ({ getService }: FtrProviderContext) => {
})
.expect(200);

await asyncForEach(transformsInfo, async ({ id: transformId }: { id: string }) => {
expect(body[transformId].transformDeleted.success).to.eql(true);
expect(body[transformId].destIndexDeleted.success).to.eql(false);
expect(body[transformId].destIndexPatternDeleted.success).to.eql(false);
await transform.api.waitForTransformNotToExist(transformId);
});
await asyncForEach(
transformsInfo,
async ({ id: transformId }: { id: string }, idx: number) => {
expect(body[transformId].transformDeleted.success).to.eql(true);
expect(body[transformId].destIndexDeleted.success).to.eql(false);
expect(body[transformId].destIndexPatternDeleted.success).to.eql(false);
await transform.api.waitForTransformNotToExist(transformId);
await transform.api.waitForIndicesToExist(destinationIndices[idx]);
}
);
});

it('should delete multiple transforms by transformIds, even if one of the transformIds is invalid', async () => {
Expand All @@ -176,12 +182,16 @@ export default ({ getService }: FtrProviderContext) => {
})
.expect(200);

await asyncForEach(transformsInfo, async ({ id: transformId }: { id: string }) => {
expect(body[transformId].transformDeleted.success).to.eql(true);
expect(body[transformId].destIndexDeleted.success).to.eql(false);
expect(body[transformId].destIndexPatternDeleted.success).to.eql(false);
await transform.api.waitForTransformNotToExist(transformId);
});
await asyncForEach(
transformsInfo,
async ({ id: transformId }: { id: string }, idx: number) => {
expect(body[transformId].transformDeleted.success).to.eql(true);
expect(body[transformId].destIndexDeleted.success).to.eql(false);
expect(body[transformId].destIndexPatternDeleted.success).to.eql(false);
await transform.api.waitForTransformNotToExist(transformId);
await transform.api.waitForIndicesToExist(destinationIndices[idx]);
}
);

expect(body[invalidTransformId].transformDeleted.success).to.eql(false);
expect(body[invalidTransformId].transformDeleted).to.have.property('error');
Expand Down Expand Up @@ -259,6 +269,7 @@ export default ({ getService }: FtrProviderContext) => {
expect(body[transformId].destIndexDeleted.success).to.eql(false);
expect(body[transformId].destIndexPatternDeleted.success).to.eql(true);
await transform.api.waitForTransformNotToExist(transformId);
await transform.api.waitForIndicesToExist(destinationIndex);
await transform.testResources.assertIndexPatternNotExist(destinationIndex);
});
});
Expand Down

0 comments on commit d8f901c

Please sign in to comment.