-
Notifications
You must be signed in to change notification settings - Fork 11.7k
/
config.test.ts
53 lines (40 loc) · 1.67 KB
/
config.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { config } from '@grafana/runtime';
import { checkEvaluationIntervalGlobalLimit } from './config';
describe('checkEvaluationIntervalGlobalLimit', () => {
it('should NOT exceed limit if evaluate every is not valid duration', () => {
config.unifiedAlerting.minInterval = '2m30s';
const { globalLimit, exceedsLimit } = checkEvaluationIntervalGlobalLimit('123notvalidduration');
expect(globalLimit).toBe(150 * 1000);
expect(exceedsLimit).toBe(false);
});
it('should NOT exceed limit if config minInterval is not valid duration', () => {
config.unifiedAlerting.minInterval = '1A8IU3A';
const { globalLimit, exceedsLimit } = checkEvaluationIntervalGlobalLimit('1m30s');
expect(globalLimit).toBe(0);
expect(exceedsLimit).toBe(false);
});
it.each([
['2m30s', '1m30s'],
['30s', '10s'],
['1d2h', '2h'],
['1y', '90d'],
])(
'should exceed limit if config minInterval (%s) is greater than evaluate every (%s)',
(minInterval, evaluateEvery) => {
config.unifiedAlerting.minInterval = minInterval;
const { globalLimit, exceedsLimit } = checkEvaluationIntervalGlobalLimit(evaluateEvery);
expect(globalLimit).toBeGreaterThan(0);
expect(exceedsLimit).toBe(true);
}
);
it.each([
['1m30s', '2m30s'],
['30s', '1d'],
['1m10s', '1h30m15s'],
])('should NOT exceed limit if config minInterval is lesser than evaluate every', (minInterval, evaluateEvery) => {
config.unifiedAlerting.minInterval = minInterval;
const { globalLimit, exceedsLimit } = checkEvaluationIntervalGlobalLimit(evaluateEvery);
expect(globalLimit).toBeGreaterThan(0);
expect(exceedsLimit).toBe(false);
});
});