[Uptime] Support agent data streams (#91469)

Co-authored-by: Dominique Clarke <doclarke71@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Shahzad 2021-03-25 09:04:40 +01:00 committed by GitHub
parent 6b5023a681
commit 69bb5979ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 98 additions and 26 deletions

View file

@ -8,7 +8,7 @@
import { DynamicSettings } from '../runtime_types';
export const DYNAMIC_SETTINGS_DEFAULTS: DynamicSettings = {
heartbeatIndices: 'heartbeat-8*',
heartbeatIndices: 'heartbeat-8*,synthetics-*',
certAgeThreshold: 730,
certExpirationThreshold: 30,
defaultConnectors: [],

View file

@ -68,6 +68,7 @@ export const AddConnectorFlyout = ({ focusInput }: Props) => {
return (
<>
<EuiButtonEmpty
data-test-subj="createConnectorButton"
iconType="plusInCircleFilled"
iconSide="left"
onClick={() => setAddFlyoutVisibility(true)}

View file

@ -23,6 +23,8 @@ import {
import { MountWithReduxProvider } from './helper_with_redux';
import { AppState } from '../../state';
import { stringifyUrlParams } from './stringify_url_params';
import { ClientPluginsStart } from '../../apps/plugin';
import { triggersActionsUiMock } from '../../../../triggers_actions_ui/public/mocks';
interface KibanaProps {
services?: KibanaServices;
@ -55,20 +57,39 @@ interface RenderRouterOptions<ExtraCore> extends KibanaProviderOptions<ExtraCore
url?: Url;
}
function getSetting<T = any>(key: string): T {
return ('MMM D, YYYY @ HH:mm:ss.SSS' as unknown) as T;
}
function setSetting$<T = any>(key: string): T {
return (of('MMM D, YYYY @ HH:mm:ss.SSS') as unknown) as T;
}
/* default mock core */
const defaultCore = coreMock.createStart();
const mockCore: () => any = () => {
const core = {
const mockCore: () => Partial<CoreStart> = () => {
const core: Partial<CoreStart & ClientPluginsStart> = {
...defaultCore,
application: {
...defaultCore.application,
getUrlForApp: () => '/app/uptime',
navigateToUrl: jest.fn(),
capabilities: {
...defaultCore.application.capabilities,
uptime: {
'alerting:save': true,
configureSettings: true,
save: true,
show: true,
},
},
},
uiSettings: {
get: (key: string) => 'MMM D, YYYY @ HH:mm:ss.SSS',
get$: (key: string) => of('MMM D, YYYY @ HH:mm:ss.SSS'),
...defaultCore.uiSettings,
get: getSetting,
get$: setSetting$,
},
usageCollection: { reportUiCounter: () => {} },
triggersActionsUi: triggersActionsUiMock.createStart(),
};
return core;

View file

@ -4,10 +4,53 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import { isValidCertVal } from './settings';
import { isValidCertVal, SettingsPage } from './settings';
import { render } from '../lib/helper/rtl_helpers';
import { fireEvent, waitFor } from '@testing-library/dom';
import { act } from 'react-dom/test-utils';
import * as alertApi from '../state/api/alerts';
describe('settings', () => {
describe('form', () => {
beforeAll(() => {
jest.spyOn(alertApi, 'fetchActionTypes').mockImplementation(async () => [
{
enabled: true,
enabledInConfig: true,
enabledInLicense: true,
id: '.slack',
minimumLicenseRequired: 'gold',
name: 'Slack',
},
]);
});
it('handles no spaces error', async () => {
const { getByText, getByTestId } = render(<SettingsPage />);
expect(getByText('heartbeat-8*,synthetics-*'));
fireEvent.input(getByTestId('heartbeat-indices-input-loaded'), {
target: { value: 'heartbeat-8*, synthetics-*' },
});
await waitFor(() => expect(getByText('Index names must not contain space')));
});
it('it show select a connector flyout', async () => {
const { getByText, getByTestId } = render(<SettingsPage />);
expect(getByText('heartbeat-8*,synthetics-*'));
act(() => {
fireEvent.click(getByTestId('createConnectorButton'));
});
await waitFor(() => expect(getByText('Select a connector')));
});
});
describe('isValidCertVal', () => {
it('handles NaN values', () => {
expect(isValidCertVal(NaN)).toMatchInlineSnapshot(`"Must be a number."`);

View file

@ -34,6 +34,7 @@ import {
VALUE_MUST_BE_AN_INTEGER,
} from '../../common/translations';
import { AlertDefaultsForm } from '../components/settings/alert_defaults_form';
import { BLANK_STR, SPACE_STR } from './translations';
interface SettingsPageFieldErrors {
heartbeatIndices: string | '';
@ -65,7 +66,9 @@ const getFieldErrors = (formFields: DynamicSettings | null): SettingsPageFieldEr
if (formFields) {
const { certAgeThreshold, certExpirationThreshold, heartbeatIndices } = formFields;
const indError = heartbeatIndices.match(/^\S+$/) ? '' : Translations.BLANK_STR;
const indErrorSpace = heartbeatIndices.includes(' ') ? SPACE_STR : '';
const indError = indErrorSpace || (heartbeatIndices.match(/^\S+$/) ? '' : BLANK_STR);
const expError = isValidCertVal(certExpirationThreshold);
const ageError = isValidCertVal(certAgeThreshold);

View file

@ -30,3 +30,7 @@ export const settings = {
export const BLANK_STR = i18n.translate('xpack.uptime.settings.blank.error', {
defaultMessage: 'May not be blank.',
});
export const SPACE_STR = i18n.translate('xpack.uptime.settings.noSpace.error', {
defaultMessage: 'Index names must not contain space',
});

View file

@ -55,7 +55,7 @@ Array [
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`;

View file

@ -212,7 +212,7 @@ describe('getCerts', () => {
},
],
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
],
]

View file

@ -241,7 +241,7 @@ describe('monitor availability', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
});
@ -387,7 +387,7 @@ describe('monitor availability', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
@ -701,7 +701,7 @@ describe('monitor availability', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
@ -799,7 +799,7 @@ describe('monitor availability', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`);
@ -929,7 +929,7 @@ describe('monitor availability', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
});

View file

@ -185,7 +185,7 @@ describe('getMonitorStatus', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
});
@ -287,7 +287,7 @@ describe('getMonitorStatus', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
});
@ -474,7 +474,7 @@ describe('getMonitorStatus', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
});
@ -581,7 +581,7 @@ describe('getMonitorStatus', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
});
@ -694,7 +694,7 @@ describe('getMonitorStatus', () => {
},
"size": 0,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
}
`);
expect(result.length).toBe(3);

View file

@ -210,7 +210,7 @@ describe('getNetworkEvents', () => {
"size": 1000,
"track_total_hits": true,
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
],
]

View file

@ -175,7 +175,7 @@ describe('getAll', () => {
},
],
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`);
@ -244,7 +244,7 @@ describe('getAll', () => {
},
],
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`);
@ -313,7 +313,7 @@ describe('getAll', () => {
},
],
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`);
@ -387,7 +387,7 @@ describe('getAll', () => {
},
],
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`);
@ -461,7 +461,7 @@ describe('getAll', () => {
},
],
},
"index": "heartbeat-8*",
"index": "heartbeat-8*,synthetics-*",
},
]
`);