Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unskip clone tests #118440

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ describe('migration actions', () => {
});
});

// FAILED ES PROMOTION: https://github.com/elastic/kibana/issues/117856
describe.skip('cloneIndex', () => {
describe('cloneIndex', () => {
afterAll(async () => {
try {
await client.indices.delete({ index: 'clone_*' });
Expand Down Expand Up @@ -375,14 +374,14 @@ describe('migration actions', () => {
expect.assertions(1);
const task = cloneIndex({ client, source: 'no_such_index', target: 'clone_target_3' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"index": "no_such_index",
"type": "index_not_found_exception",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"index": "no_such_index",
"type": "index_not_found_exception",
},
}
`);
});
it('resolves left with a retryable_es_client_error if clone target already exists but takes longer than the specified timeout before turning yellow', async () => {
// Create a red index
Expand All @@ -407,7 +406,7 @@ describe('migration actions', () => {
client,
source: 'existing_index_with_write_block',
target: 'clone_red_index',
timeout: '0s',
timeout: '1s',
})();

await expect(cloneIndexPromise).resolves.toMatchInlineSnapshot(`
Expand All @@ -419,6 +418,34 @@ describe('migration actions', () => {
},
}
`);

// Now that we know timeouts work, make the index yellow again and call cloneIndex a second time to verify that it completes

await client.indices.putSettings({
index: 'clone_red_index',
body: {
// Enable all shard allocation so that the index status goes yellow
routing: { allocation: { enable: 'all' } },
},
});

// Call clone even though the index already exists with yellow state
const cloneIndexPromise2 = cloneIndex({
client,
source: 'existing_index_with_write_block',
target: 'clone_red_index',
timeout: '30s',
})();

await expect(cloneIndexPromise2).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": Object {
"acknowledged": true,
"shardsAcknowledged": true,
},
}
`);
});
});

Expand All @@ -436,11 +463,11 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);

const results = (
(await searchForOutdatedDocuments(client, {
Expand Down Expand Up @@ -476,11 +503,11 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);

const results = (
(await searchForOutdatedDocuments(client, {
Expand Down Expand Up @@ -509,11 +536,11 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
const results = (
(await searchForOutdatedDocuments(client, {
batchSize: 1000,
Expand Down Expand Up @@ -544,11 +571,11 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
let task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);

// reindex without a script
res = (await reindex({
Expand All @@ -561,11 +588,11 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);

// Assert that documents weren't overridden by the second, unscripted reindex
const results = (
Expand Down Expand Up @@ -620,11 +647,11 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "reindex_succeeded",
}
`);
// Assert that existing documents weren't overridden, but that missing
// documents were added by the reindex
const results = (
Expand Down Expand Up @@ -677,13 +704,13 @@ describe('migration actions', () => {
const task = waitForReindexTask({ client, taskId: reindexTaskId, timeout: '10s' });

await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"type": "incompatible_mapping_exception",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"type": "incompatible_mapping_exception",
},
}
`);
});
it('resolves left incompatible_mapping_exception if all reindex failures are due to a mapper_parsing_exception', async () => {
expect.assertions(1);
Expand Down Expand Up @@ -716,13 +743,13 @@ describe('migration actions', () => {
const task = waitForReindexTask({ client, taskId: reindexTaskId, timeout: '10s' });

await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"type": "incompatible_mapping_exception",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"type": "incompatible_mapping_exception",
},
}
`);
});
it('resolves left index_not_found_exception if source index does not exist', async () => {
expect.assertions(1);
Expand All @@ -738,14 +765,14 @@ describe('migration actions', () => {
})()) as Either.Right<ReindexResponse>;
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"index": "no_such_index",
"type": "index_not_found_exception",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"index": "no_such_index",
"type": "index_not_found_exception",
},
}
`);
});
it('resolves left target_index_had_write_block if all failures are due to a write block', async () => {
expect.assertions(1);
Expand All @@ -761,13 +788,13 @@ describe('migration actions', () => {
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });

await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"type": "target_index_had_write_block",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"type": "target_index_had_write_block",
},
}
`);
});
it('resolves left if requireAlias=true and the target is not an alias', async () => {
expect.assertions(1);
Expand All @@ -783,14 +810,14 @@ describe('migration actions', () => {
const task = waitForReindexTask({ client, taskId: res.right.taskId, timeout: '10s' });

await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"index": "existing_index_with_write_block",
"type": "index_not_found_exception",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"index": "existing_index_with_write_block",
"type": "index_not_found_exception",
},
}
`);
});
it('resolves left wait_for_task_completion_timeout when the task does not finish within the timeout', async () => {
await waitForIndexStatusYellow({
Expand Down Expand Up @@ -841,11 +868,11 @@ describe('migration actions', () => {
targetIndex: 'reindex_target_7',
});
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Right",
"right": "verify_reindex_succeeded",
}
`);
Object {
"_tag": "Right",
"right": "verify_reindex_succeeded",
}
`);
});
it('resolves left if source and target indices have different amount of documents', async () => {
expect.assertions(1);
Expand All @@ -855,13 +882,13 @@ describe('migration actions', () => {
targetIndex: 'existing_index_2',
});
await expect(task()).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"type": "verify_reindex_failed",
},
}
`);
Object {
"_tag": "Left",
"left": Object {
"type": "verify_reindex_failed",
},
}
`);
});
it('rejects if source or target index does not exist', async () => {
expect.assertions(2);
Expand Down