Skip to content

Commit

Permalink
Integration test: assert waitForPickupUpdatedMappingsTask waitForRein…
Browse files Browse the repository at this point in the history
…dexTask returns retryable error when task has not completed within the timeout
  • Loading branch information
rudolf committed Mar 24, 2021
1 parent fd249da commit fc694f5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ const waitForTask = (
) {
return Either.left({
type: 'retryable_es_client_error' as const,
message: `[${e.body.error.type}] ${e.body.error.reason}`,
message: `[${e.body.error.type}] ${e.body.error.reason}`,
error: e,
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
} from '../actions';
import * as Either from 'fp-ts/lib/Either';
import * as Option from 'fp-ts/lib/Option';
import { ResponseError } from '@elastic/elasticsearch/lib/errors';

const { startES } = kbnTestServer.createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
Expand Down Expand Up @@ -587,6 +588,28 @@ describe('migration actions', () => {
}
`);
});
it('resolves left retryable_es_client_error when the task does not finish within the timeout', async () => {
const res = (await reindex(
client,
'existing_index_with_docs',
'existing_index_with_write_block',
Option.none,
true
)()) as Either.Right<ReindexResponse>;

const task = waitForReindexTask(client, res.right.taskId, '0s');

await expect(task()).resolves.toMatchObject({
_tag: 'Left',
left: {
error: expect.any(ResponseError),
message: expect.stringMatching(
/\[timeout_exception\] Timed out waiting for completion of \[org.elasticsearch.index.reindex.BulkByScrollTask/
),
type: 'retryable_es_client_error',
},
});
});
});

describe('verifyReindex', () => {
Expand Down Expand Up @@ -702,6 +725,25 @@ describe('migration actions', () => {
{"type":"index_not_found_exception","reason":"no such index [no_such_index]","resource.type":"index_or_alias","resource.id":"no_such_index","index_uuid":"_na_","index":"no_such_index"}]
`);
});
it('resolves with a retryable error when the operation does not complete within the timeout', async () => {
const res = (await pickupUpdatedMappings(
client,
'existing_index_with_docs'
)()) as Either.Right<UpdateByQueryResponse>;

const task = waitForPickupUpdatedMappingsTask(client, res.right.taskId, '0s');

await expect(task()).resolves.toMatchObject({
_tag: 'Left',
left: {
error: expect.any(ResponseError),
message: expect.stringMatching(
/\[timeout_exception\] Timed out waiting for completion of \[org.elasticsearch.index.reindex.BulkByScrollTask/
),
type: 'retryable_es_client_error',
},
});
});
it('resolves right when successful', async () => {
const res = (await pickupUpdatedMappings(
client,
Expand Down

0 comments on commit fc694f5

Please sign in to comment.