Skip to content

Commit

Permalink
[Migrations] Upgrade tests to use 9.x compatible archives (#193696)
Browse files Browse the repository at this point in the history
## Summary

Part of elastic/kibana-team#1113

Merges some tested code paths into `v2_migration.test.ts` which uses an
archive that is generated in 9.0.0.
Gets rid of the related failing tests.
  • Loading branch information
gsoldevila authored Sep 24, 2024
1 parent 3b8e56f commit d4cc182
Show file tree
Hide file tree
Showing 23 changed files with 901 additions and 1,530 deletions.
5 changes: 1 addition & 4 deletions docs/setup/upgrade/resolving-migration-failures.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ If you fail to remedy this, your upgrade to 8.0+ will fail with a message like:

[source,sh]
--------------------------------------------
Unable to complete saved object migrations for the [.kibana] index: Migration failed because some documents were found which use unknown saved object types:
- "firstDocId" (type "someType")
- "secondtDocId" (type "someType")
- "thirdDocId" (type "someOtherType")
Unable to complete saved object migrations for the [.kibana] index: Migration failed because some documents were found which use unknown saved object types: someType,someOtherType
To proceed with the migration you can configure Kibana to discard unknown saved objects for this migration.
--------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ describe('extractUnknownDocFailureReason', () => {
},
])
).toMatchInlineSnapshot(`
"Migration failed because some documents were found which use unknown saved object types:
- \\"unknownType:12\\" (type: \\"unknownType\\")
- \\"anotherUnknownType:42\\" (type: \\"anotherUnknownType\\")
"Migration failed because some documents were found which use unknown saved object types: unknownType,anotherUnknownType
To proceed with the migration you can configure Kibana to discard unknown saved objects for this migration.
Please refer to some-url.co for more information."
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ export function extractUnknownDocFailureReason(
resolveMigrationFailuresUrl: string,
unknownDocs: DocumentIdAndType[]
): string {
const typesSet = new Set(unknownDocs.map(({ type }) => type));
return (
`Migration failed because some documents were found which use unknown saved object types:\n` +
unknownDocs.map((doc) => `- "${doc.id}" (type: "${doc.type}")\n`).join('') +
`\nTo proceed with the migration you can configure Kibana to discard unknown saved objects for this migration.\n` +
`Migration failed because some documents were found which use unknown saved object types: ${Array.from(
typesSet.values()
)}\n` +
`To proceed with the migration you can configure Kibana to discard unknown saved objects for this migration.\n` +
`Please refer to ${resolveMigrationFailuresUrl} for more information.`
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,21 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
deleteByQueryTaskId: res.right.taskId,
};
} else {
const reason = extractUnknownDocFailureReason(
stateP.migrationDocLinks.resolveMigrationFailures,
res.left.unknownDocs
);
return {
...stateP,
controlState: 'FATAL',
reason: extractUnknownDocFailureReason(
stateP.migrationDocLinks.resolveMigrationFailures,
res.left.unknownDocs
),
reason,
logs: [
...logs,
{
level: 'error',
message: reason,
},
],
};
}
} else if (stateP.controlState === 'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK') {
Expand Down Expand Up @@ -700,13 +708,22 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):

if (isTypeof(res.right, 'unknown_docs_found')) {
if (!stateP.discardUnknownObjects) {
const reason = extractUnknownDocFailureReason(
stateP.migrationDocLinks.resolveMigrationFailures,
res.right.unknownDocs
);

return {
...stateP,
controlState: 'FATAL',
reason: extractUnknownDocFailureReason(
stateP.migrationDocLinks.resolveMigrationFailures,
res.right.unknownDocs
),
reason,
logs: [
...logs,
{
level: 'error',
message: reason,
},
],
};
}

Expand Down Expand Up @@ -879,6 +896,13 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
corruptDocumentIds: [],
transformErrors: [],
progress: createInitialProgress(),
logs: [
...logs,
{
level: 'info',
message: `REINDEX_SOURCE_TO_TEMP_OPEN_PIT PitId:${res.right.pitId}`,
},
],
};
} else {
throwBadResponse(stateP, res);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Loading

0 comments on commit d4cc182

Please sign in to comment.