mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* [server/config/deprecationWarnings] fix deprecation logging warnings (#17439) * [server/config/deprecationWarnings] fix deprecation logging warnings * typos * explain kbn_server_worker a bit with better naming and comment * Address review feedback * adapt #17439 to 5.6
This commit is contained in:
parent
b0cb5f8019
commit
ec92ab7894
5 changed files with 99 additions and 8 deletions
80
src/server/config/__tests__/deprecation_warnings.js
Normal file
80
src/server/config/__tests__/deprecation_warnings.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
import { spawn } from 'child_process';
|
||||
|
||||
import expect from 'expect.js';
|
||||
|
||||
const RUN_KBN_SERVER_STARTUP = require.resolve('./fixtures/run_kbn_server_startup');
|
||||
const BABEL_REGISTER = require.resolve('../../../optimize/babel/register');
|
||||
const SECOND = 1000;
|
||||
|
||||
describe('config/deprecation warnings mixin', function () {
|
||||
this.timeout(15 * SECOND);
|
||||
|
||||
let stdio = '';
|
||||
let proc = null;
|
||||
|
||||
before(() => new Promise((resolve, reject) => {
|
||||
proc = spawn(process.execPath, [
|
||||
'-r', BABEL_REGISTER,
|
||||
RUN_KBN_SERVER_STARTUP
|
||||
], {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
env: {
|
||||
CREATE_SERVER_OPTS: JSON.stringify({
|
||||
logging: {
|
||||
quiet: false
|
||||
},
|
||||
kibana_index: 'my-kibana-index'
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
proc.stdout.on('data', (chunk) => {
|
||||
stdio += chunk.toString('utf8');
|
||||
});
|
||||
|
||||
proc.stderr.on('data', (chunk) => {
|
||||
stdio += chunk.toString('utf8');
|
||||
});
|
||||
|
||||
proc.on('exit', (code) => {
|
||||
proc = null;
|
||||
if (code > 0) {
|
||||
reject(new Error(`Kibana server exited with ${code} -- stdout:\n\n${stdio}\n`));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
after(() => {
|
||||
if (proc) {
|
||||
proc.kill('SIGKILL');
|
||||
}
|
||||
});
|
||||
|
||||
it('logs deprecation warnings when using outdated config', async () => {
|
||||
const deprecationLines = stdio
|
||||
.split('\n')
|
||||
.map(json => {
|
||||
try {
|
||||
// in dev mode kibana might log things like node.js warnings which
|
||||
// are not JSON, ignore the lines that don't parse as JSON
|
||||
return JSON.parse(json);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
.filter(line => (
|
||||
line.type === 'log' &&
|
||||
line.tags.includes('deprecation') &&
|
||||
line.tags.includes('warning')
|
||||
));
|
||||
|
||||
expect(deprecationLines).to.have.length(1);
|
||||
expect(deprecationLines[0]).to.have.property(
|
||||
'message',
|
||||
'Config key "kibana_index" is deprecated. It has been replaced with "kibana.index"'
|
||||
);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
import { createServer } from '../../../../test_utils/kbn_server';
|
||||
|
||||
(async function run() {
|
||||
const server = createServer(JSON.parse(process.env.CREATE_SERVER_OPTS));
|
||||
|
||||
// We just need the server to run through startup so that it will
|
||||
// log the deprecation messages. Once it has started up we close it
|
||||
// to allow the process to exit naturally
|
||||
try {
|
||||
await server.ready();
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
|
||||
}());
|
|
@ -1,6 +1,6 @@
|
|||
import { transformDeprecations } from './transform_deprecations';
|
||||
|
||||
export default function (kbnServer, server) {
|
||||
export function configDeprecationWarningsMixin(kbnServer, server) {
|
||||
transformDeprecations(kbnServer.settings, (message) => {
|
||||
server.log(['warning', 'config', 'deprecation'], message);
|
||||
});
|
||||
|
|
|
@ -15,6 +15,7 @@ import pluginsScanMixin from './plugins/scan';
|
|||
import pluginsCheckEnabledMixin from './plugins/check_enabled';
|
||||
import pluginsCheckVersionMixin from './plugins/check_version';
|
||||
import configCompleteMixin from './config/complete';
|
||||
import { configDeprecationWarningsMixin } from './config/deprecation_warnings';
|
||||
import uiMixin from '../ui';
|
||||
import optimizeMixin from '../optimize';
|
||||
import pluginsInitializeMixin from './plugins/initialize';
|
||||
|
@ -37,6 +38,7 @@ module.exports = class KbnServer {
|
|||
// sets this.server
|
||||
httpMixin,
|
||||
loggingMixin,
|
||||
configDeprecationWarningsMixin,
|
||||
warningsMixin,
|
||||
statusMixin,
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@ const DEFAULTS_SETTINGS = {
|
|||
quiet: true
|
||||
},
|
||||
plugins: {},
|
||||
uiSettings: {
|
||||
enabled: false
|
||||
},
|
||||
optimize: {
|
||||
enabled: false
|
||||
},
|
||||
|
@ -34,10 +31,7 @@ const DEFAULT_SETTINGS_WITH_CORE_PLUGINS = {
|
|||
url: esTestConfig.getUrl(),
|
||||
username: kibanaServer.username,
|
||||
password: kibanaServer.password
|
||||
},
|
||||
uiSettings: {
|
||||
enabled: true
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue