Skip to content

Commit

Permalink
fix backport to remove post-7.14 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuellr committed Sep 1, 2021
1 parent 934a281 commit a8d52d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,20 @@ describe('Task Run Statistics', () => {
// Use 'summarizeTaskRunStat' to receive summarize stats
map(({ key, value }: AggregatedStat<TaskRunStat>) => ({
key,
value: summarizeTaskRunStat(logger, value, getTaskManagerConfig({})).value,
value: summarizeTaskRunStat(
logger,
value,
getTaskManagerConfig({
monitored_task_execution_thresholds: {
custom: {
'alerting:test': {
error_threshold: 59,
warn_threshold: 39,
},
},
},
})
).value,
})),
take(10),
bufferCount(10)
Expand Down Expand Up @@ -485,54 +498,13 @@ describe('Task Run Statistics', () => {
}
});

taskEvents.forEach((event) => events$.next(event));
});
});

test('frequency of polled tasks by their persistence', async () => {
const events$ = new Subject<TaskLifecycleEvent>();

const taskPollingLifecycle = taskPollingLifecycleMock.create({
events$: events$ as Observable<TaskLifecycleEvent>,
});

const runningAverageWindowSize = 5;
const taskRunAggregator = createTaskRunAggregator(
taskPollingLifecycle,
runningAverageWindowSize
);

const taskEvents = [
mockTaskPollingEvent({}),
mockTaskPollingEvent({}),
mockTaskPollingEvent({ schedule: { interval: '3s' } }),
mockTaskPollingEvent({}),
mockTaskPollingEvent({}),
mockTaskPollingEvent({ schedule: { interval: '3s' } }),
mockTaskPollingEvent({ schedule: { interval: '3s' } }),
mockTaskPollingEvent({}),
mockTaskPollingEvent({}),
mockTaskPollingEvent({ schedule: { interval: '3s' } }),
mockTaskPollingEvent({}),
mockTaskPollingEvent({}),
mockTaskPollingEvent({}),
mockTaskPollingEvent({}),
mockTaskPollingEvent({ schedule: { interval: '3s' } }),
];

return new Promise<void>((resolve, reject) => {
taskRunAggregator
.pipe(
// skip initial stat which is just initialized data which
// ensures we don't stall on combineLatest
skip(1),
// Use 'summarizeTaskRunStat' to receive summarize stats
map(({ key, value }: AggregatedStat<TaskRunStat>) => ({
key,
value: summarizeTaskRunStat(logger, value, getTaskManagerConfig({})).value,
})),
take(taskEvents.length),
bufferCount(taskEvents.length)
events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Success));
events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Success));
events$.next(
mockTaskRunEvent(
{ schedule: { interval: '3s' } },
{ start: 0, stop: 0 },
TaskRunResult.Success
)
);
events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Failed));
Expand Down
16 changes: 0 additions & 16 deletions x-pack/plugins/task_manager/server/routes/health.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ describe('healthRoute', () => {
summarizeMonitoringStats(logger, warnWorkloadStat, getTaskManagerConfig({}))
),
});
expect(logHealthMetrics.mock.calls[3][0]).toMatchObject({
id,
timestamp: expect.any(String),
status: expect.any(String),
...ignoreCapacityEstimation(
summarizeMonitoringStats(logger, warnEphemeralStat, getTaskManagerConfig({}))
),
});
});

it(`logs at an error level if the status is error`, async () => {
Expand Down Expand Up @@ -227,14 +219,6 @@ describe('healthRoute', () => {
summarizeMonitoringStats(logger, errorWorkloadStat, getTaskManagerConfig({}))
),
});
expect(logHealthMetrics.mock.calls[3][0]).toMatchObject({
id,
timestamp: expect.any(String),
status: expect.any(String),
...ignoreCapacityEstimation(
summarizeMonitoringStats(logger, errorEphemeralStat, getTaskManagerConfig({}))
),
});
});

it('returns a error status if the overall stats have not been updated within the required hot freshness', async () => {
Expand Down

0 comments on commit a8d52d6

Please sign in to comment.