forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Reporting] Fix job notifications poller (elastic#177537)
## Summary In previous code, Reporting fetched for a list of pending reports and compared the status of each result to a stored record of pending reports. The flakiness occurred because sometimes the results don't contain a record for a very "fresh" report since the refresh interval hadn't ticked and the stored change wasn't reflecting in search results. With [switching Reporting to use a data stream](elastic#176022), there was new flakiness in serverless tests. The area of flakiness was in getting Reporting to show the "Job completed" toast notification. The main difference faced with data streams is a lower index refresh interval, which is lower even more for serverless. This PR fixes the poller to loop through the list of stored pending reports and compare each to the result from the search. If a stored report isn't present in the search, we consider that to still be in the pending state. Other changes: - Improvements the class responsible for managing updates to the stored list of pending reports, so that each operation performs atomically and go through a queue to mitigate the chance of race conditions. - Update function names and variable names for readability - Remove the unused `removeJob` function. - Move helper code into private methods of the `StreamHandler` class and simplify `x-pack/plugins/reporting/public/plugin.ts` ## Release note Fixed an issue in Reporting with consistently showing the toast message for completed report jobs. --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
Showing
8 changed files
with
391 additions
and
339 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/kbn-reporting/public/job_completion_notifications.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { jobCompletionNotifications } from './job_completion_notifications'; | ||
|
||
describe('Job completion notifications', () => { | ||
const { setPendingJobIds, getPendingJobIds, addPendingJobId } = jobCompletionNotifications(); | ||
|
||
afterEach(async () => { | ||
setPendingJobIds([]); | ||
}); | ||
|
||
it('initially contains not job IDs', async () => { | ||
expect(getPendingJobIds()).toEqual([]); | ||
}); | ||
|
||
it('handles multiple job ID additions', async () => { | ||
addPendingJobId('job-123'); | ||
addPendingJobId('job-456'); | ||
addPendingJobId('job-789'); | ||
expect(getPendingJobIds()).toEqual(['job-123', 'job-456', 'job-789']); | ||
}); | ||
|
||
it('handles setting a total of amount of job ID', async () => { | ||
setPendingJobIds(['job-abc', 'job-def', 'job-ghi']); | ||
expect(getPendingJobIds()).toEqual(['job-abc', 'job-def', 'job-ghi']); | ||
}); | ||
|
||
it('able to clear all jobIds', async () => { | ||
setPendingJobIds(['job-abc', 'job-def', 'job-ghi']); | ||
setPendingJobIds([]); | ||
expect(getPendingJobIds()).toEqual([]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.