[ML] Fix Index data visualizer sometimes shows wrong doc count for saved searches (#106007)

* [ML] Fix flaky saved search

* [ML] Re-enable tests

* [ML] Make data viz the only tests for flaky test suite runner

* [ML] Make ML only

* [ML] Remove describe.only

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Quynh Nguyen 2021-07-19 11:49:03 -05:00 committed by GitHub
parent 7101c42bec
commit 3b921cea56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -65,20 +65,16 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
const parsedQueryString = parse(prevSearchString, { sort: false });
const getIndexPattern = async () => {
if (typeof parsedQueryString?.index === 'string') {
const indexPattern = await indexPatterns.get(parsedQueryString.index);
setCurrentIndexPattern(indexPattern);
}
if (typeof parsedQueryString?.savedSearchId === 'string') {
const savedSearchId = parsedQueryString.savedSearchId;
try {
const savedSearch = await savedObjectsClient.get('search', savedSearchId);
const indexPatternId = savedSearch.references.find((ref) => ref.type === 'index-pattern')
?.id;
if (indexPatternId !== undefined) {
if (indexPatternId !== undefined && savedSearch) {
try {
const indexPattern = await indexPatterns.get(indexPatternId);
setCurrentSavedSearch(savedSearch);
setCurrentIndexPattern(indexPattern);
} catch (e) {
toasts.addError(e, {
@ -88,7 +84,6 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
});
}
}
setCurrentSavedSearch(savedSearch);
} catch (e) {
toasts.addError(e, {
title: i18n.translate('xpack.dataVisualizer.index.savedSearchErrorMessage', {
@ -98,6 +93,11 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
});
}
}
if (typeof parsedQueryString?.index === 'string') {
const indexPattern = await indexPatterns.get(parsedQueryString.index);
setCurrentIndexPattern(indexPattern);
}
};
getIndexPattern();
// eslint-disable-next-line react-hooks/exhaustive-deps

View file

@ -496,8 +496,7 @@ export default function ({ getService }: FtrProviderContext) {
});
}
// FLAKY: https://github.com/elastic/kibana/issues/105087
describe.skip('index based', function () {
describe('index based', function () {
this.tags(['mlqa']);
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');