forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] Add pod and container to monitor list query (elastic#35835)
* Add test to ensure that container.id and kubernetes information are returned from the adapter. * Update GraphQL schema to reflect added Container fields. * Update monitor list query to fetch additional container/kubernetes fields. * Update API test fixtures to account for changed query. * Add copyright header to file.
- Loading branch information
1 parent
4174b17
commit e7e4388
Showing
9 changed files
with
255 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
...lib/adapters/monitors/__tests__/__snapshots__/elasticsearch_monitors_adapter.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
...gins/uptime/server/lib/adapters/monitors/__tests__/elasticsearch_monitors_adapter.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,65 @@ | ||
/* | ||
* 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 { DatabaseAdapter } from '../../database'; | ||
import { ElasticsearchMonitorsAdapter } from '../elasticsearch_monitors_adapter'; | ||
|
||
// FIXME: there are many untested functions in this adapter. They should be tested. | ||
describe('ElasticsearchMonitorsAdapter', () => { | ||
it('will return kubernetes information if contained in hits', async () => { | ||
expect.assertions(2); | ||
|
||
const mockHits = [ | ||
{ | ||
_source: { | ||
'@timestamp': '2018-10-30T18:51:59.800Z', | ||
container: { | ||
id: 'container_id', | ||
}, | ||
kubernetes: { | ||
pod: { | ||
uid: 'kubernetes_pod_uid', | ||
}, | ||
}, | ||
monitor: { | ||
status: 'up', | ||
}, | ||
}, | ||
}, | ||
]; | ||
const mockEsQueryResult = { | ||
aggregations: { | ||
hosts: { | ||
buckets: [ | ||
{ | ||
key: { | ||
id: 'foo', | ||
url: 'bar', | ||
}, | ||
latest: { | ||
hits: { | ||
hits: mockHits, | ||
}, | ||
}, | ||
histogram: { | ||
buckets: [], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
const database: DatabaseAdapter = { | ||
search: async (request: any, params: any) => mockEsQueryResult, | ||
count: async (request: any, params: any) => null, | ||
}; | ||
const adapter = new ElasticsearchMonitorsAdapter(database); | ||
const result = await adapter.getMonitors({}, 'now-15m', 'now'); | ||
expect(result).toHaveLength(1); | ||
expect(result[0]).toMatchSnapshot(); | ||
}); | ||
}); |
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
Oops, something went wrong.