Skip to content

Commit

Permalink
adapt more usages and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Apr 27, 2023
1 parent f3f37ed commit 9163bd4
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('updateIndexMeta', () => {
const index = '.kibana_1';
const meta: IndexMappingMeta = {
mappingVersions: {
foo: 1,
bar: 1,
foo: '10.1.0',
bar: '10.1.0',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Stage: init', () => {
aliases: {},
mappings: {
properties: {},
_meta: { mappingVersions: { foo: 1, bar: 1 } },
_meta: { mappingVersions: { foo: '10.1.0', bar: '10.1.0' } },
},
settings: {},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ describe('Stage: updateDocumentModelVersion', () => {
it('updates state.currentIndexMeta when successful', () => {
const state = createState({
currentIndexMeta: {
mappingVersions: { foo: 1, bar: 2 },
docVersions: { foo: 0, bar: 0 },
mappingVersions: { foo: '10.1.0', bar: '10.2.0' },
docVersions: { foo: '0.0.0', bar: '0.0.0' },
migrationState: {
convertingDocuments: true,
},
Expand All @@ -63,8 +63,8 @@ describe('Stage: updateDocumentModelVersion', () => {
const newState = updateDocumentModelVersion(state, res, context);

expect(newState.currentIndexMeta).toEqual({
mappingVersions: { foo: 1, bar: 2 },
docVersions: { foo: 1, bar: 2 },
mappingVersions: { foo: '10.1.0', bar: '10.2.0' },
docVersions: { foo: '10.1.0', bar: '10.2.0' },
migrationState: {
convertingDocuments: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const updateDocumentModelVersion: ModelStage<
controlState: 'UPDATE_DOCUMENT_MODEL_VERSIONS_WAIT_FOR_INSTANCES',
currentIndexMeta: setMetaDocMigrationComplete({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
}),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Stage: updateMappingModelVersion', () => {
expect(newState.currentIndexMeta).toEqual(
setMetaMappingMigrationComplete({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const updateMappingModelVersion: ModelStage<
controlState: state.aliasActions.length ? 'UPDATE_ALIASES' : 'INDEX_STATE_UPDATE_DONE',
currentIndexMeta: setMetaMappingMigrationComplete({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
}),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('actions', () => {
expect(setMetaMappingMigrationCompleteMock).toHaveBeenCalledTimes(1);
expect(setMetaMappingMigrationCompleteMock).toHaveBeenCalledWith({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
});
});

Expand Down Expand Up @@ -123,7 +123,7 @@ describe('actions', () => {
expect(setMetaDocMigrationCompleteMock).toHaveBeenCalledTimes(1);
expect(setMetaDocMigrationCompleteMock).toHaveBeenCalledWith({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const nextActionMap = (context: MigratorContext) => {
index: state.currentIndex,
meta: setMetaMappingMigrationComplete({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
}),
}),
UPDATE_ALIASES: (state: UpdateAliasesState) =>
Expand Down Expand Up @@ -172,7 +172,7 @@ export const nextActionMap = (context: MigratorContext) => {
index: state.currentIndex,
meta: setMetaDocMigrationComplete({
meta: state.currentIndexMeta,
versions: context.typeModelVersions,
versions: context.typeVirtualVersions,
}),
}),
UPDATE_DOCUMENT_MODEL_VERSIONS_WAIT_FOR_INSTANCES: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const createContextMock = (
kibanaVersion: '8.7.0',
indexPrefix: '.kibana',
types: ['foo', 'bar'],
typeModelVersions: {
foo: 1,
bar: 2,
typeVirtualVersions: {
foo: '10.1.0',
bar: '10.2.0',
},
documentMigrator: createDocumentMigrator(),
migrationConfig: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ describe('buildIndexMeta', () => {

expect(meta).toEqual({
mappingVersions: {
foo: 2,
bar: 1,
dolly: 3,
foo: '10.2.0',
bar: '10.1.0',
dolly: '10.3.0',
},
docVersions: {
foo: 2,
bar: 1,
dolly: 3,
foo: '10.2.0',
bar: '10.1.0',
dolly: '10.3.0',
},
migrationState: {
convertingDocuments: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
import {
type IndexMapping,
type IndexMappingMeta,
getModelVersionMapForTypes,
getVirtualVersionMap,
} from '@kbn/core-saved-objects-base-server-internal';
import { getBaseMappings, buildTypesMappings } from '../../core';

Expand Down Expand Up @@ -48,11 +48,11 @@ interface BuildIndexMetaOpts {
* @param types The list of all registered SO types.
*/
export const buildIndexMeta = ({ types }: BuildIndexMetaOpts): IndexMappingMeta => {
const modelVersions = getModelVersionMapForTypes(types);
const typeVersions = getVirtualVersionMap(types);

return {
mappingVersions: modelVersions,
docVersions: modelVersions,
mappingVersions: typeVersions,
docVersions: typeVersions,
migrationState: {
convertingDocuments: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import type {
IndexMappingMeta,
ModelVersionMap,
VirtualVersionMap,
} from '@kbn/core-saved-objects-base-server-internal';
import {
setMetaDocMigrationStarted,
Expand All @@ -18,12 +18,12 @@ import {

const getDefaultMeta = (): IndexMappingMeta => ({
mappingVersions: {
foo: 1,
bar: 1,
foo: '10.1.0',
bar: '10.1.0',
},
docVersions: {
foo: 1,
bar: 1,
foo: '10.1.0',
bar: '10.1.0',
},
migrationState: {
convertingDocuments: false,
Expand All @@ -33,7 +33,7 @@ const getDefaultMeta = (): IndexMappingMeta => ({
describe('setMetaMappingMigrationComplete', () => {
it('updates the meta to set the mappingVersions', () => {
const meta: IndexMappingMeta = getDefaultMeta();
const versions: ModelVersionMap = { foo: 3, bar: 2 };
const versions: VirtualVersionMap = { foo: '10.3.0', bar: '10.2.0' };

const updated = setMetaMappingMigrationComplete({ meta, versions });

Expand Down Expand Up @@ -67,7 +67,7 @@ describe('setMetaDocMigrationComplete', () => {
convertingDocuments: true,
},
};
const versions: ModelVersionMap = { foo: 3, bar: 2 };
const versions: VirtualVersionMap = { foo: '10.3.0', bar: '10.2.0' };

const updated = setMetaDocMigrationComplete({ meta, versions });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

import type {
IndexMappingMeta,
ModelVersionMap,
VirtualVersionMap,
} from '@kbn/core-saved-objects-base-server-internal';

export const setMetaMappingMigrationComplete = ({
meta,
versions,
}: {
meta: IndexMappingMeta;
versions: ModelVersionMap;
versions: VirtualVersionMap;
}): IndexMappingMeta => {
return {
...meta,
Expand Down Expand Up @@ -44,7 +44,7 @@ export const setMetaDocMigrationComplete = ({
versions,
}: {
meta: IndexMappingMeta;
versions: ModelVersionMap;
versions: VirtualVersionMap;
}): IndexMappingMeta => {
return {
...meta,
Expand Down

0 comments on commit 9163bd4

Please sign in to comment.