[Metrics + Logs UI] Add test for logs and metrics telemetry (#70858)

* Add test for logs and metrics telemetry

* wait before you go

* Remove kubenetes

* Fix type check

* Add back kubernetes test

* Remove kubernetes

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Phillip Burch 2020-07-13 08:57:42 -05:00 committed by GitHub
parent 4b9902987f
commit 4bdd31e9c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 120 additions and 1 deletions

View file

@ -9,13 +9,15 @@ import React, { ReactNode } from 'react';
import { withTheme, EuiTheme } from '../../../../../../observability/public';
interface Props {
'data-test-subj'?: string;
label: string;
onClick: () => void;
theme: EuiTheme | undefined;
children: ReactNode;
}
export const DropdownButton = withTheme(({ onClick, label, theme, children }: Props) => {
export const DropdownButton = withTheme((props: Props) => {
const { onClick, label, theme, children } = props;
return (
<EuiFlexGroup
alignItems="center"
@ -39,6 +41,7 @@ export const DropdownButton = withTheme(({ onClick, label, theme, children }: Pr
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj={props['data-test-subj']}
color="text"
iconType="arrowDown"
onClick={onClick}

View file

@ -68,14 +68,17 @@ export const WaffleInventorySwitcher: React.FC = () => {
id: 'firstPanel',
items: [
{
'data-test-subj': 'goToHost',
name: getDisplayNameForType('host'),
onClick: goToHost,
},
{
'data-test-subj': 'goToPods',
name: getDisplayNameForType('pod'),
onClick: goToK8,
},
{
'data-test-subj': 'goToDocker',
name: getDisplayNameForType('container'),
onClick: goToDocker,
},
@ -117,6 +120,7 @@ export const WaffleInventorySwitcher: React.FC = () => {
const button = (
<DropdownButton
data-test-subj={'openInventorySwitcher'}
onClick={openPopover}
label={i18n.translate('xpack.infra.waffle.showLabel', { defaultMessage: 'Show' })}
>

View file

@ -4,15 +4,22 @@
* you may not use this file except in compliance with the Elastic License.
*/
import moment from 'moment';
import expect from '@kbn/expect/expect.js';
import { FtrProviderContext } from '../../ftr_provider_context';
import { DATES } from './constants';
const DATE_WITH_DATA = DATES.metricsAndLogs.hosts.withData;
const DATE_WITHOUT_DATA = DATES.metricsAndLogs.hosts.withoutData;
const COMMON_REQUEST_HEADERS = {
'kbn-xsrf': 'some-xsrf-token',
};
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const pageObjects = getPageObjects(['common', 'infraHome']);
const supertest = getService('supertest');
describe('Home page', function () {
this.tags('includeFirefox');
@ -46,6 +53,53 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.infraHome.goToTime(DATE_WITHOUT_DATA);
await pageObjects.infraHome.getNoMetricsDataPrompt();
});
it('records telemetry for hosts', async () => {
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
await pageObjects.infraHome.getWaffleMap();
const resp = await supertest
.post(`/api/telemetry/v2/clusters/_stats`)
.set(COMMON_REQUEST_HEADERS)
.set('Accept', 'application/json')
.send({
timeRange: {
min: moment().subtract(1, 'hour').toISOString(),
max: moment().toISOString(),
},
unencrypted: true,
})
.expect(200)
.then((res: any) => res.body);
expect(
resp[0].stack_stats.kibana.plugins.infraops.last_24_hours.hits.infraops_hosts
).to.be.greaterThan(0);
});
it('records telemetry for docker', async () => {
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
await pageObjects.infraHome.getWaffleMap();
await pageObjects.infraHome.goToDocker();
const resp = await supertest
.post(`/api/telemetry/v2/clusters/_stats`)
.set(COMMON_REQUEST_HEADERS)
.set('Accept', 'application/json')
.send({
timeRange: {
min: moment().subtract(1, 'hour').toISOString(),
max: moment().toISOString(),
},
unencrypted: true,
})
.expect(200)
.then((res: any) => res.body);
expect(
resp[0].stack_stats.kibana.plugins.infraops.last_24_hours.hits.infraops_docker
).to.be.greaterThan(0);
});
});
});
};

View file

@ -5,16 +5,22 @@
*/
import expect from '@kbn/expect';
import moment from 'moment';
import { DATES } from './constants';
import { FtrProviderContext } from '../../ftr_provider_context';
const COMMON_REQUEST_HEADERS = {
'kbn-xsrf': 'some-xsrf-token',
};
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const logsUi = getService('logsUi');
const infraSourceConfigurationForm = getService('infraSourceConfigurationForm');
const pageObjects = getPageObjects(['common', 'infraLogs']);
const retry = getService('retry');
const supertest = getService('supertest');
describe('Logs Source Configuration', function () {
before(async () => {
@ -97,6 +103,35 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(logStreamEntryColumns).to.have.length(3);
});
it('records telemetry for logs', async () => {
await logsUi.logStreamPage.navigateTo({
logPosition: {
start: DATES.metricsAndLogs.stream.startWithData,
end: DATES.metricsAndLogs.stream.endWithData,
},
});
await logsUi.logStreamPage.getStreamEntries();
const resp = await supertest
.post(`/api/telemetry/v2/clusters/_stats`)
.set(COMMON_REQUEST_HEADERS)
.set('Accept', 'application/json')
.send({
timeRange: {
min: moment().subtract(1, 'hour').toISOString(),
max: moment().toISOString(),
},
unencrypted: true,
})
.expect(200)
.then((res: any) => res.body);
expect(
resp[0].stack_stats.kibana.plugins.infraops.last_24_hours.hits.logs
).to.be.greaterThan(0);
});
it('can change the log columns', async () => {
await pageObjects.infraLogs.navigateToTab('settings');

View file

@ -33,6 +33,29 @@ export function InfraHomePageProvider({ getService }: FtrProviderContext) {
return await testSubjects.find('waffleMap');
},
async openInvenotrySwitcher() {
await testSubjects.click('openInventorySwitcher');
return await testSubjects.find('goToHost');
},
async goToHost() {
await testSubjects.click('openInventorySwitcher');
await testSubjects.find('goToHost');
return await testSubjects.click('goToHost');
},
async goToPods() {
await testSubjects.click('openInventorySwitcher');
await testSubjects.find('goToHost');
return await testSubjects.click('goToPods');
},
async goToDocker() {
await testSubjects.click('openInventorySwitcher');
await testSubjects.find('goToHost');
return await testSubjects.click('goToDocker');
},
async goToMetricExplorer() {
return await testSubjects.click('infrastructureNavLink_/infrastructure/metrics-explorer');
},