Skip to content

Commit

Permalink
Work-around elastic#7496 and/or elastic#7055 by re-setting default in…
Browse files Browse the repository at this point in the history
…dex pattern

Former-commit-id: e2b7aea
  • Loading branch information
LeeDr committed Aug 30, 2016
1 parent 1f753ea commit aeb6b33
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
23 changes: 19 additions & 4 deletions test/support/page_objects/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
})
Expand Down
29 changes: 28 additions & 1 deletion test/support/utils/es_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aeb6b33

Please sign in to comment.