-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] Fix: Last successful screenshot should be from same location (…
…#116906) * update get_last_successful_step query to include location logic * adjust types
- Loading branch information
1 parent
39d79f7
commit 4e294e3
Showing
7 changed files
with
185 additions
and
6 deletions.
There are no files selected for viewing
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
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
132 changes: 132 additions & 0 deletions
132
x-pack/plugins/uptime/server/lib/requests/get_last_successful_step.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,132 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getLastSuccessfulStepParams } from './get_last_successful_step'; | ||
|
||
describe('getLastSuccessfulStep', () => { | ||
describe('getLastSuccessfulStepParams', () => { | ||
it('formats ES params with location', () => { | ||
const monitorId = 'my-monitor'; | ||
const stepIndex = 1; | ||
const location = 'au-heartbeat'; | ||
const timestamp = '2021-10-31T19:47:52.392Z'; | ||
const params = getLastSuccessfulStepParams({ | ||
monitorId, | ||
stepIndex, | ||
location, | ||
timestamp, | ||
}); | ||
|
||
expect(params).toEqual({ | ||
query: { | ||
bool: { | ||
filter: [ | ||
{ | ||
range: { | ||
'@timestamp': { | ||
lte: '2021-10-31T19:47:52.392Z', | ||
}, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'monitor.id': monitorId, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'synthetics.type': 'step/end', | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'synthetics.step.status': 'succeeded', | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'synthetics.step.index': stepIndex, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'observer.geo.name': location, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
size: 1, | ||
sort: [ | ||
{ | ||
'@timestamp': { | ||
order: 'desc', | ||
}, | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
it('formats ES params without location', () => { | ||
const params = getLastSuccessfulStepParams({ | ||
monitorId: 'my-monitor', | ||
stepIndex: 1, | ||
location: undefined, | ||
timestamp: '2021-10-31T19:47:52.392Z', | ||
}); | ||
|
||
expect(params).toEqual({ | ||
query: { | ||
bool: { | ||
filter: [ | ||
{ | ||
range: { | ||
'@timestamp': { | ||
lte: '2021-10-31T19:47:52.392Z', | ||
}, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'monitor.id': 'my-monitor', | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'synthetics.type': 'step/end', | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'synthetics.step.status': 'succeeded', | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'synthetics.step.index': 1, | ||
}, | ||
}, | ||
], | ||
must_not: { | ||
exists: { | ||
field: 'observer.geo.name', | ||
}, | ||
}, | ||
}, | ||
}, | ||
size: 1, | ||
sort: [ | ||
{ | ||
'@timestamp': { | ||
order: 'desc', | ||
}, | ||
}, | ||
], | ||
}); | ||
}); | ||
}); | ||
}); |
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