Skip to content

Commit

Permalink
[Uptime] Hide integration using IP when IP not present (#50138)
Browse files Browse the repository at this point in the history
Fixes #49366 , where this issue
was first described. If linking is based on IP we should only show the
link if we actually have an IP.
  • Loading branch information
andrewvc committed Nov 14, 2019
1 parent e44616e commit 063d13b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ describe('getInfraHref', () => {
expect(getInfraKubernetesHref(summary, '')).toBeUndefined();
});

it('getInfraKubernetesHref returns undefined when checks are null', () => {
summary.state.checks![0]!.kubernetes!.pod!.uid = null;
expect(getInfraKubernetesHref(summary, '')).toBeUndefined();
});

it('getInfraIpHref creates a link for valid parameters', () => {
const result = getInfraIpHref(summary, 'bar');
expect(result).toMatchSnapshot();
Expand All @@ -161,6 +166,11 @@ describe('getInfraHref', () => {
expect(getInfraIpHref(summary, 'foo')).toBeUndefined();
});

it('getInfraIpHref returns undefined when ip is null', () => {
summary.state.checks![0].monitor.ip = null;
expect(getInfraIpHref(summary, 'foo')).toBeUndefined();
});

it('getInfraIpHref returns a url for ors between multiple ips', () => {
summary.state.checks = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,28 @@ describe('getLoggingHref', () => {
expect(getLoggingContainerHref(summary, '')).toBeUndefined();
});

it('returns undefined if necessary container is null', () => {
summary.state.checks![0].container!.id = null;
expect(getLoggingContainerHref(summary, '')).toBeUndefined();
});

it('returns undefined if necessary pod is not present', () => {
delete summary.state.checks;
expect(getLoggingKubernetesHref(summary, '')).toBeUndefined();
});

it('returns undefined if necessary pod is null', () => {
summary.state.checks![0].kubernetes!.pod!.uid = null;
expect(getLoggingKubernetesHref(summary, '')).toBeUndefined();
});

it('returns undefined ip href if ip is not present', () => {
delete summary.state.checks;
expect(getLoggingIpHref(summary, '')).toBeUndefined();
});

it('returns undefined ip href if ip is null', () => {
summary.state.checks![0].monitor.ip = null;
expect(getLoggingIpHref(summary, '')).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const getInfraContainerHref = (
basePath: string
): string | undefined => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(basePath, `/app/infra#/link-to/container-detail/${encodeURIComponent(ret)}`);
Expand All @@ -27,8 +27,8 @@ export const getInfraKubernetesHref = (
basePath: string
): string | undefined => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(basePath, `/app/infra#/link-to/pod-detail/${encodeURIComponent(ret)}`);
Expand All @@ -39,8 +39,8 @@ export const getInfraKubernetesHref = (

export const getInfraIpHref = (summary: MonitorSummary, basePath: string) => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
if (!Array.isArray(value)) {
const expression = encodeURIComponent(`host.ip : ${value}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const getLoggingContainerHref = (
basePath: string
): string | undefined => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(
Expand All @@ -27,8 +27,8 @@ export const getLoggingContainerHref = (

export const getLoggingKubernetesHref = (summary: MonitorSummary, basePath: string) => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(
Expand All @@ -41,8 +41,8 @@ export const getLoggingKubernetesHref = (summary: MonitorSummary, basePath: stri

export const getLoggingIpHref = (summary: MonitorSummary, basePath: string) => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(
Expand Down

0 comments on commit 063d13b

Please sign in to comment.