mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Infra UI] Test sources and capabilities endpoints (#24216)
* Test for capabilities GraphQL endpoint. * Test for sources GraphQL endpoint. * Move tests to typescript. * Renaming infraops to infra.
This commit is contained in:
parent
bc2803d151
commit
6b5b4cc33b
4 changed files with 92 additions and 0 deletions
|
@ -9,6 +9,7 @@ import gql from 'graphql-tag';
|
|||
export const sourceQuery = gql`
|
||||
query SourceQuery($sourceId: ID = "default") {
|
||||
source(id: $sourceId) {
|
||||
id
|
||||
configuration {
|
||||
metricAlias
|
||||
logAlias
|
||||
|
|
39
x-pack/test/api_integration/apis/infra/capabilities.ts
Normal file
39
x-pack/test/api_integration/apis/infra/capabilities.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 expect from 'expect.js';
|
||||
import { CapabilitiesQuery } from '../../../../plugins/infra/common/graphql/types';
|
||||
import { capabilitiesQuery } from '../../../../plugins/infra/public/containers/capabilities/capabilities.gql_query';
|
||||
import { KbnTestProvider } from './types';
|
||||
|
||||
const capabilitiesTests: KbnTestProvider = ({ getService }) => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const client = getService('infraOpsGraphQLClient');
|
||||
|
||||
describe('capabilities', () => {
|
||||
before(() => esArchiver.load('infra'));
|
||||
after(() => esArchiver.unload('infra'));
|
||||
|
||||
it('supports the capabilities container query', () => {
|
||||
return client
|
||||
.query<CapabilitiesQuery.Query>({
|
||||
query: capabilitiesQuery,
|
||||
variables: {
|
||||
sourceId: 'default',
|
||||
nodeId: 'demo-stack-nginx-01',
|
||||
nodeType: 'host',
|
||||
},
|
||||
})
|
||||
.then(resp => {
|
||||
const capabilities = resp.data.source.capabilitiesByNode;
|
||||
expect(capabilities.length).to.be(14);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// tslint:disable-next-line no-default-export
|
||||
export default capabilitiesTests;
|
|
@ -9,5 +9,7 @@ export default function ({ loadTestFile }) {
|
|||
describe('InfraOps GraphQL Endpoints', () => {
|
||||
loadTestFile(require.resolve('./metrics'));
|
||||
loadTestFile(require.resolve('./waffle'));
|
||||
loadTestFile(require.resolve('./capabilities'));
|
||||
loadTestFile(require.resolve('./sources'));
|
||||
});
|
||||
}
|
||||
|
|
50
x-pack/test/api_integration/apis/infra/sources.ts
Normal file
50
x-pack/test/api_integration/apis/infra/sources.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 expect from 'expect.js';
|
||||
import { SourceQuery } from '../../../../plugins/infra/common/graphql/types';
|
||||
import { sourceQuery } from '../../../../plugins/infra/public/store/remote/source/operations/query_source.gql_query';
|
||||
|
||||
import { KbnTestProvider } from './types';
|
||||
|
||||
const sourcesTests: KbnTestProvider = ({ getService }) => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const client = getService('infraOpsGraphQLClient');
|
||||
|
||||
describe('sources', () => {
|
||||
before(() => esArchiver.load('infra'));
|
||||
after(() => esArchiver.unload('infra'));
|
||||
|
||||
it('supports the redux store query', () => {
|
||||
return client
|
||||
.query<SourceQuery.Query>({
|
||||
query: sourceQuery,
|
||||
variables: {
|
||||
sourceId: 'default',
|
||||
},
|
||||
})
|
||||
.then(resp => {
|
||||
const sourceConfiguration = resp.data.source.configuration;
|
||||
const sourceStatus = resp.data.source.status;
|
||||
|
||||
// shipped default values
|
||||
expect(sourceConfiguration.metricAlias).to.be('metricbeat-*');
|
||||
expect(sourceConfiguration.logAlias).to.be('filebeat-*');
|
||||
expect(sourceConfiguration.fields.container).to.be('docker.container.name');
|
||||
expect(sourceConfiguration.fields.host).to.be('beat.hostname');
|
||||
expect(sourceConfiguration.fields.pod).to.be('kubernetes.pod.name');
|
||||
|
||||
// test data in x-pack/test/functional/es_archives/infra/data.json.gz
|
||||
expect(sourceStatus.indexFields.length).to.be(1765);
|
||||
expect(sourceStatus.logIndicesExist).to.be(true);
|
||||
expect(sourceStatus.metricIndicesExist).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// tslint:disable-next-line no-default-export
|
||||
export default sourcesTests;
|
Loading…
Add table
Add a link
Reference in a new issue