[7.x] Backport v2 SO migrations, disabled in FTR tests (#89297) (#89903)

* Enable v2 so migrations, disable in FTR tests (#89297)

* Enable v2 so migrations, disable in FTR tests

* Disable v2 migrations for ui_settings integration tests

* Disable v2 migrations for reporting without serucity api integration test
# Conflicts:
#	test/common/config.js

* migrations v2: fix snapshot builds (#89541)

* migrations v2: fix snapshot builds

* Revert "Fix sharing saved objects phase 2 CI (#89056)"

This reverts commit 8263d47d37.

* Fix documentMigrator for snapshot releases (#89936)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Rudolf Meijering 2021-02-09 09:52:22 +01:00 committed by GitHub
parent 5c92b57f51
commit 735d9a9993
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 20 deletions

View file

@ -206,20 +206,6 @@ describe('DocumentMigrator', () => {
);
});
it('coerces the current Kibana version if it has a hyphen', () => {
const validDefinition = {
kibanaVersion: '3.2.0-SNAPSHOT',
typeRegistry: createRegistry({
name: 'foo',
convertToMultiNamespaceTypeVersion: '3.2.0',
namespaceType: 'multiple',
}),
minimumConvertVersion: '0.0.0',
log: mockLogger,
};
expect(() => new DocumentMigrator(validDefinition)).not.toThrowError();
});
it('validates convertToMultiNamespaceTypeVersion is not used on a patch version', () => {
const invalidDefinition = {
kibanaVersion: '3.2.3',

View file

@ -159,11 +159,10 @@ export class DocumentMigrator implements VersionedTransformer {
*/
constructor({
typeRegistry,
kibanaVersion: rawKibanaVersion,
kibanaVersion,
minimumConvertVersion = DEFAULT_MINIMUM_CONVERT_VERSION,
log,
}: DocumentMigratorOptions) {
const kibanaVersion = rawKibanaVersion.split('-')[0]; // coerce a semver-like string (x.y.z-SNAPSHOT) or prerelease version (x.y.z-alpha) to a regular semver (x.y.z)
validateMigrationDefinition(typeRegistry, kibanaVersion, minimumConvertVersion);
this.documentMigratorOptions = { typeRegistry, kibanaVersion, log };

View file

@ -14,6 +14,16 @@ import { loggingSystemMock } from '../../../logging/logging_system.mock';
import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry';
import { SavedObjectsType } from '../../types';
import { errors as esErrors } from '@elastic/elasticsearch';
import { DocumentMigrator } from '../core/document_migrator';
jest.mock('../core/document_migrator', () => {
return {
// Create a mock for spying on the constructor
DocumentMigrator: jest.fn().mockImplementation((...args) => {
const { DocumentMigrator: RealDocMigrator } = jest.requireActual('../core/document_migrator');
return new RealDocMigrator(args[0]);
}),
};
});
const createRegistry = (types: Array<Partial<SavedObjectsType>>) => {
const registry = new SavedObjectTypeRegistry();
@ -31,6 +41,18 @@ const createRegistry = (types: Array<Partial<SavedObjectsType>>) => {
};
describe('KibanaMigrator', () => {
beforeEach(() => {
(DocumentMigrator as jest.Mock).mockClear();
});
describe('constructor', () => {
it('coerces the current Kibana version if it has a hyphen', () => {
const options = mockOptions();
options.kibanaVersion = '3.2.1-SNAPSHOT';
const migrator = new KibanaMigrator(options);
expect(migrator.kibanaVersion).toEqual('3.2.1');
expect((DocumentMigrator as jest.Mock).mock.calls[0][0].kibanaVersion).toEqual('3.2.1');
});
});
describe('getActiveMappings', () => {
it('returns full index mappings w/ core properties', () => {
const options = mockOptions();

View file

@ -91,15 +91,14 @@ export class KibanaMigrator {
}: KibanaMigratorOptions) {
this.client = client;
this.kibanaConfig = kibanaConfig;
this.kibanaVersion = kibanaVersion;
this.savedObjectsConfig = savedObjectsConfig;
this.typeRegistry = typeRegistry;
this.serializer = new SavedObjectsSerializer(this.typeRegistry);
this.mappingProperties = mergeTypes(this.typeRegistry.getAllTypes());
this.log = logger;
this.kibanaVersion = kibanaVersion;
this.kibanaVersion = kibanaVersion.split('-')[0]; // coerce a semver-like string (x.y.z-SNAPSHOT) or prerelease version (x.y.z-alpha) to a regular semver (x.y.z);
this.documentMigrator = new DocumentMigrator({
kibanaVersion,
kibanaVersion: this.kibanaVersion,
typeRegistry,
log: this.log,
});

View file

@ -18,7 +18,7 @@ export const savedObjectsMigrationConfig = {
pollInterval: schema.number({ defaultValue: 1500 }),
skip: schema.boolean({ defaultValue: false }),
// TODO migrationsV2: remove/deprecate once we release migrations v2
enableV2: schema.boolean({ defaultValue: false }),
enableV2: schema.boolean({ defaultValue: true }),
}),
};

View file

@ -37,6 +37,9 @@ export async function startServers() {
adjustTimeout: (t) => jest.setTimeout(t),
settings: {
kbn: {
migrations: {
enableV2: false,
},
uiSettings: {
overrides: {
foo: 'bar',

View file

@ -55,6 +55,8 @@ export default function () {
`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'newsfeed')}`,
`--newsfeed.service.urlRoot=${servers.kibana.protocol}://${servers.kibana.hostname}:${servers.kibana.port}`,
`--newsfeed.service.pathTemplate=/api/_newsfeed-FTS-external-service-simulators/kibana/v{VERSION}.json`,
// Disable v2 migrations in tests for now
'--migrations.enableV2=false',
],
},
services,

View file

@ -33,6 +33,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
kbnTestServer: {
...apiConfig.get('kbnTestServer'),
serverArgs: [
`--migrations.enableV2=false`,
`--elasticsearch.hosts=${formatUrl(esTestConfig.getUrlParts())}`,
`--logging.json=false`,
`--server.maxPayloadBytes=1679958`,