-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infra] Replace infra aggregation runtime types with the types in `es…
…types` (#192059) Closes #190497 ## Summary This PR replaces infra aggregation types with types provided by the [Elasticsearch client](elastic/elasticsearch-js#1358). ### Testing not applicable ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
1 parent
1681a34
commit 8afac4d
Showing
6 changed files
with
118 additions
and
43 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...ability_solution/infra/server/lib/alerting/inventory_metric_threshold/lib/is_rate.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,73 @@ | ||
/* | ||
* 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 { MetricsUIAggregation } from '@kbn/metrics-data-access-plugin/common'; | ||
import { isCustomMetricRate, isInterfaceRateAgg, isMetricRate, isRate } from './is_rate'; | ||
import { SnapshotCustomMetricInput } from '../../../../../common/http_api'; | ||
|
||
const customMaxMetricMock: SnapshotCustomMetricInput = { | ||
type: 'custom', | ||
aggregation: 'max', | ||
field: '', | ||
id: '', | ||
}; | ||
|
||
const customRateMetricMock: SnapshotCustomMetricInput = { | ||
type: 'custom', | ||
aggregation: 'rate', | ||
field: '', | ||
id: '', | ||
}; | ||
|
||
const metricMock: MetricsUIAggregation = { | ||
mock1: { derivative: {} }, | ||
mock2: { max: null, mock: { field: '' } }, | ||
mock3: { | ||
aggregations: {}, | ||
terms: {}, | ||
sum_bucket: {}, | ||
}, | ||
}; | ||
|
||
describe('isRate', () => { | ||
describe('isMetricRate', () => { | ||
it('should return false when metric is undefined', () => { | ||
expect(isMetricRate(undefined)).toEqual(false); | ||
}); | ||
it('should return true when correct metric is passed', () => { | ||
expect(isMetricRate(metricMock)).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('isCustomMetricRate', () => { | ||
it("should return false when aggregation isn't 'rate'", () => { | ||
expect(isCustomMetricRate(customMaxMetricMock)).toEqual(false); | ||
}); | ||
it("should return true when aggregation is equal to 'rate'", () => { | ||
expect(isCustomMetricRate(customRateMetricMock)).toEqual(true); | ||
}); | ||
|
||
describe('isInterfaceRateAgg', () => { | ||
it('should return false if metric is undefined', () => { | ||
expect(isInterfaceRateAgg(undefined)).toEqual(false); | ||
}); | ||
it('should return true when correct metric is passed', () => { | ||
expect(isInterfaceRateAgg(metricMock)).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('isRate', () => { | ||
it('should return false when incorrect metrics are provided', () => { | ||
expect(isRate({} as MetricsUIAggregation, {} as SnapshotCustomMetricInput)).toEqual(false); | ||
}); | ||
|
||
it('should return true when proper metric are provided', () => { | ||
expect(isRate(metricMock, customRateMetricMock)).toEqual(true); | ||
}); | ||
}); | ||
}); | ||
}); |
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