* [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) Co-authored-by: spalger <spalger@users.noreply.github.com> # Conflicts: # test/api_integration/apis/suggestions/suggestions.js # test/functional/apps/discover/_large_string.ts # test/functional/apps/visualize/index.ts # x-pack/test/functional/apps/infra/feature_controls/logs_security.ts # x-pack/test/functional/apps/saved_objects_management/import_saved_objects_between_versions_6.x_7.x.ts # x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts * convert references to `saved_objects/basic` archive * adapt other `saved_objects/*` archives * update management/saved_obejcts/relationships archives * replace old monitoring setup() usage * remove reference to `empty_kibana` archive Co-authored-by: spalger <spalger@users.noreply.github.com>
260 lines
9.7 KiB
TypeScript
260 lines
9.7 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import expect from '@kbn/expect';
|
|
import type { DomainDeprecationDetails, DeprecationsGetResponse } from 'src/core/server/types';
|
|
import type { ResolveDeprecationResponse } from 'src/core/public';
|
|
import { PluginFunctionalProviderContext } from '../../services';
|
|
|
|
export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) {
|
|
const supertest = getService('supertest');
|
|
const esArchiver = getService('esArchiver');
|
|
const PageObjects = getPageObjects(['common']);
|
|
const browser = getService('browser');
|
|
|
|
const CorePluginDeprecationsPluginDeprecations: DomainDeprecationDetails[] = [
|
|
{
|
|
level: 'critical',
|
|
message:
|
|
'"corePluginDeprecations.oldProperty" is deprecated and has been replaced by "corePluginDeprecations.newProperty"',
|
|
correctiveActions: {
|
|
manualSteps: [
|
|
'Replace "corePluginDeprecations.oldProperty" with "corePluginDeprecations.newProperty" in the Kibana config file, CLI flag, or environment variable (in Docker only).',
|
|
],
|
|
},
|
|
deprecationType: 'config',
|
|
domainId: 'corePluginDeprecations',
|
|
},
|
|
{
|
|
level: 'critical',
|
|
message: 'corePluginDeprecations.noLongerUsed is deprecated and is no longer used',
|
|
correctiveActions: {
|
|
manualSteps: [
|
|
'Remove "corePluginDeprecations.noLongerUsed" from the Kibana config file, CLI flag, or environment variable (in Docker only)',
|
|
],
|
|
},
|
|
deprecationType: 'config',
|
|
domainId: 'corePluginDeprecations',
|
|
},
|
|
{
|
|
level: 'critical',
|
|
message:
|
|
'Kibana plugin functional tests will no longer allow corePluginDeprecations.secret config to be set to anything except 42.',
|
|
correctiveActions: {
|
|
manualSteps: [
|
|
'This is an intentional deprecation for testing with no intention for having it fixed!',
|
|
],
|
|
},
|
|
documentationUrl: 'config-secret-doc-url',
|
|
deprecationType: 'config',
|
|
domainId: 'corePluginDeprecations',
|
|
},
|
|
{
|
|
message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
|
|
documentationUrl: 'test-url',
|
|
level: 'warning',
|
|
correctiveActions: {
|
|
manualSteps: ['Step a', 'Step b'],
|
|
},
|
|
deprecationType: 'feature',
|
|
domainId: 'corePluginDeprecations',
|
|
},
|
|
{
|
|
message: 'SavedObject test-deprecations-plugin is still being used.',
|
|
documentationUrl: 'another-test-url',
|
|
level: 'critical',
|
|
correctiveActions: {
|
|
manualSteps: ['Step a', 'Step b'],
|
|
},
|
|
domainId: 'corePluginDeprecations',
|
|
},
|
|
];
|
|
|
|
describe('deprecations service', () => {
|
|
before(() => esArchiver.load('test/functional/fixtures/es_archiver/deprecations_service'));
|
|
after(() => esArchiver.unload('test/functional/fixtures/es_archiver/deprecations_service'));
|
|
|
|
describe('GET /api/deprecations/', async () => {
|
|
it('returns registered config deprecations and feature deprecations', async () => {
|
|
const { body } = await supertest.get('/api/deprecations/').set('kbn-xsrf', 'true');
|
|
|
|
const { deprecations } = body as DeprecationsGetResponse;
|
|
expect(Array.isArray(deprecations)).to.be(true);
|
|
const corePluginDeprecations = deprecations.filter(
|
|
({ domainId }) => domainId === 'corePluginDeprecations'
|
|
);
|
|
|
|
expect(corePluginDeprecations).to.eql(CorePluginDeprecationsPluginDeprecations);
|
|
});
|
|
});
|
|
|
|
describe('Public API', () => {
|
|
before(async () => await PageObjects.common.navigateToApp('home'));
|
|
|
|
it('#getAllDeprecations returns all deprecations plugin deprecations', async () => {
|
|
const result = await browser.executeAsync<DomainDeprecationDetails[]>((cb) => {
|
|
return window._coreProvider.start.core.deprecations.getAllDeprecations().then(cb);
|
|
});
|
|
|
|
const corePluginDeprecations = result.filter(
|
|
({ domainId }) => domainId === 'corePluginDeprecations'
|
|
);
|
|
|
|
expect(corePluginDeprecations).to.eql(CorePluginDeprecationsPluginDeprecations);
|
|
});
|
|
|
|
it('#getDeprecations returns domain deprecations', async () => {
|
|
const corePluginDeprecations = await browser.executeAsync<DomainDeprecationDetails[]>(
|
|
(cb) => {
|
|
return window._coreProvider.start.core.deprecations
|
|
.getDeprecations('corePluginDeprecations')
|
|
.then(cb);
|
|
}
|
|
);
|
|
|
|
expect(corePluginDeprecations).to.eql(CorePluginDeprecationsPluginDeprecations);
|
|
});
|
|
|
|
describe('resolveDeprecation', () => {
|
|
it('fails on missing correctiveActions.api', async () => {
|
|
const resolveResult = await browser.executeAsync<ResolveDeprecationResponse>((cb) => {
|
|
return window._coreProvider.start.core.deprecations
|
|
.resolveDeprecation({
|
|
message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
|
|
documentationUrl: 'test-url',
|
|
level: 'warning',
|
|
correctiveActions: {
|
|
manualSteps: ['Step a', 'Step b'],
|
|
},
|
|
domainId: 'corePluginDeprecations',
|
|
})
|
|
.then(cb);
|
|
});
|
|
|
|
expect(resolveResult).to.eql({
|
|
reason: 'deprecation has no correctiveAction via api.',
|
|
status: 'fail',
|
|
});
|
|
});
|
|
|
|
it('fails on bad request from correctiveActions.api', async () => {
|
|
const resolveResult = await browser.executeAsync<ResolveDeprecationResponse>((cb) => {
|
|
return window._coreProvider.start.core.deprecations
|
|
.resolveDeprecation({
|
|
message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
|
|
documentationUrl: 'test-url',
|
|
level: 'warning',
|
|
correctiveActions: {
|
|
api: {
|
|
method: 'POST',
|
|
path: '/api/core_deprecations_resolve/',
|
|
body: {
|
|
mockFail: true,
|
|
},
|
|
},
|
|
manualSteps: ['Step a', 'Step b'],
|
|
},
|
|
domainId: 'corePluginDeprecations',
|
|
})
|
|
.then(cb);
|
|
});
|
|
|
|
expect(resolveResult).to.eql({
|
|
reason: 'Mocking api failure',
|
|
status: 'fail',
|
|
});
|
|
});
|
|
|
|
it('fails on 404 request from correctiveActions.api', async () => {
|
|
const resolveResult = await browser.executeAsync<ResolveDeprecationResponse>((cb) => {
|
|
return window._coreProvider.start.core.deprecations
|
|
.resolveDeprecation({
|
|
message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
|
|
documentationUrl: 'test-url',
|
|
level: 'warning',
|
|
correctiveActions: {
|
|
api: {
|
|
method: 'POST',
|
|
path: '/api/invalid_route_not_registered/',
|
|
body: {
|
|
mockFail: true,
|
|
},
|
|
},
|
|
manualSteps: ['Step a', 'Step b'],
|
|
},
|
|
domainId: 'corePluginDeprecations',
|
|
})
|
|
.then(cb);
|
|
});
|
|
|
|
expect(resolveResult).to.eql({
|
|
reason: 'Not Found',
|
|
status: 'fail',
|
|
});
|
|
});
|
|
|
|
it('returns { status: ok } on successful correctiveActions.api', async () => {
|
|
const savedObjectId = await supertest
|
|
.get('/api/saved_objects/_find?type=test-deprecations-plugin')
|
|
.set('kbn-xsrf', 'true')
|
|
.expect(200)
|
|
.then(({ body }) => {
|
|
expect(body.total).to.be(1);
|
|
return body.saved_objects[0].id;
|
|
});
|
|
|
|
const resolveResult = await browser.executeAsync<ResolveDeprecationResponse>(
|
|
(keyId, cb) => {
|
|
return window._coreProvider.start.core.deprecations
|
|
.resolveDeprecation({
|
|
message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
|
|
documentationUrl: 'test-url',
|
|
level: 'warning',
|
|
correctiveActions: {
|
|
api: {
|
|
method: 'POST',
|
|
path: '/api/core_deprecations_resolve/',
|
|
body: { keyId },
|
|
},
|
|
manualSteps: ['Step a', 'Step b'],
|
|
},
|
|
domainId: 'corePluginDeprecations',
|
|
})
|
|
.then(cb);
|
|
},
|
|
savedObjectId
|
|
);
|
|
|
|
expect(resolveResult).to.eql({ status: 'ok' });
|
|
await supertest
|
|
.get('/api/saved_objects/_find?type=test-deprecations-plugin')
|
|
.set('kbn-xsrf', 'true')
|
|
.expect(200)
|
|
.then(({ body }) => {
|
|
expect(body.total).to.be(0);
|
|
});
|
|
|
|
const { deprecations } = await supertest
|
|
.get('/api/deprecations/')
|
|
.set('kbn-xsrf', 'true')
|
|
.then(
|
|
({ body }): Promise<DeprecationsGetResponse> => {
|
|
return body;
|
|
}
|
|
);
|
|
|
|
const deprecation = deprecations.find(
|
|
({ message }) => message === 'SavedObject test-deprecations-plugin is still being used.'
|
|
);
|
|
|
|
expect(deprecation).to.eql(undefined);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|