From 179997e30364bfb5271bc0528220807619ed8f0d Mon Sep 17 00:00:00 2001 From: Lucas Fernandes da Costa Date: Wed, 6 Apr 2022 14:38:59 +0100 Subject: [PATCH] [Uptime] remove latency limit warnings when using monitor management --- .../monitor_management/locations.ts | 4 -- .../browser/throttling_fields.test.tsx | 49 ------------------- .../browser/throttling_fields.tsx | 29 ++++------- .../get_service_locations.test.ts | 2 - .../get_service_locations.ts | 3 +- 5 files changed, 11 insertions(+), 76 deletions(-) diff --git a/x-pack/plugins/uptime/common/runtime_types/monitor_management/locations.ts b/x-pack/plugins/uptime/common/runtime_types/monitor_management/locations.ts index ab9a6f90de0a0..8ee664bda1ebf 100644 --- a/x-pack/plugins/uptime/common/runtime_types/monitor_management/locations.ts +++ b/x-pack/plugins/uptime/common/runtime_types/monitor_management/locations.ts @@ -12,19 +12,16 @@ import { tEnum } from '../../utils/t_enum'; export enum BandwidthLimitKey { DOWNLOAD = 'download', UPLOAD = 'upload', - LATENCY = 'latency', } export const DEFAULT_BANDWIDTH_LIMIT = { [BandwidthLimitKey.DOWNLOAD]: 100, [BandwidthLimitKey.UPLOAD]: 30, - [BandwidthLimitKey.LATENCY]: 1000, }; export const DEFAULT_THROTTLING = { [BandwidthLimitKey.DOWNLOAD]: DEFAULT_BANDWIDTH_LIMIT[BandwidthLimitKey.DOWNLOAD], [BandwidthLimitKey.UPLOAD]: DEFAULT_BANDWIDTH_LIMIT[BandwidthLimitKey.UPLOAD], - [BandwidthLimitKey.LATENCY]: DEFAULT_BANDWIDTH_LIMIT[BandwidthLimitKey.LATENCY], }; export const BandwidthLimitKeyCodec = tEnum( @@ -107,7 +104,6 @@ export const isServiceLocationInvalid = (location: MonitorServiceLocation) => export const ThrottlingOptionsCodec = t.interface({ [BandwidthLimitKey.DOWNLOAD]: t.number, [BandwidthLimitKey.UPLOAD]: t.number, - [BandwidthLimitKey.LATENCY]: t.number, }); export const ServiceLocationsApiResponseCodec = t.interface({ diff --git a/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.test.tsx b/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.test.tsx index f817f1ff9a805..dc74717ec2c98 100644 --- a/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.test.tsx +++ b/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.test.tsx @@ -214,7 +214,6 @@ describe('', () => { const throttling = { [BandwidthLimitKey.DOWNLOAD]: 100, [BandwidthLimitKey.UPLOAD]: 50, - [BandwidthLimitKey.LATENCY]: 25, }; const defaultLocations = [defaultLocation]; @@ -339,54 +338,6 @@ describe('', () => { ) ).not.toBeInTheDocument(); }); - - it("shows latency warnings when exceeding the node's latency limits", () => { - const { getByLabelText, queryByText } = render( - - ); - - const latencyLimit = throttling[BandwidthLimitKey.LATENCY]; - - const latency = getByLabelText('Latency') as HTMLInputElement; - userEvent.clear(latency); - userEvent.type(latency, String(latencyLimit + 1)); - - expect( - queryByText( - `You have exceeded the latency limit for Synthetic Nodes. The latency value can't be larger than ${latencyLimit}ms.` - ) - ).toBeInTheDocument(); - - expect( - queryByText("You've exceeded the Synthetics Node bandwidth limits") - ).toBeInTheDocument(); - - expect( - queryByText( - 'When using throttling values larger than a Synthetics Node bandwidth limit, your monitor will still have its bandwidth capped.' - ) - ).toBeInTheDocument(); - - userEvent.clear(latency); - userEvent.type(latency, String(latencyLimit - 1)); - expect( - queryByText( - `You have exceeded the latency limit for Synthetic Nodes. The latency value can't be larger than ${latencyLimit}ms.` - ) - ).not.toBeInTheDocument(); - - expect( - queryByText("You've exceeded the Synthetics Node bandwidth limits") - ).not.toBeInTheDocument(); - - expect( - queryByText( - 'When using throttling values larger than a Synthetics Node bandwidth limit, your monitor will still have its bandwidth capped.' - ) - ).not.toBeInTheDocument(); - }); }); it('only displays download, upload, and latency fields with throttling is on', () => { diff --git a/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.tsx b/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.tsx index 683bc1e79e386..f7fc15887e721 100644 --- a/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.tsx +++ b/x-pack/plugins/uptime/public/components/fleet_package/browser/throttling_fields.tsx @@ -76,17 +76,15 @@ export const ThrottlingExceededCallout = () => { export const ThrottlingExceededMessage = ({ throttlingField, limit, - unit, }: { throttlingField: string; limit: number; - unit: string; }) => { return ( ); }; @@ -97,7 +95,6 @@ export const ThrottlingFields = memo(({ validate, minColumnWidth, onField const maxDownload = throttling[BandwidthLimitKey.DOWNLOAD]; const maxUpload = throttling[BandwidthLimitKey.UPLOAD]; - const maxLatency = throttling[BandwidthLimitKey.LATENCY]; const handleInputChange = useCallback( ({ value, configKey }: { value: unknown; configKey: ThrottlingConfigs }) => { @@ -110,7 +107,6 @@ export const ThrottlingFields = memo(({ validate, minColumnWidth, onField runsOnService && parseFloat(fields[ConfigKey.DOWNLOAD_SPEED]) > maxDownload; const exceedsUploadLimits = runsOnService && parseFloat(fields[ConfigKey.UPLOAD_SPEED]) > maxUpload; - const exceedsLatencyLimits = runsOnService && parseFloat(fields[ConfigKey.LATENCY]) > maxLatency; const isThrottlingEnabled = fields[ConfigKey.IS_THROTTLING_ENABLED]; const throttlingInputs = isThrottlingEnabled ? ( @@ -127,7 +123,7 @@ export const ThrottlingFields = memo(({ validate, minColumnWidth, onField isInvalid={!!validate[ConfigKey.DOWNLOAD_SPEED]?.(fields) || exceedsDownloadLimits} error={ exceedsDownloadLimits ? ( - + ) : ( (({ validate, minColumnWidth, onField isInvalid={!!validate[ConfigKey.UPLOAD_SPEED]?.(fields) || exceedsUploadLimits} error={ exceedsUploadLimits ? ( - + ) : ( (({ validate, minColumnWidth, onField /> } labelAppend={} - isInvalid={!!validate[ConfigKey.LATENCY]?.(fields) || exceedsLatencyLimits} + isInvalid={!!validate[ConfigKey.LATENCY]?.(fields)} error={ - exceedsLatencyLimits ? ( - - ) : ( - - ) + } > (({ validate, minColumnWidth, onField } onBlur={() => onFieldBlur?.(ConfigKey.IS_THROTTLING_ENABLED)} /> - {isThrottlingEnabled && - (exceedsDownloadLimits || exceedsUploadLimits || exceedsLatencyLimits) ? ( + {isThrottlingEnabled && (exceedsDownloadLimits || exceedsUploadLimits) ? ( <> diff --git a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts index 82fe06f36d533..9151a1dcac6ad 100644 --- a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts +++ b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts @@ -18,7 +18,6 @@ describe('getServiceLocations', function () { throttling: { [BandwidthLimitKey.DOWNLOAD]: 100, [BandwidthLimitKey.UPLOAD]: 50, - [BandwidthLimitKey.LATENCY]: 20, }, locations: { us_central: { @@ -50,7 +49,6 @@ describe('getServiceLocations', function () { throttling: { [BandwidthLimitKey.DOWNLOAD]: 100, [BandwidthLimitKey.UPLOAD]: 50, - [BandwidthLimitKey.LATENCY]: 20, }, locations: [ { diff --git a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts index 50ecfe38d20dd..45dd0ded1438d 100644 --- a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts +++ b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts @@ -54,8 +54,7 @@ export async function getServiceLocations(server: UptimeServerSetup) { const throttling = pick( data.throttling, BandwidthLimitKey.DOWNLOAD, - BandwidthLimitKey.UPLOAD, - BandwidthLimitKey.LATENCY + BandwidthLimitKey.UPLOAD ) as ThrottlingOptions; return { throttling, locations };