mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
parent
132dbdf774
commit
4cad856136
2 changed files with 47 additions and 5 deletions
|
@ -15,17 +15,19 @@ import {
|
|||
import util from 'util';
|
||||
|
||||
import getUrl from '../../utils/get_url';
|
||||
|
||||
import {
|
||||
config,
|
||||
defaultTryTimeout,
|
||||
defaultFindTimeout,
|
||||
remote,
|
||||
shieldPage
|
||||
shieldPage,
|
||||
esClient
|
||||
} from '../index';
|
||||
|
||||
import {
|
||||
Log,
|
||||
Try,
|
||||
Try
|
||||
} from '../utils';
|
||||
|
||||
const mkdirpAsync = promisify(mkdirp);
|
||||
|
@ -83,8 +85,21 @@ export default class Common {
|
|||
function navigateTo(url) {
|
||||
return self.try(function () {
|
||||
// since we're using hash URLs, always reload first to force re-render
|
||||
self.debug('navigate to: ' + url);
|
||||
return self.remote.get(url)
|
||||
return esClient.getDefaultIndex()
|
||||
.then(function (defaultIndex) {
|
||||
if (appName === 'discover' || appName === 'visualize' || appName === 'dashboard') {
|
||||
if (!defaultIndex) {
|
||||
// https://github.com/elastic/kibana/issues/7496
|
||||
// Even though most tests are using esClient to set the default index, sometimes Kibana clobbers
|
||||
// that change. If we got here, fix it.
|
||||
self.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex);
|
||||
self.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""');
|
||||
esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'});
|
||||
}
|
||||
}
|
||||
self.debug('navigate to: ' + url);
|
||||
return self.remote.get(url);
|
||||
})
|
||||
.then(function () {
|
||||
return self.sleep(700);
|
||||
})
|
||||
|
|
|
@ -68,12 +68,39 @@ export default (function () {
|
|||
);
|
||||
} else {
|
||||
configId = response.hits.hits[0]._id;
|
||||
Log.debug('config._id =' + configId);
|
||||
Log.debug('config._id = ' + configId);
|
||||
return configId;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
** Gets defaultIndex from the config doc.
|
||||
*/
|
||||
getDefaultIndex: function () {
|
||||
var defaultIndex;
|
||||
|
||||
return this.client.search({
|
||||
index: '.kibana',
|
||||
type: 'config'
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.errors) {
|
||||
throw new Error(
|
||||
'get config failed\n' +
|
||||
response.items
|
||||
.map(i => i[Object.keys(i)[0]].error)
|
||||
.filter(Boolean)
|
||||
.map(err => ' ' + JSON.stringify(err))
|
||||
.join('\n')
|
||||
);
|
||||
} else {
|
||||
defaultIndex = response.hits.hits[0]._source.defaultIndex;
|
||||
Log.debug('config.defaultIndex = ' + defaultIndex);
|
||||
return defaultIndex;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add fields to the config doc (like setting timezone and defaultIndex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue