Skip to content

Commit

Permalink
Remove deprecated dependency, add extra integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Jun 20, 2023
1 parent a751935 commit 84bd400
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
const nonTypeFields = res.right.updatedHashes.filter(
(field) => !typeFields.includes(field)
);
console.log('TYPE vs NON_TYPE', typeFields, nonTypeFields);

if (nonTypeFields.length) {
return {
...stateP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@kbn/core-saved-objects-base-server-mocks",
"@kbn/core-elasticsearch-server-internal",
"@kbn/core-node-server",
"@kbn/core-saved-objects-api-server-internal",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import type { TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import {
clearLog,
createBaseline,
currentVersion,
defaultKibanaIndex,
defaultLogFilePath,
getCompatibleMappingsMigrator,
getIncompatibleMappingsMigrator,
startElasticsearch,
} from '../kibana_migrator_test_kit';
import '../jest_matchers';
import { delay, parseLogFile } from '../test_utils';
import { IndexMappingMeta } from '@kbn/core-saved-objects-base-server-internal';

export const logFilePath = Path.join(__dirname, 'pickup_updated_types_only.test.log');

Expand Down Expand Up @@ -59,6 +62,29 @@ describe('pickupUpdatedMappings', () => {
'Kibana is performing a compatible update and it will update the following SO types so that ES can pickup the updated mappings: complex.'
);
});

it('should pickup ALL documents if any root fields have been updated', async () => {
const { runMigrations, client } = await getCompatibleMappingsMigrator();

// we tamper the baseline mappings to simulate some root fields changes
const baselineMappings = await client.indices.getMapping({ index: defaultKibanaIndex });
const _meta = baselineMappings[`${defaultKibanaIndex}_${currentVersion}_001`].mappings
._meta as IndexMappingMeta;
_meta.migrationMappingPropertyHashes!.namespace =
_meta.migrationMappingPropertyHashes!.namespace + '_tampered';
await client.indices.putMapping({ index: defaultKibanaIndex, _meta });

await runMigrations();

const logs = await parseLogFile(defaultLogFilePath);

expect(logs).toContainLogEntry(
'Kibana is performing a compatible update and some root fields have been updated. All SO documents must be updated. Updated root fields: namespace.'
);
expect(logs).not.toContainLogEntry(
'Kibana is performing a compatible update and it will update the following SO types so that ES can pickup the updated mappings'
);
});
});

afterAll(async () => {
Expand Down

0 comments on commit 84bd400

Please sign in to comment.