From 4869b8f21c7bc2e0234bfddf7415646f72429c22 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Tue, 5 Nov 2024 17:03:49 +0100 Subject: [PATCH] Fix discover async search relative timerange test (#197740) ## Summary Resolves https://github.com/elastic/kibana/issues/195955. --- .../data/server/search/session/session_service.ts | 4 ++-- .../page_objects/search_sessions_management_page.ts | 2 +- .../tests/apps/discover/async_search.ts | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/plugins/data/server/search/session/session_service.ts b/src/plugins/data/server/search/session/session_service.ts index 4ef741ec78387..48b563c5585ca 100644 --- a/src/plugins/data/server/search/session/session_service.ts +++ b/src/plugins/data/server/search/session/session_service.ts @@ -402,8 +402,8 @@ export class SearchSessionService implements ISearchSessionService { const session = await this.get(deps, user, sessionId); const requestHash = createRequestHash(searchRequest.params); if (!Object.hasOwn(session.attributes.idMapping, requestHash)) { - this.logger.error(`SearchSessionService: getId | ${sessionId} | ${requestHash} not found`); - this.logger.debug( + this.logger.debug(`SearchSessionService: getId | ${sessionId} | ${requestHash} not found`); + this.logger.error( `SearchSessionService: getId not found search with params: ${JSON.stringify( searchRequest.params )}` diff --git a/x-pack/test/functional/page_objects/search_sessions_management_page.ts b/x-pack/test/functional/page_objects/search_sessions_management_page.ts index 6d704387e21f2..8694dc51dfbd6 100644 --- a/x-pack/test/functional/page_objects/search_sessions_management_page.ts +++ b/x-pack/test/functional/page_objects/search_sessions_management_page.ts @@ -37,7 +37,7 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr id: ((await row.getAttribute('data-test-search-session-id')) ?? '').split('id-')[1], name: $.findTestSubject('sessionManagementNameCol').text().trim(), status: $.findTestSubject('sessionManagementStatusLabel').attr('data-test-status'), - mainUrl: $.findTestSubject('sessionManagementNameCol').text(), + mainUrl: $.findTestSubject('sessionManagementNameCol').attr('href'), created: $.findTestSubject('sessionManagementCreatedCol').text(), expires: $.findTestSubject('sessionManagementExpiresCol').text(), searchesCount: Number($.findTestSubject('sessionManagementNumSearchesCol').text()), diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts index 3e9429ee5ed97..1f768780a9c95 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts @@ -29,8 +29,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const toasts = getService('toasts'); - // FLAKY: https://github.com/elastic/kibana/issues/195955 - describe.skip('discover async search', () => { + describe('discover async search', () => { before(async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.importExport.load( @@ -115,6 +114,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('relative timerange works', async () => { await common.navigateToApp('discover'); await header.waitUntilLoadingHasFinished(); + const url = await browser.getCurrentUrl(); + await searchSessions.save(); await searchSessions.expectState('backgroundCompleted'); const searchSessionId = await getSearchSessionId(); @@ -125,8 +126,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await searchSessionsManagement.goTo(); const searchSessionListBeforeRestore = await searchSessionsManagement.getList(); const searchesCountBeforeRestore = searchSessionListBeforeRestore[0].searchesCount; + // navigate to Discover - await searchSessionListBeforeRestore[0].view(); + // Instead of clicking the link to navigate to Discover, we load Discover from scratch (just like we did when we + // ran the search session before saving). This ensures that the same number of requests are made. + // await searchSessionListBeforeRestore[0].view(); + const restoreUrl = new URL(searchSessionListBeforeRestore[0].mainUrl, url).href; + await browser.navigateTo(restoreUrl); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); expect(await discover.hasNoResults()).to.be(true);