mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
address comments from Pierre
This commit is contained in:
parent
145244a66b
commit
44f797477a
4 changed files with 17 additions and 15 deletions
|
@ -67,7 +67,7 @@ import { SavedObjectMigrationFn, SavedObjectMigrationMap } from '../types';
|
|||
import { DEFAULT_NAMESPACE_STRING } from '../../service/lib/utils';
|
||||
import { LegacyUrlAlias, LEGACY_URL_ALIAS_TYPE } from '../../object_types';
|
||||
|
||||
const DEFAULT_MINIMUM_CONVERT_VERSION = '8.0.0';
|
||||
const DEFAULT_MINIMUM_CONVERT_VERSION = '7.13.0';
|
||||
|
||||
export type MigrateFn = (doc: SavedObjectUnsanitizedDoc) => SavedObjectUnsanitizedDoc;
|
||||
export type MigrateAndConvertFn = (doc: SavedObjectUnsanitizedDoc) => SavedObjectUnsanitizedDoc[];
|
||||
|
@ -850,7 +850,8 @@ function assertNoDowngrades(
|
|||
* that we can later regenerate any inbound object references to match.
|
||||
*
|
||||
* @note This is only intended to be used when single-namespace object types are converted into multi-namespace object types.
|
||||
* @internal
|
||||
*/
|
||||
function deterministicallyRegenerateObjectId(namespace: string, type: string, id: string) {
|
||||
export function deterministicallyRegenerateObjectId(namespace: string, type: string, id: string) {
|
||||
return uuidv5(`${namespace}:${type}:${id}`, uuidv5.DNS); // the uuidv5 namespace constant (uuidv5.DNS) is arbitrary
|
||||
}
|
||||
|
|
|
@ -865,7 +865,7 @@ describe('migration actions', () => {
|
|||
await expect(docsResponse.right.outdatedDocuments.length).toBe(3);
|
||||
});
|
||||
|
||||
it('excludes documents with types listed in unusedTypesToExclude', async () => {
|
||||
it('it excludes documents not matching the provided "unusedTypesQuery"', async () => {
|
||||
const openPitTask = openPit(client, 'existing_index_with_docs');
|
||||
const pitResponse = (await openPitTask()) as Either.Right<OpenPitResponse>;
|
||||
|
||||
|
@ -941,11 +941,11 @@ describe('migration actions', () => {
|
|||
{ _id: 'foo:2', _source: { type: 'dashboard', value: 2 } },
|
||||
];
|
||||
|
||||
const creteIndexTask = createIndex(client, index, {
|
||||
const createIndexTask = createIndex(client, index, {
|
||||
dynamic: true,
|
||||
properties: {},
|
||||
});
|
||||
await creteIndexTask();
|
||||
await createIndexTask();
|
||||
|
||||
async function tranformRawDocs(docs: SavedObjectsRawDoc[]): Promise<SavedObjectsRawDoc[]> {
|
||||
for (const doc of docs) {
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
import Path from 'path';
|
||||
import Fs from 'fs';
|
||||
import Util from 'util';
|
||||
import uuidv5 from 'uuid/v5';
|
||||
import { kibanaPackageJson as pkg } from '@kbn/utils';
|
||||
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
|
||||
import type { ElasticsearchClient } from '../../../elasticsearch';
|
||||
import { Root } from '../../../root';
|
||||
import { deterministicallyRegenerateObjectId } from '../../migrations/core/document_migrator';
|
||||
|
||||
const logFilePath = Path.join(__dirname, 'migration_test_kibana.log');
|
||||
|
||||
|
@ -147,7 +147,7 @@ describe('migration v2', () => {
|
|||
hidden: false,
|
||||
mappings: { properties: { name: { type: 'text' } } },
|
||||
namespaceType: 'multiple',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
convertToMultiNamespaceTypeVersion: '7.13.0',
|
||||
});
|
||||
|
||||
coreSetup.savedObjects.registerType({
|
||||
|
@ -155,7 +155,7 @@ describe('migration v2', () => {
|
|||
hidden: false,
|
||||
mappings: { properties: { nomnom: { type: 'integer' } } },
|
||||
namespaceType: 'multiple-isolated',
|
||||
convertToMultiNamespaceTypeVersion: '8.0.0',
|
||||
convertToMultiNamespaceTypeVersion: '7.13.0',
|
||||
});
|
||||
|
||||
const coreStart = await root.start();
|
||||
|
@ -165,8 +165,8 @@ describe('migration v2', () => {
|
|||
|
||||
// each newly converted multi-namespace object in a non-default space has its ID deterministically regenerated, and a legacy-url-alias
|
||||
// object is created which links the old ID to the new ID
|
||||
const newFooId = uuidv5('spacex:foo:1', uuidv5.DNS);
|
||||
const newBarId = uuidv5('spacex:bar:1', uuidv5.DNS);
|
||||
const newFooId = deterministicallyRegenerateObjectId('spacex', 'foo', '1');
|
||||
const newBarId = deterministicallyRegenerateObjectId('spacex', 'bar', '1');
|
||||
|
||||
expect(migratedDocs).toEqual(
|
||||
[
|
||||
|
@ -176,7 +176,7 @@ describe('migration v2', () => {
|
|||
foo: { name: 'Foo 1 default' },
|
||||
references: [],
|
||||
namespaces: ['default'],
|
||||
migrationVersion: { foo: '8.0.0' },
|
||||
migrationVersion: { foo: '7.13.0' },
|
||||
coreMigrationVersion: pkg.version,
|
||||
},
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ describe('migration v2', () => {
|
|||
references: [],
|
||||
namespaces: ['spacex'],
|
||||
originId: '1',
|
||||
migrationVersion: { foo: '8.0.0' },
|
||||
migrationVersion: { foo: '7.13.0' },
|
||||
coreMigrationVersion: pkg.version,
|
||||
},
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ describe('migration v2', () => {
|
|||
bar: { nomnom: 1 },
|
||||
references: [{ type: 'foo', id: '1', name: 'Foo 1 default' }],
|
||||
namespaces: ['default'],
|
||||
migrationVersion: { bar: '8.0.0' },
|
||||
migrationVersion: { bar: '7.13.0' },
|
||||
coreMigrationVersion: pkg.version,
|
||||
},
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ describe('migration v2', () => {
|
|||
references: [{ type: 'foo', id: newFooId, name: 'Foo 1 spacex' }],
|
||||
namespaces: ['spacex'],
|
||||
originId: '1',
|
||||
migrationVersion: { bar: '8.0.0' },
|
||||
migrationVersion: { bar: '7.13.0' },
|
||||
coreMigrationVersion: pkg.version,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -506,8 +506,9 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
|
|||
} else if (stateP.controlState === 'REINDEX_SOURCE_TO_TEMP_CLOSE_PIT') {
|
||||
const res = resW as ExcludeRetryableEsError<ResponseType<typeof stateP.controlState>>;
|
||||
if (Either.isRight(res)) {
|
||||
const { sourceIndexPitId, ...state } = stateP;
|
||||
return {
|
||||
...stateP,
|
||||
...state,
|
||||
controlState: 'SET_TEMP_WRITE_BLOCK',
|
||||
sourceIndex: stateP.sourceIndex as Option.Some<string>,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue