[Migrations] Improve naming on some states' names (#152441)

Some migration states have names that are a bit vague / not accurate.
This PR intends to update them to reduce confusion and make the flow
more clear.
This commit is contained in:
Gerard Soldevila 2023-03-07 12:25:01 +01:00 committed by GitHub
parent bc64e05281
commit d2a329f88d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 182 additions and 153 deletions

View file

@ -63,10 +63,10 @@
- [CHECK_TARGET_MAPPINGS](#check_target_mappings)
- [Next action](#next-action-20)
- [New control state](#new-control-state-20)
- [UPDATE_TARGET_MAPPINGS](#update_target_mappings)
- [UPDATE_TARGET_MAPPINGS_PROPERTIES](#update_target_mappings_properties)
- [Next action](#next-action-21)
- [New control state](#new-control-state-21)
- [UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK](#update_target_mappings_wait_for_task)
- [UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK](#update_target_mappings_properties_wait_for_task)
- [Next action](#next-action-22)
- [New control state](#new-control-state-22)
- [CHECK_VERSION_INDEX_READY_ACTIONS](#check_version_index_ready_actions)
@ -360,7 +360,7 @@ ensuring that each Kibana instance generates the same new `_id` for the same doc
Use the bulk API create action to write a batch of up-to-date documents. The
create action ensures that there will be only one write per reindexed document
even if multiple Kibana instances are performing this step. Use
`refresh=false` to speed up the create actions, the `UPDATE_TARGET_MAPPINGS`
`refresh=false` to speed up the create actions, the `UPDATE_TARGET_MAPPINGS_PROPERTIES`
step will ensure that the index is refreshed before we start serving traffic.
The following errors are ignored because it means another instance already
@ -420,7 +420,7 @@ and transform them to ensure that everything is up to date.
1. Found outdated documents?
`OUTDATED_DOCUMENTS_TRANSFORM`
2. All documents up to date
`UPDATE_TARGET_MAPPINGS`
`UPDATE_TARGET_MAPPINGS_PROPERTIES`
## OUTDATED_DOCUMENTS_TRANSFORM
### Next action
@ -442,11 +442,11 @@ Compare the calculated mappings' hashes against those stored in the `<index>.map
### New control state
1. If calculated mappings don't match, we must update them.
`UPDATE_TARGET_MAPPINGS`
`UPDATE_TARGET_MAPPINGS_PROPERTIES`
2. If calculated mappings and stored mappings match, we can skip directly to the next step.
`CHECK_VERSION_INDEX_READY_ACTIONS`
## UPDATE_TARGET_MAPPINGS
## UPDATE_TARGET_MAPPINGS_PROPERTIES
### Next action
`updateAndPickupMappings`
@ -454,9 +454,9 @@ If another instance has some plugins disabled it will disable the mappings of th
update the mappings and then use an update_by_query to ensure that all fields are “picked-up” and ready to be searched over.
### New control state
`UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK`
`UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK`
## UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK
## UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK
### Next action
`waitForPickupUpdatedMappingsTask`

View file

@ -31,7 +31,7 @@ describe('refreshIndex', () => {
);
it('calls catchRetryableEsClientErrors when the promise rejects', async () => {
const task = refreshIndex({ client, targetIndex: 'target_index' });
const task = refreshIndex({ client, index: 'target_index' });
try {
await task();
} catch (e) {

View file

@ -17,7 +17,7 @@ import {
/** @internal */
export interface RefreshIndexParams {
client: ElasticsearchClient;
targetIndex: string;
index: string;
}
/**
* Wait for Elasticsearch to reindex all the changes.
@ -25,13 +25,11 @@ export interface RefreshIndexParams {
export const refreshIndex =
({
client,
targetIndex,
index,
}: RefreshIndexParams): TaskEither.TaskEither<RetryableEsClientError, { refreshed: boolean }> =>
() => {
return client.indices
.refresh({
index: targetIndex,
})
.refresh({ index })
.then(() => {
return Either.right({ refreshed: true });
})

View file

@ -18,7 +18,7 @@ import { DEFAULT_TIMEOUT } from './constants';
export interface UpdateMappingsParams {
client: ElasticsearchClient;
index: string;
mappings: IndexMapping;
mappings: Partial<IndexMapping>;
}
/** @internal */

View file

@ -13,7 +13,7 @@ import type { IndexMapping } from '@kbn/core-saved-objects-base-server-internal'
import type {
BaseState,
CalculateExcludeFiltersState,
UpdateSourceMappingsState,
UpdateSourceMappingsPropertiesState,
CheckTargetMappingsState,
CheckUnknownDocumentsState,
CheckVersionIndexReadyActions,
@ -47,8 +47,8 @@ import type {
State,
TransformedDocumentsBulkIndex,
UpdateTargetMappingsMeta,
UpdateTargetMappingsState,
UpdateTargetMappingsWaitForTaskState,
UpdateTargetMappingsPropertiesState,
UpdateTargetMappingsPropertiesWaitForTaskState,
WaitForYellowSourceState,
} from '../state';
import { type TransformErrorObjects, TransformSavedObjectDocumentError } from '../core';
@ -1299,12 +1299,12 @@ describe('migrations v2 model', () => {
sourceIndexMappings: actualMappings,
};
test('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS', () => {
test('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES', () => {
const res: ResponseType<'WAIT_FOR_YELLOW_SOURCE'> = Either.right({});
const newState = model(changedMappingsState, res);
expect(newState).toMatchObject({
controlState: 'UPDATE_SOURCE_MAPPINGS',
controlState: 'UPDATE_SOURCE_MAPPINGS_PROPERTIES',
sourceIndex: Option.some('.kibana_7.11.0_001'),
sourceIndexMappings: actualMappings,
});
@ -1330,10 +1330,10 @@ describe('migrations v2 model', () => {
});
});
describe('UPDATE_SOURCE_MAPPINGS', () => {
const checkCompatibleMappingsState: UpdateSourceMappingsState = {
describe('UPDATE_SOURCE_MAPPINGS_PROPERTIES', () => {
const checkCompatibleMappingsState: UpdateSourceMappingsPropertiesState = {
...baseState,
controlState: 'UPDATE_SOURCE_MAPPINGS',
controlState: 'UPDATE_SOURCE_MAPPINGS_PROPERTIES',
sourceIndex: Option.some('.kibana_7.11.0_001') as Option.Some<string>,
sourceIndexMappings: baseState.targetIndexMappings,
aliases: {
@ -1343,8 +1343,8 @@ describe('migrations v2 model', () => {
};
describe('if action succeeds', () => {
test('UPDATE_SOURCE_MAPPINGS -> CLEANUP_UNKNOWN_AND_EXCLUDED', () => {
const res: ResponseType<'UPDATE_SOURCE_MAPPINGS'> = Either.right(
test('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CLEANUP_UNKNOWN_AND_EXCLUDED', () => {
const res: ResponseType<'UPDATE_SOURCE_MAPPINGS_PROPERTIES'> = Either.right(
'update_mappings_succeeded' as const
);
const newState = model(checkCompatibleMappingsState, res);
@ -1358,8 +1358,8 @@ describe('migrations v2 model', () => {
});
describe('if action fails', () => {
test('UPDATE_SOURCE_MAPPINGS -> CHECK_UNKNOWN_DOCUMENTS', () => {
const res: ResponseType<'UPDATE_SOURCE_MAPPINGS'> = Either.left({
test('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CHECK_UNKNOWN_DOCUMENTS', () => {
const res: ResponseType<'UPDATE_SOURCE_MAPPINGS_PROPERTIES'> = Either.left({
type: 'incompatible_mapping_exception',
});
const newState = model(checkCompatibleMappingsState, res);
@ -1461,7 +1461,7 @@ describe('migrations v2 model', () => {
};
test('CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK when response is left wait_for_task_completion_timeout', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK'> = Either.left({
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK'> = Either.left({
message: '[timeout_exception] Timeout waiting for ...',
type: 'wait_for_task_completion_timeout',
});
@ -2201,7 +2201,7 @@ describe('migrations v2 model', () => {
preTransformDocsActions: [someAliasAction],
};
it('PREPARE_COMPATIBLE_MIGRATIONS -> REFRESH_TARGET if action succeeds and we must refresh the index', () => {
it('PREPARE_COMPATIBLE_MIGRATIONS -> REFRESH_SOURCE if action succeeds and we must refresh the index', () => {
const res: ResponseType<'PREPARE_COMPATIBLE_MIGRATION'> = Either.right(
'update_aliases_succeeded'
);
@ -2209,7 +2209,7 @@ describe('migrations v2 model', () => {
{ ...state, mustRefresh: true },
res
) as OutdatedDocumentsSearchOpenPit;
expect(newState.controlState).toEqual('REFRESH_TARGET');
expect(newState.controlState).toEqual('REFRESH_SOURCE');
expect(newState.versionIndexReadyActions).toEqual(Option.none);
});
@ -2222,7 +2222,7 @@ describe('migrations v2 model', () => {
expect(newState.versionIndexReadyActions).toEqual(Option.none);
});
it('PREPARE_COMPATIBLE_MIGRATIONS -> REFRESH_TARGET if action fails because the alias is not found', () => {
it('PREPARE_COMPATIBLE_MIGRATIONS -> REFRESH_SOURCE if action fails because the alias is not found', () => {
const res: ResponseType<'PREPARE_COMPATIBLE_MIGRATION'> = Either.left({
type: 'alias_not_found_exception',
});
@ -2231,7 +2231,7 @@ describe('migrations v2 model', () => {
{ ...state, mustRefresh: true },
res
) as OutdatedDocumentsSearchOpenPit;
expect(newState.controlState).toEqual('REFRESH_TARGET');
expect(newState.controlState).toEqual('REFRESH_SOURCE');
expect(newState.versionIndexReadyActions).toEqual(Option.none);
});
@ -2418,10 +2418,13 @@ describe('migrations v2 model', () => {
targetIndex: '.kibana_7.11.0_001',
};
it('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS if mappings do not match', () => {
it('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES if mappings do not match', () => {
const res: ResponseType<'CHECK_TARGET_MAPPINGS'> = Either.right({ match: false });
const newState = model(checkTargetMappingsState, res) as UpdateTargetMappingsState;
expect(newState.controlState).toBe('UPDATE_TARGET_MAPPINGS');
const newState = model(
checkTargetMappingsState,
res
) as UpdateTargetMappingsPropertiesState;
expect(newState.controlState).toBe('UPDATE_TARGET_MAPPINGS_PROPERTIES');
});
it('CHECK_TARGET_MAPPINGS -> CHECK_VERSION_INDEX_READY_ACTIONS if mappings match', () => {
@ -2442,7 +2445,7 @@ describe('migrations v2 model', () => {
it('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT if action succeeded', () => {
const res: ResponseType<'REFRESH_TARGET'> = Either.right({ refreshed: true });
const newState = model(state, res) as UpdateTargetMappingsState;
const newState = model(state, res) as UpdateTargetMappingsPropertiesState;
expect(newState.controlState).toBe('OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT');
});
});
@ -2651,41 +2654,41 @@ describe('migrations v2 model', () => {
});
});
describe('UPDATE_TARGET_MAPPINGS', () => {
const updateTargetMappingsState: UpdateTargetMappingsState = {
describe('UPDATE_TARGET_MAPPINGS_PROPERTIES', () => {
const updateTargetMappingsState: UpdateTargetMappingsPropertiesState = {
...baseState,
controlState: 'UPDATE_TARGET_MAPPINGS',
controlState: 'UPDATE_TARGET_MAPPINGS_PROPERTIES',
versionIndexReadyActions: Option.none,
sourceIndex: Option.some('.kibana') as Option.Some<string>,
targetIndex: '.kibana_7.11.0_001',
};
test('UPDATE_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS'> = Either.right({
test('UPDATE_TARGET_MAPPINGS_PROPERTIES -> UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_PROPERTIES'> = Either.right({
taskId: 'update target mappings task',
});
const newState = model(
updateTargetMappingsState,
res
) as UpdateTargetMappingsWaitForTaskState;
expect(newState.controlState).toEqual('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK');
) as UpdateTargetMappingsPropertiesWaitForTaskState;
expect(newState.controlState).toEqual('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK');
expect(newState.updateTargetMappingsTaskId).toEqual('update target mappings task');
expect(newState.retryCount).toEqual(0);
expect(newState.retryDelay).toEqual(0);
});
});
describe('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK', () => {
const updateTargetMappingsWaitForTaskState: UpdateTargetMappingsWaitForTaskState = {
describe('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK', () => {
const updateTargetMappingsWaitForTaskState: UpdateTargetMappingsPropertiesWaitForTaskState = {
...baseState,
controlState: 'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK',
controlState: 'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK',
versionIndexReadyActions: Option.none,
sourceIndex: Option.some('.kibana') as Option.Some<string>,
targetIndex: '.kibana_7.11.0_001',
updateTargetMappingsTaskId: 'update target mappings task',
};
test('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_META if response is right', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK'> = Either.right(
test('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_META if response is right', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK'> = Either.right(
'pickup_updated_mappings_succeeded'
);
@ -2698,28 +2701,28 @@ describe('migrations v2 model', () => {
expect(newState.retryDelay).toEqual(0);
});
test('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK when response is left wait_for_task_completion_timeout', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK'> = Either.left({
test('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK when response is left wait_for_task_completion_timeout', () => {
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK'> = Either.left({
message: '[timeout_exception] Timeout waiting for ...',
type: 'wait_for_task_completion_timeout',
});
const newState = model(
updateTargetMappingsWaitForTaskState,
res
) as UpdateTargetMappingsWaitForTaskState;
expect(newState.controlState).toEqual('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK');
) as UpdateTargetMappingsPropertiesWaitForTaskState;
expect(newState.controlState).toEqual('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK');
expect(newState.retryCount).toEqual(1);
expect(newState.retryDelay).toEqual(2000);
});
test('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK with incremented retry count when response is left wait_for_task_completion_timeout a second time', () => {
test('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK with incremented retry count when response is left wait_for_task_completion_timeout a second time', () => {
const state = Object.assign({}, updateTargetMappingsWaitForTaskState, { retryCount: 1 });
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK'> = Either.left({
const res: ResponseType<'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK'> = Either.left({
message: '[timeout_exception] Timeout waiting for ...',
type: 'wait_for_task_completion_timeout',
});
const newState = model(state, res) as UpdateTargetMappingsWaitForTaskState;
expect(newState.controlState).toEqual('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK');
const newState = model(state, res) as UpdateTargetMappingsPropertiesWaitForTaskState;
expect(newState.controlState).toEqual('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK');
expect(newState.retryCount).toEqual(2);
expect(newState.retryDelay).toEqual(4000);
});

View file

@ -445,7 +445,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
} else {
return {
...stateP,
controlState: 'UPDATE_SOURCE_MAPPINGS',
controlState: 'UPDATE_SOURCE_MAPPINGS_PROPERTIES',
};
}
} else if (Either.isLeft(res)) {
@ -464,7 +464,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
} else {
return throwBadResponse(stateP, res);
}
} else if (stateP.controlState === 'UPDATE_SOURCE_MAPPINGS') {
} else if (stateP.controlState === 'UPDATE_SOURCE_MAPPINGS_PROPERTIES') {
const res = resW as ExcludeRetryableEsError<ResponseType<typeof stateP.controlState>>;
if (Either.isRight(res)) {
return {
@ -592,7 +592,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
if (Either.isRight(res)) {
return {
...stateP,
controlState: stateP.mustRefresh ? 'REFRESH_TARGET' : 'OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT',
controlState: stateP.mustRefresh ? 'REFRESH_SOURCE' : 'OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT',
};
} else if (Either.isLeft(res)) {
// Note: if multiple newer Kibana versions are competing with each other to perform a migration,
@ -604,7 +604,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
return {
...stateP,
controlState: stateP.mustRefresh
? 'REFRESH_TARGET'
? 'REFRESH_SOURCE'
: 'OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT',
};
} else {
@ -613,6 +613,16 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
} else {
throwBadResponse(stateP, res);
}
} else if (stateP.controlState === 'REFRESH_SOURCE') {
const res = resW as ExcludeRetryableEsError<ResponseType<typeof stateP.controlState>>;
if (Either.isRight(res)) {
return {
...stateP,
controlState: 'OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT',
};
} else {
throwBadResponse(stateP, res);
}
} else if (stateP.controlState === 'CHECK_UNKNOWN_DOCUMENTS') {
const res = resW as ExcludeRetryableEsError<ResponseType<typeof stateP.controlState>>;
@ -970,7 +980,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
// index_not_found_exception means another instance already completed
// the MARK_VERSION_INDEX_READY step and removed the temp index
// We still perform the REFRESH_TARGET, OUTDATED_DOCUMENTS_* and
// UPDATE_TARGET_MAPPINGS steps since we might have plugins enabled
// UPDATE_TARGET_MAPPINGS_PROPERTIES steps since we might have plugins enabled
// which the other instances don't.
return {
...stateP,
@ -1225,7 +1235,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
if (!res.right.match) {
return {
...stateP,
controlState: 'UPDATE_TARGET_MAPPINGS',
controlState: 'UPDATE_TARGET_MAPPINGS_PROPERTIES',
};
}
@ -1237,18 +1247,18 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
} else {
throwBadResponse(stateP, res as never);
}
} else if (stateP.controlState === 'UPDATE_TARGET_MAPPINGS') {
} else if (stateP.controlState === 'UPDATE_TARGET_MAPPINGS_PROPERTIES') {
const res = resW as ExcludeRetryableEsError<ResponseType<typeof stateP.controlState>>;
if (Either.isRight(res)) {
return {
...stateP,
controlState: 'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK',
controlState: 'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK',
updateTargetMappingsTaskId: res.right.taskId,
};
} else {
throwBadResponse(stateP, res as never);
}
} else if (stateP.controlState === 'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK') {
} else if (stateP.controlState === 'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK') {
const res = resW as ExcludeRetryableEsError<ResponseType<typeof stateP.controlState>>;
if (Either.isRight(res)) {
return {

View file

@ -11,7 +11,6 @@ import { omit } from 'lodash';
import type {
AllActionStates,
CalculateExcludeFiltersState,
UpdateSourceMappingsState,
CheckTargetMappingsState,
CheckUnknownDocumentsState,
CleanupUnknownAndExcluded,
@ -33,6 +32,7 @@ import type {
OutdatedDocumentsSearchRead,
OutdatedDocumentsTransform,
PrepareCompatibleMigration,
RefreshSource,
RefreshTarget,
ReindexSourceToTempClosePit,
ReindexSourceToTempIndexBulk,
@ -43,8 +43,10 @@ import type {
SetTempWriteBlock,
State,
TransformedDocumentsBulkIndex,
UpdateTargetMappingsState,
UpdateTargetMappingsWaitForTaskState,
UpdateSourceMappingsPropertiesState,
UpdateTargetMappingsMeta,
UpdateTargetMappingsPropertiesState,
UpdateTargetMappingsPropertiesWaitForTaskState,
WaitForMigrationCompletionState,
WaitForYellowSourceState,
} from './state';
@ -72,7 +74,7 @@ export const nextActionMap = (client: ElasticsearchClient, transformRawDocs: Tra
Actions.fetchIndices({ client, indices: [state.currentAlias, state.versionAlias] }),
WAIT_FOR_YELLOW_SOURCE: (state: WaitForYellowSourceState) =>
Actions.waitForIndexStatus({ client, index: state.sourceIndex.value, status: 'yellow' }),
UPDATE_SOURCE_MAPPINGS: (state: UpdateSourceMappingsState) =>
UPDATE_SOURCE_MAPPINGS_PROPERTIES: (state: UpdateSourceMappingsPropertiesState) =>
Actions.updateMappings({
client,
index: state.sourceIndex.value, // attempt to update source mappings in-place
@ -98,6 +100,8 @@ export const nextActionMap = (client: ElasticsearchClient, transformRawDocs: Tra
}),
PREPARE_COMPATIBLE_MIGRATION: (state: PrepareCompatibleMigration) =>
Actions.updateAliases({ client, aliasActions: state.preTransformDocsActions }),
REFRESH_SOURCE: (state: RefreshSource) =>
Actions.refreshIndex({ client, index: state.sourceIndex.value }),
CHECK_UNKNOWN_DOCUMENTS: (state: CheckUnknownDocumentsState) =>
Actions.checkForUnknownDocs({
client,
@ -161,29 +165,31 @@ export const nextActionMap = (client: ElasticsearchClient, transformRawDocs: Tra
CLONE_TEMP_TO_TARGET: (state: CloneTempToSource) =>
Actions.cloneIndex({ client, source: state.tempIndex, target: state.targetIndex }),
REFRESH_TARGET: (state: RefreshTarget) =>
Actions.refreshIndex({ client, targetIndex: state.targetIndex }),
Actions.refreshIndex({ client, index: state.targetIndex }),
CHECK_TARGET_MAPPINGS: (state: CheckTargetMappingsState) =>
Actions.checkTargetMappings({
actualMappings: state.targetIndexRawMappings,
expectedMappings: state.targetIndexMappings,
}),
UPDATE_TARGET_MAPPINGS: (state: UpdateTargetMappingsState) =>
UPDATE_TARGET_MAPPINGS_PROPERTIES: (state: UpdateTargetMappingsPropertiesState) =>
Actions.updateAndPickupMappings({
client,
index: state.targetIndex,
mappings: omit(state.targetIndexMappings, ['_meta']), // ._meta property will be updated on a later step
}),
UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK: (state: UpdateTargetMappingsWaitForTaskState) =>
UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK: (
state: UpdateTargetMappingsPropertiesWaitForTaskState
) =>
Actions.waitForPickupUpdatedMappingsTask({
client,
taskId: state.updateTargetMappingsTaskId,
timeout: '60s',
}),
UPDATE_TARGET_MAPPINGS_META: (state: UpdateTargetMappingsState) =>
UPDATE_TARGET_MAPPINGS_META: (state: UpdateTargetMappingsMeta) =>
Actions.updateMappings({
client,
index: state.targetIndex,
mappings: state.targetIndexMappings,
mappings: omit(state.targetIndexMappings, 'properties'),
}),
CHECK_VERSION_INDEX_READY_ACTIONS: () => Actions.noop,
OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT: (state: OutdatedDocumentsSearchOpenPit) =>
@ -200,7 +206,7 @@ export const nextActionMap = (client: ElasticsearchClient, transformRawDocs: Tra
OUTDATED_DOCUMENTS_SEARCH_CLOSE_PIT: (state: OutdatedDocumentsSearchClosePit) =>
Actions.closePit({ client, pitId: state.pitId }),
OUTDATED_DOCUMENTS_REFRESH: (state: OutdatedDocumentsRefresh) =>
Actions.refreshIndex({ client, targetIndex: state.targetIndex }),
Actions.refreshIndex({ client, index: state.targetIndex }),
OUTDATED_DOCUMENTS_TRANSFORM: (state: OutdatedDocumentsTransform) =>
Actions.transformDocs({ transformRawDocs, outdatedDocuments: state.outdatedDocuments }),
TRANSFORMED_DOCUMENTS_BULK_INDEX: (state: TransformedDocumentsBulkIndex) =>

View file

@ -229,6 +229,11 @@ export interface PrepareCompatibleMigration extends PostInitWithSource {
readonly mustRefresh?: boolean;
}
export interface RefreshSource extends PostInitWithSource {
/** Refresh source index before searching for outdated docs */
readonly controlState: 'REFRESH_SOURCE';
}
export interface FatalState extends BaseState {
/** Migration terminated with a failure */
readonly controlState: 'FATAL';
@ -243,8 +248,8 @@ export interface WaitForYellowSourceState extends BaseWithSource {
readonly aliases: Record<string, string | undefined>;
}
export interface UpdateSourceMappingsState extends BaseState {
readonly controlState: 'UPDATE_SOURCE_MAPPINGS';
export interface UpdateSourceMappingsPropertiesState extends BaseState {
readonly controlState: 'UPDATE_SOURCE_MAPPINGS_PROPERTIES';
readonly sourceIndex: Option.Some<string>;
readonly sourceIndexMappings: IndexMapping;
readonly aliases: Record<string, string | undefined>;
@ -335,14 +340,14 @@ export interface CheckTargetMappingsState extends PostInitState {
readonly sourceIndexMappings?: IndexMapping;
}
export interface UpdateTargetMappingsState extends PostInitState {
export interface UpdateTargetMappingsPropertiesState extends PostInitState {
/** Update the mappings of the target index */
readonly controlState: 'UPDATE_TARGET_MAPPINGS';
readonly controlState: 'UPDATE_TARGET_MAPPINGS_PROPERTIES';
}
export interface UpdateTargetMappingsWaitForTaskState extends PostInitState {
export interface UpdateTargetMappingsPropertiesWaitForTaskState extends PostInitState {
/** Update the mappings of the target index */
readonly controlState: 'UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK';
readonly controlState: 'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK';
readonly updateTargetMappingsTaskId: string;
}
@ -417,7 +422,7 @@ export interface MarkVersionIndexReady extends PostInitState {
* cloning a source index or creating a new index.
*
* To account for newly installed or enabled plugins, Kibana will still
* perform the `UPDATE_TARGET_MAPPINGS*` and `OUTDATED_DOCUMENTS_*` steps
* perform the `UPDATE_TARGET_MAPPINGS_PROPERTIES*` and `OUTDATED_DOCUMENTS_*` steps
* every time it is restarted.
*/
readonly controlState: 'MARK_VERSION_INDEX_READY';
@ -492,46 +497,47 @@ export interface LegacyDeleteState extends LegacyBaseState {
}
export type State = Readonly<
| FatalState
| InitState
| PrepareCompatibleMigration
| CalculateExcludeFiltersState
| CheckTargetMappingsState
| CheckUnknownDocumentsState
| CheckVersionIndexReadyActions
| CleanupUnknownAndExcluded
| CleanupUnknownAndExcludedWaitForTaskState
| WaitForMigrationCompletionState
| DoneState
| WaitForYellowSourceState
| UpdateSourceMappingsState
| CheckUnknownDocumentsState
| SetSourceWriteBlockState
| CalculateExcludeFiltersState
| CloneTempToSource
| CreateNewTargetState
| CreateReindexTempState
| ReindexSourceToTempOpenPit
| ReindexSourceToTempRead
| ReindexSourceToTempClosePit
| ReindexSourceToTempTransform
| ReindexSourceToTempIndexBulk
| SetTempWriteBlock
| CloneTempToSource
| CheckTargetMappingsState
| UpdateTargetMappingsState
| UpdateTargetMappingsWaitForTaskState
| UpdateTargetMappingsMeta
| CheckVersionIndexReadyActions
| OutdatedDocumentsSearchOpenPit
| OutdatedDocumentsSearchRead
| OutdatedDocumentsSearchClosePit
| OutdatedDocumentsTransform
| RefreshTarget
| OutdatedDocumentsRefresh
| MarkVersionIndexReady
| MarkVersionIndexReadyConflict
| TransformedDocumentsBulkIndex
| DoneState
| FatalState
| InitState
| LegacyCreateReindexTargetState
| LegacySetWriteBlockState
| LegacyDeleteState
| LegacyReindexState
| LegacyReindexWaitForTaskState
| LegacyDeleteState
| LegacySetWriteBlockState
| MarkVersionIndexReady
| MarkVersionIndexReadyConflict
| OutdatedDocumentsRefresh
| OutdatedDocumentsSearchClosePit
| OutdatedDocumentsSearchOpenPit
| OutdatedDocumentsSearchRead
| OutdatedDocumentsTransform
| PrepareCompatibleMigration
| RefreshSource
| RefreshTarget
| ReindexSourceToTempClosePit
| ReindexSourceToTempIndexBulk
| ReindexSourceToTempOpenPit
| ReindexSourceToTempRead
| ReindexSourceToTempTransform
| SetSourceWriteBlockState
| SetTempWriteBlock
| TransformedDocumentsBulkIndex
| UpdateSourceMappingsPropertiesState
| UpdateTargetMappingsMeta
| UpdateTargetMappingsPropertiesState
| UpdateTargetMappingsPropertiesWaitForTaskState
| WaitForMigrationCompletionState
| WaitForYellowSourceState
>;
export type AllControlStates = State['controlState'];

View file

@ -60,7 +60,7 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => {
});
describe('when the indices are aligned with the stack version', () => {
it('skips UPDATE_TARGET_MAPPINGS if there are no changes in the mappings', async () => {
it('skips UPDATE_TARGET_MAPPINGS_PROPERTIES if there are no changes in the mappings', async () => {
const { startES } = createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
settings: {
@ -92,8 +92,8 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => {
logs = await fs.readFile(logFilePath, 'utf-8');
expect(logs).not.toMatch('CREATE_NEW_TARGET');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> CHECK_VERSION_INDEX_READY_ACTIONS');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS_PROPERTIES');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS_META');
});
});
@ -101,7 +101,7 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => {
describe('when upgrading to a newer stack version', () => {
const currentVersion = Env.createDefault(REPO_ROOT, getEnvOptions()).packageInfo.version;
it('runs UPDATE_TARGET_MAPPINGS when mappings have changed', async () => {
it('runs UPDATE_TARGET_MAPPINGS_PROPERTIES when mappings have changed', async () => {
const { startES } = createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
settings: {
@ -123,9 +123,13 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => {
// Check for migration steps present in the logs
logs = await fs.readFile(logFilePath, 'utf-8');
expect(logs).not.toMatch('CREATE_NEW_TARGET');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_META');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES');
expect(logs).toMatch(
'UPDATE_TARGET_MAPPINGS_PROPERTIES -> UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK'
);
expect(logs).toMatch(
'UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK -> UPDATE_TARGET_MAPPINGS_META'
);
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_META -> CHECK_VERSION_INDEX_READY_ACTIONS');
expect(logs).toMatch('Migration completed');
});

View file

@ -80,8 +80,8 @@ describe('when upgrading to a new stack version', () => {
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> PREPARE_COMPATIBLE_MIGRATION'
);
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_TARGET');
expect(logs).toMatch('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT');
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_SOURCE');
expect(logs).toMatch('REFRESH_SOURCE -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> CHECK_VERSION_INDEX_READY_ACTIONS');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> DONE');
});
@ -175,8 +175,8 @@ describe('when upgrading to a new stack version', () => {
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> PREPARE_COMPATIBLE_MIGRATION.'
);
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_TARGET.');
expect(logs).toMatch('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_SOURCE.');
expect(logs).toMatch('REFRESH_SOURCE -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> DONE.');
@ -216,9 +216,9 @@ describe('when upgrading to a new stack version', () => {
const logs = await readLog();
expect(logs).toMatch('INIT -> WAIT_FOR_YELLOW_SOURCE.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES.');
// this step is run only if mappings are compatible but NOT equal
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
// we gotta inform that we are deleting unknown documents too (discardUnknownObjects: true),
expect(logs).toMatch(
'Kibana has been configured to discard unknown documents for this migration.'
@ -232,9 +232,9 @@ describe('when upgrading to a new stack version', () => {
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> PREPARE_COMPATIBLE_MIGRATION.'
);
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_TARGET.');
expect(logs).toMatch('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS.');
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_SOURCE.');
expect(logs).toMatch('REFRESH_SOURCE -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_META -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> DONE.');
});
@ -311,8 +311,8 @@ describe('when upgrading to a new stack version', () => {
const logs = await readLog();
expect(logs).toMatch('INIT -> WAIT_FOR_YELLOW_SOURCE.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS.'); // this step is run only if mappings are compatible but NOT equal
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES.'); // this step is run only if mappings are compatible but NOT equal
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch('CLEANUP_UNKNOWN_AND_EXCLUDED -> FATAL.');
});
@ -323,17 +323,17 @@ describe('when upgrading to a new stack version', () => {
const logs = await readLog();
expect(logs).toMatch('INIT -> WAIT_FOR_YELLOW_SOURCE.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED -> CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK.'
);
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> PREPARE_COMPATIBLE_MIGRATION.'
);
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_TARGET.');
expect(logs).toMatch('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS.');
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_SOURCE.');
expect(logs).toMatch('REFRESH_SOURCE -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_META -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> DONE.');
@ -362,10 +362,10 @@ describe('when upgrading to a new stack version', () => {
const logs = await readLog();
expect(logs).toMatch('INIT -> WAIT_FOR_YELLOW_SOURCE');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS -> CHECK_UNKNOWN_DOCUMENTS.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CHECK_UNKNOWN_DOCUMENTS.');
expect(logs).toMatch('CHECK_UNKNOWN_DOCUMENTS -> SET_SOURCE_WRITE_BLOCK.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_META -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> MARK_VERSION_INDEX_READY.');
expect(logs).toMatch('MARK_VERSION_INDEX_READY -> DONE');

View file

@ -53,15 +53,15 @@ describe.skip('when migrating to a new version', () => {
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> PREPARE_COMPATIBLE_MIGRATION.'
);
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_TARGET.');
expect(logs).toMatch('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_SOURCE.');
expect(logs).toMatch('REFRESH_SOURCE -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> DONE.');
expect(logs).not.toMatch('CREATE_NEW_TARGET');
expect(logs).not.toMatch('CHECK_UNKNOWN_DOCUMENTS');
expect(logs).not.toMatch('REINDEX');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS_PROPERTIES');
});
});
@ -74,17 +74,17 @@ describe.skip('when migrating to a new version', () => {
const logs = await readLog();
expect(logs).toMatch('INIT -> WAIT_FOR_YELLOW_SOURCE.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CLEANUP_UNKNOWN_AND_EXCLUDED.');
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED -> CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK.'
);
expect(logs).toMatch(
'CLEANUP_UNKNOWN_AND_EXCLUDED_WAIT_FOR_TASK -> PREPARE_COMPATIBLE_MIGRATION.'
);
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_TARGET.');
expect(logs).toMatch('REFRESH_TARGET -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS.');
expect(logs).toMatch('PREPARE_COMPATIBLE_MIGRATION -> REFRESH_SOURCE.');
expect(logs).toMatch('REFRESH_SOURCE -> OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_META -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> DONE.');
@ -103,9 +103,9 @@ describe.skip('when migrating to a new version', () => {
const logs = await readLog();
expect(logs).toMatch('INIT -> WAIT_FOR_YELLOW_SOURCE.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS -> CHECK_UNKNOWN_DOCUMENTS.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS.');
expect(logs).toMatch('WAIT_FOR_YELLOW_SOURCE -> UPDATE_SOURCE_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_SOURCE_MAPPINGS_PROPERTIES -> CHECK_UNKNOWN_DOCUMENTS.');
expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES.');
expect(logs).toMatch('UPDATE_TARGET_MAPPINGS_META -> CHECK_VERSION_INDEX_READY_ACTIONS.');
expect(logs).toMatch('CHECK_VERSION_INDEX_READY_ACTIONS -> MARK_VERSION_INDEX_READY.');
expect(logs).toMatch('MARK_VERSION_INDEX_READY -> DONE.');
@ -129,7 +129,7 @@ describe.skip('when migrating to a new version', () => {
expect(logs).not.toMatch('CLEANUP_UNKNOWN_AND_EXCLUCED');
expect(logs).not.toMatch('CREATE_NEW_TARGET');
expect(logs).not.toMatch('PREPARE_COMPATIBLE_MIGRATION');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS');
expect(logs).not.toMatch('UPDATE_TARGET_MAPPINGS_PROPERTIES');
// clear the system index for next test
await esClient?.indices.delete({ index: `${defaultKibanaIndex}_${currentVersion}_001` });

View file

@ -43,6 +43,7 @@ import type { ISavedObjectsRepository } from '@kbn/core-saved-objects-api-server
import { getDocLinks, getDocLinksMeta } from '@kbn/doc-links';
import type { DocLinksServiceStart } from '@kbn/core-doc-links-server';
import { baselineDocuments, baselineTypes } from './kibana_migrator_test_kit.fixtures';
import { delay } from './test_utils';
export const defaultLogFilePath = Path.join(__dirname, 'kibana_migrator_test_kit.log');
@ -384,6 +385,7 @@ export const getIncompatibleMappingsMigrator = async ({
};
export const readLog = async (logFilePath: string = defaultLogFilePath): Promise<string> => {
await delay(0.1); // give the logger enough time to write to the file
return await fs.readFile(logFilePath, 'utf-8');
};