Skip to content

Commit

Permalink
Fix discover async search relative timerange test (#197740)
Browse files Browse the repository at this point in the history
## Summary

Resolves #195955.
  • Loading branch information
lukasolson authored Nov 5, 2024
1 parent d5e9939 commit 4869b8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/plugins/data/server/search/session/session_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 4869b8f

Please sign in to comment.