-
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.
- Loading branch information
1 parent
ef90801
commit 654e73e
Showing
3 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.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,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { fetchElasticsearchVersions } from './fetch_elasticsearch_versions'; | ||
|
||
describe('fetchElasticsearchVersions', () => { | ||
let callCluster = jest.fn(); | ||
const clusters = [ | ||
{ | ||
clusterUuid: 'cluster123', | ||
clusterName: 'test-cluster', | ||
}, | ||
]; | ||
const index = '.monitoring-es-*'; | ||
const size = 10; | ||
const versions = ['8.0.0', '7.2.1']; | ||
|
||
it('fetch as expected', async () => { | ||
callCluster = jest.fn().mockImplementation(() => { | ||
return { | ||
hits: { | ||
hits: [ | ||
{ | ||
_index: `Monitoring:${index}`, | ||
_source: { | ||
cluster_uuid: 'cluster123', | ||
cluster_stats: { | ||
nodes: { | ||
versions, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
}); | ||
|
||
const result = await fetchElasticsearchVersions(callCluster, clusters, index, size); | ||
expect(result).toEqual([ | ||
{ | ||
clusterUuid: clusters[0].clusterUuid, | ||
ccs: 'Monitoring', | ||
versions, | ||
}, | ||
]); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { fetchKibanaVersions } from './fetch_kibana_versions'; | ||
|
||
describe('fetchKibanaVersions', () => { | ||
let callCluster = jest.fn(); | ||
const clusters = [ | ||
{ | ||
clusterUuid: 'cluster123', | ||
clusterName: 'test-cluster', | ||
}, | ||
]; | ||
const index = '.monitoring-kibana-*'; | ||
const size = 10; | ||
|
||
it('fetch as expected', async () => { | ||
callCluster = jest.fn().mockImplementation(() => { | ||
return { | ||
aggregations: { | ||
index: { | ||
buckets: [ | ||
{ | ||
key: `Monitoring:${index}`, | ||
}, | ||
], | ||
}, | ||
cluster: { | ||
buckets: [ | ||
{ | ||
key: 'cluster123', | ||
group_by_kibana: { | ||
buckets: [ | ||
{ | ||
group_by_version: { | ||
buckets: [ | ||
{ | ||
key: '8.0.0', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
group_by_version: { | ||
buckets: [ | ||
{ | ||
key: '7.2.1', | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
const result = await fetchKibanaVersions(callCluster, clusters, index, size); | ||
expect(result).toEqual([ | ||
{ | ||
clusterUuid: clusters[0].clusterUuid, | ||
ccs: 'Monitoring', | ||
versions: ['8.0.0', '7.2.1'], | ||
}, | ||
]); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { fetchLogstashVersions } from './fetch_logstash_versions'; | ||
|
||
describe('fetchLogstashVersions', () => { | ||
let callCluster = jest.fn(); | ||
const clusters = [ | ||
{ | ||
clusterUuid: 'cluster123', | ||
clusterName: 'test-cluster', | ||
}, | ||
]; | ||
const index = '.monitoring-logstash-*'; | ||
const size = 10; | ||
|
||
it('fetch as expected', async () => { | ||
callCluster = jest.fn().mockImplementation(() => { | ||
return { | ||
aggregations: { | ||
index: { | ||
buckets: [ | ||
{ | ||
key: `Monitoring:${index}`, | ||
}, | ||
], | ||
}, | ||
cluster: { | ||
buckets: [ | ||
{ | ||
key: 'cluster123', | ||
group_by_logstash: { | ||
buckets: [ | ||
{ | ||
group_by_version: { | ||
buckets: [ | ||
{ | ||
key: '8.0.0', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
group_by_version: { | ||
buckets: [ | ||
{ | ||
key: '7.2.1', | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
const result = await fetchLogstashVersions(callCluster, clusters, index, size); | ||
expect(result).toEqual([ | ||
{ | ||
clusterUuid: clusters[0].clusterUuid, | ||
ccs: 'Monitoring', | ||
versions: ['8.0.0', '7.2.1'], | ||
}, | ||
]); | ||
}); | ||
}); |