Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix discover async search relative timerange test #197740

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