-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit 0f4e48a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
98fa532
commit 4e55a23
Showing
5 changed files
with
176 additions
and
29 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
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,66 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { extractTimeRangeDSL } from '../alerting'; | ||
|
||
describe('extractTimeRangeDSL', () => { | ||
it('should only extract utc time range filter', () => { | ||
expect(extractTimeRangeDSL([{ range: { timestamp: { to: 'now' } } }]).timeRangeDSL).toEqual( | ||
undefined | ||
); | ||
}); | ||
|
||
it('should return undefined timeFiledName if no time range filter', () => { | ||
expect( | ||
extractTimeRangeDSL([ | ||
{ | ||
bool: {}, | ||
}, | ||
]).timeRangeDSL | ||
).toBe(undefined); | ||
}); | ||
|
||
it('should extract timeFiledName normally', () => { | ||
expect( | ||
extractTimeRangeDSL([ | ||
{ | ||
range: { | ||
timestamp: { | ||
from: '2024-10-09T17:40:47+00:00||-1h', | ||
to: '2024-10-09T17:40:47+00:00', | ||
include_lower: true, | ||
include_upper: true, | ||
boost: 1, | ||
}, | ||
}, | ||
}, | ||
{ | ||
bool: { | ||
must_not: [ | ||
{ | ||
match_phrase: { | ||
response: { | ||
query: '200', | ||
slop: 0, | ||
zero_terms_query: 'NONE', | ||
boost: 1, | ||
}, | ||
}, | ||
}, | ||
], | ||
adjust_pure_negative: true, | ||
boost: 1, | ||
}, | ||
}, | ||
]).timeRangeDSL | ||
).toStrictEqual({ | ||
from: '2024-10-09T17:40:47+00:00||-1h', | ||
to: '2024-10-09T17:40:47+00:00', | ||
include_lower: true, | ||
include_upper: true, | ||
boost: 1, | ||
}); | ||
}); | ||
}); |