Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Remove latency warnings on monitor management UI #129597

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<BandwidthLimitKey>(
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ describe('<ThrottlingFields />', () => {
const throttling = {
[BandwidthLimitKey.DOWNLOAD]: 100,
[BandwidthLimitKey.UPLOAD]: 50,
[BandwidthLimitKey.LATENCY]: 25,
};

const defaultLocations = [defaultLocation];
Expand Down Expand Up @@ -339,54 +338,6 @@ describe('<ThrottlingFields />', () => {
)
).not.toBeInTheDocument();
});

it("shows latency warnings when exceeding the node's latency limits", () => {
const { getByLabelText, queryByText } = render(
<WrappedComponent
policyConfigOverrides={{ throttling, defaultLocations, runsOnService: true }}
/>
);

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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ export const ThrottlingExceededCallout = () => {
export const ThrottlingExceededMessage = ({
throttlingField,
limit,
unit,
}: {
throttlingField: string;
limit: number;
unit: string;
}) => {
return (
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.browserAdvancedSettings.throttling.throttling_exceeded.message"
defaultMessage="You have exceeded the { throttlingField } limit for Synthetic Nodes. The { throttlingField } value can't be larger than { limit }{unit}."
values={{ throttlingField, limit, unit }}
defaultMessage="You have exceeded the { throttlingField } limit for Synthetic Nodes. The { throttlingField } value can't be larger than { limit }Mbps."
values={{ throttlingField, limit }}
/>
);
};
Expand All @@ -97,7 +95,6 @@ export const ThrottlingFields = memo<Props>(({ 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 }) => {
Expand All @@ -110,7 +107,6 @@ export const ThrottlingFields = memo<Props>(({ 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 ? (
Expand All @@ -127,7 +123,7 @@ export const ThrottlingFields = memo<Props>(({ validate, minColumnWidth, onField
isInvalid={!!validate[ConfigKey.DOWNLOAD_SPEED]?.(fields) || exceedsDownloadLimits}
error={
exceedsDownloadLimits ? (
<ThrottlingExceededMessage throttlingField="download" limit={maxDownload} unit="Mbps" />
<ThrottlingExceededMessage throttlingField="download" limit={maxDownload} />
) : (
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.browserAdvancedSettings.throttling.download.error"
Expand Down Expand Up @@ -166,7 +162,7 @@ export const ThrottlingFields = memo<Props>(({ validate, minColumnWidth, onField
isInvalid={!!validate[ConfigKey.UPLOAD_SPEED]?.(fields) || exceedsUploadLimits}
error={
exceedsUploadLimits ? (
<ThrottlingExceededMessage throttlingField="upload" limit={maxUpload} unit="Mbps" />
<ThrottlingExceededMessage throttlingField="upload" limit={maxUpload} />
) : (
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.browserAdvancedSettings.throttling.upload.error"
Expand Down Expand Up @@ -202,16 +198,12 @@ export const ThrottlingFields = memo<Props>(({ validate, minColumnWidth, onField
/>
}
labelAppend={<OptionalLabel />}
isInvalid={!!validate[ConfigKey.LATENCY]?.(fields) || exceedsLatencyLimits}
isInvalid={!!validate[ConfigKey.LATENCY]?.(fields)}
error={
exceedsLatencyLimits ? (
<ThrottlingExceededMessage throttlingField="latency" limit={maxLatency} unit="ms" />
) : (
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.browserAdvancedSettings.throttling.latency.error"
defaultMessage="Latency must not be negative."
/>
)
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.browserAdvancedSettings.throttling.latency.error"
defaultMessage="Latency must not be negative."
/>
}
>
<EuiFieldNumber
Expand Down Expand Up @@ -277,8 +269,7 @@ export const ThrottlingFields = memo<Props>(({ validate, minColumnWidth, onField
}
onBlur={() => onFieldBlur?.(ConfigKey.IS_THROTTLING_ENABLED)}
/>
{isThrottlingEnabled &&
(exceedsDownloadLimits || exceedsUploadLimits || exceedsLatencyLimits) ? (
{isThrottlingEnabled && (exceedsDownloadLimits || exceedsUploadLimits) ? (
<>
<EuiSpacer />
<ThrottlingExceededCallout />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('getServiceLocations', function () {
throttling: {
[BandwidthLimitKey.DOWNLOAD]: 100,
[BandwidthLimitKey.UPLOAD]: 50,
[BandwidthLimitKey.LATENCY]: 20,
},
locations: {
us_central: {
Expand Down Expand Up @@ -50,7 +49,6 @@ describe('getServiceLocations', function () {
throttling: {
[BandwidthLimitKey.DOWNLOAD]: 100,
[BandwidthLimitKey.UPLOAD]: 50,
[BandwidthLimitKey.LATENCY]: 20,
},
locations: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down