[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:
parent
4b9902987f
commit
4bdd31e9c9
|
@ -9,13 +9,15 @@ import React, { ReactNode } from 'react';
|
||||||
import { withTheme, EuiTheme } from '../../../../../../observability/public';
|
import { withTheme, EuiTheme } from '../../../../../../observability/public';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
'data-test-subj'?: string;
|
||||||
label: string;
|
label: string;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
theme: EuiTheme | undefined;
|
theme: EuiTheme | undefined;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DropdownButton = withTheme(({ onClick, label, theme, children }: Props) => {
|
export const DropdownButton = withTheme((props: Props) => {
|
||||||
|
const { onClick, label, theme, children } = props;
|
||||||
return (
|
return (
|
||||||
<EuiFlexGroup
|
<EuiFlexGroup
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
|
@ -39,6 +41,7 @@ export const DropdownButton = withTheme(({ onClick, label, theme, children }: Pr
|
||||||
</EuiFlexItem>
|
</EuiFlexItem>
|
||||||
<EuiFlexItem grow={false}>
|
<EuiFlexItem grow={false}>
|
||||||
<EuiButtonEmpty
|
<EuiButtonEmpty
|
||||||
|
data-test-subj={props['data-test-subj']}
|
||||||
color="text"
|
color="text"
|
||||||
iconType="arrowDown"
|
iconType="arrowDown"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
|
|
@ -68,14 +68,17 @@ export const WaffleInventorySwitcher: React.FC = () => {
|
||||||
id: 'firstPanel',
|
id: 'firstPanel',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
|
'data-test-subj': 'goToHost',
|
||||||
name: getDisplayNameForType('host'),
|
name: getDisplayNameForType('host'),
|
||||||
onClick: goToHost,
|
onClick: goToHost,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
'data-test-subj': 'goToPods',
|
||||||
name: getDisplayNameForType('pod'),
|
name: getDisplayNameForType('pod'),
|
||||||
onClick: goToK8,
|
onClick: goToK8,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
'data-test-subj': 'goToDocker',
|
||||||
name: getDisplayNameForType('container'),
|
name: getDisplayNameForType('container'),
|
||||||
onClick: goToDocker,
|
onClick: goToDocker,
|
||||||
},
|
},
|
||||||
|
@ -117,6 +120,7 @@ export const WaffleInventorySwitcher: React.FC = () => {
|
||||||
|
|
||||||
const button = (
|
const button = (
|
||||||
<DropdownButton
|
<DropdownButton
|
||||||
|
data-test-subj={'openInventorySwitcher'}
|
||||||
onClick={openPopover}
|
onClick={openPopover}
|
||||||
label={i18n.translate('xpack.infra.waffle.showLabel', { defaultMessage: 'Show' })}
|
label={i18n.translate('xpack.infra.waffle.showLabel', { defaultMessage: 'Show' })}
|
||||||
>
|
>
|
||||||
|
|
|
@ -4,15 +4,22 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* 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 { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
import { DATES } from './constants';
|
import { DATES } from './constants';
|
||||||
|
|
||||||
const DATE_WITH_DATA = DATES.metricsAndLogs.hosts.withData;
|
const DATE_WITH_DATA = DATES.metricsAndLogs.hosts.withData;
|
||||||
const DATE_WITHOUT_DATA = DATES.metricsAndLogs.hosts.withoutData;
|
const DATE_WITHOUT_DATA = DATES.metricsAndLogs.hosts.withoutData;
|
||||||
|
|
||||||
|
const COMMON_REQUEST_HEADERS = {
|
||||||
|
'kbn-xsrf': 'some-xsrf-token',
|
||||||
|
};
|
||||||
|
|
||||||
export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
||||||
const esArchiver = getService('esArchiver');
|
const esArchiver = getService('esArchiver');
|
||||||
const pageObjects = getPageObjects(['common', 'infraHome']);
|
const pageObjects = getPageObjects(['common', 'infraHome']);
|
||||||
|
const supertest = getService('supertest');
|
||||||
|
|
||||||
describe('Home page', function () {
|
describe('Home page', function () {
|
||||||
this.tags('includeFirefox');
|
this.tags('includeFirefox');
|
||||||
|
@ -46,6 +53,53 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
||||||
await pageObjects.infraHome.goToTime(DATE_WITHOUT_DATA);
|
await pageObjects.infraHome.goToTime(DATE_WITHOUT_DATA);
|
||||||
await pageObjects.infraHome.getNoMetricsDataPrompt();
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,16 +5,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
|
import moment from 'moment';
|
||||||
import { DATES } from './constants';
|
import { DATES } from './constants';
|
||||||
|
|
||||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
|
|
||||||
|
const COMMON_REQUEST_HEADERS = {
|
||||||
|
'kbn-xsrf': 'some-xsrf-token',
|
||||||
|
};
|
||||||
|
|
||||||
export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
||||||
const esArchiver = getService('esArchiver');
|
const esArchiver = getService('esArchiver');
|
||||||
const logsUi = getService('logsUi');
|
const logsUi = getService('logsUi');
|
||||||
const infraSourceConfigurationForm = getService('infraSourceConfigurationForm');
|
const infraSourceConfigurationForm = getService('infraSourceConfigurationForm');
|
||||||
const pageObjects = getPageObjects(['common', 'infraLogs']);
|
const pageObjects = getPageObjects(['common', 'infraLogs']);
|
||||||
const retry = getService('retry');
|
const retry = getService('retry');
|
||||||
|
const supertest = getService('supertest');
|
||||||
|
|
||||||
describe('Logs Source Configuration', function () {
|
describe('Logs Source Configuration', function () {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
@ -97,6 +103,35 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
||||||
expect(logStreamEntryColumns).to.have.length(3);
|
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 () => {
|
it('can change the log columns', async () => {
|
||||||
await pageObjects.infraLogs.navigateToTab('settings');
|
await pageObjects.infraLogs.navigateToTab('settings');
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,29 @@ export function InfraHomePageProvider({ getService }: FtrProviderContext) {
|
||||||
return await testSubjects.find('waffleMap');
|
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() {
|
async goToMetricExplorer() {
|
||||||
return await testSubjects.click('infrastructureNavLink_/infrastructure/metrics-explorer');
|
return await testSubjects.click('infrastructureNavLink_/infrastructure/metrics-explorer');
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue