[ftr/services/kbnServer] set uiSetting defaults more often (#30459)

* [ftr/services/kbnServer] set uiSetting defaults more often

* [ftr/services/uiSettings] only init defaults when they're defined
This commit is contained in:
Spencer 2019-02-08 13:18:16 -08:00 committed by GitHub
parent 3fba1f3fd5
commit 476c4cd099
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View file

@ -17,7 +17,7 @@
* under the License.
*/
const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded'];
const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload'];
const KIBANA_INDEX = '.kibana';
export function extendEsArchiver({ esArchiver, kibanaServer, defaults }) {
@ -35,7 +35,7 @@ export function extendEsArchiver({ esArchiver, kibanaServer, defaults }) {
// if the kibana index was created by the esArchiver then update the uiSettings
// with the defaults to make sure that they are always in place initially
if (stats[KIBANA_INDEX] && stats[KIBANA_INDEX].created) {
if (stats[KIBANA_INDEX] && (stats[KIBANA_INDEX].created || stats[KIBANA_INDEX].deleted)) {
await kibanaServer.uiSettings.update(defaults);
}

View file

@ -26,13 +26,14 @@ import { KibanaServerVersion } from './version';
export function KibanaServerProvider({ getService }) {
const log = getService('log');
const config = getService('config');
const lifecycle = getService('lifecycle');
return new class KibanaServer {
constructor() {
const url = formatUrl(config.get('servers.kibana'));
this.status = new KibanaServerStatus(url);
this.version = new KibanaServerVersion(this.status);
this.uiSettings = new KibanaServerUiSettings(url, log, config.get('uiSettings.defaults'));
this.uiSettings = new KibanaServerUiSettings(url, log, config.get('uiSettings.defaults'), lifecycle);
}
};
}

View file

@ -24,7 +24,7 @@ const MINUTE = 60 * 1000;
const HOUR = 60 * MINUTE;
export class KibanaServerUiSettings {
constructor(url, log, defaults) {
constructor(url, log, defaults, lifecycle) {
this._log = log;
this._defaults = defaults;
this._wreck = Wreck.defaults({
@ -33,6 +33,12 @@ export class KibanaServerUiSettings {
json: true,
redirects: 3,
});
if (this._defaults) {
lifecycle.on('beforeTests', async () => {
await this.update(defaults);
});
}
}
/**