Skip to content

Commit

Permalink
[8.11] [Synthetics] Unskip alerting test (#168958) (#169544)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.11`:
- [[Synthetics] Unskip alerting test
(#168958)](#168958)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-23T15:23:33Z","message":"[Synthetics]
Unskip alerting test
(#168958)","sha":"032a12606eea62efbed84da00847eefd347fc8b8","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:uptime","release_note:skip","v8.11.0","v8.12.0"],"number":168958,"url":"https://github.com/elastic/kibana/pull/168958","mergeCommit":{"message":"[Synthetics]
Unskip alerting test
(#168958)","sha":"032a12606eea62efbed84da00847eefd347fc8b8"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/168958","number":168958,"mergeCommit":{"message":"[Synthetics]
Unskip alerting test
(#168958)","sha":"032a12606eea62efbed84da00847eefd347fc8b8"}}]}]
BACKPORT-->

Co-authored-by: Shahzad <[email protected]>
  • Loading branch information
kibanamachine and shahzad31 authored Oct 23, 2023
1 parent b2bdb9f commit 10016d7
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ journey(`DefaultStatusAlert`, async ({ page, params }) => {
await page.click(byTestId('xpack.synthetics.alertsPopover.toggleButton'));
await page.isDisabled(byTestId('xpack.synthetics.toggleAlertFlyout'));
await page.click(byTestId('xpack.synthetics.toggleAlertFlyout'));
await page.waitForSelector('text=Edit rule');
await page.waitForSelector('text=Monitor status rule');
expect(await page.locator(`[data-test-subj="intervalFormRow"]`).count()).toEqual(0);
await page.click(byTestId('saveEditedRuleButton'));
await page.waitForSelector("text=Updated 'Synthetics internal alert'");
await page.waitForSelector("text=Updated 'Synthetics status internal rule'");
});

step('Monitor is as up in overview page', async () => {
Expand Down Expand Up @@ -108,7 +108,7 @@ journey(`DefaultStatusAlert`, async ({ page, params }) => {
name: 'Test Monitor',
location: 'North America - US Central',
timestamp: downCheckTime,
status: 'is down.',
status: 'down',
});

await retry.tryForTime(3 * 60 * 1000, async () => {
Expand Down Expand Up @@ -169,7 +169,7 @@ journey(`DefaultStatusAlert`, async ({ page, params }) => {
name,
location: 'North America - US Central',
timestamp: downCheckTime,
status: 'is down.',
status: 'down',
});

await retry.tryForTime(3 * 60 * 1000, async () => {
Expand Down Expand Up @@ -198,7 +198,6 @@ journey(`DefaultStatusAlert`, async ({ page, params }) => {
await page.waitForTimeout(10 * 1000);

await page.click('[aria-label="View in app"]');
await page.click(byTestId('syntheticsMonitorOverviewTab'));
await page.waitForSelector('text=Monitor details');
await page.click(byTestId('breadcrumb /app/synthetics/monitors'));
});
});
2 changes: 1 addition & 1 deletion x-pack/plugins/synthetics/e2e/synthetics/journeys/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './private_locations.journey';
export * from './alerting_default.journey';
export * from './global_parameters.journey';
export * from './detail_flyout';
// export * from './alert_rules/default_status_alert.journey';
export * from './alert_rules/default_status_alert.journey';
export * from './test_now_mode.journey';
export * from './monitor_details_page/monitor_summary.journey';
export * from './test_run_details.journey';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import axios from 'axios';
import type { Client } from '@elastic/elasticsearch';
import { KbnClient, uriencode } from '@kbn/test';
import { KbnClient } from '@kbn/test';
import pMap from 'p-map';
import { SyntheticsMonitor } from '../../../../common/runtime_types';
import { SYNTHETICS_API_URLS } from '../../../../common/constants';
Expand Down Expand Up @@ -100,12 +100,13 @@ export class SyntheticsServices {
});

const { monitors = [] } = data as any;

await pMap(
monitors,
async (monitor: Record<string, any>) => {
await this.requester.request({
description: 'delete monitor',
path: uriencode`${SYNTHETICS_API_URLS.SYNTHETICS_MONITORS}/${monitor.id}`,
path: `${SYNTHETICS_API_URLS.SYNTHETICS_MONITORS}/${monitor.config_id}`,
method: 'DELETE',
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { ChromeBreadcrumb } from '@kbn/core/public';
import { render } from '../utils/testing';
import React from 'react';
import { i18n } from '@kbn/i18n';
import { Route } from 'react-router-dom';
import { OVERVIEW_ROUTE } from '../../../../common/constants';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
Expand All @@ -22,13 +23,27 @@ describe('useBreadcrumbs', () => {
const [getBreadcrumbs, core] = mockCore();

const expectedCrumbs: ChromeBreadcrumb[] = [
{ text: 'Crumb: ', href: 'http://href.example.net' },
{ text: 'Crumb II: Son of Crumb', href: 'http://href2.example.net' },
{
text: 'Crumb: ',
'data-test-subj': 'http://href.example.net',
href: 'http://href.example.net',
},
{
text: 'Crumb II: Son of Crumb',
'data-test-subj': 'http://href2.example.net',
href: 'http://href2.example.net',
},
];

const Component = () => {
useBreadcrumbs(expectedCrumbs);
return <>Hello</>;
return (
<>
{i18n.translate('app_not_found_in_i18nrc.component.helloLabel', {
defaultMessage: 'Hello',
})}
</>
);
};

render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ function handleBreadcrumbClick(
},
}
: {}),
...(bc['data-test-subj']
? {
'data-test-subj': bc['data-test-subj'],
}
: {
'data-test-subj': bc.href,
}),
}));
}

Expand All @@ -54,12 +61,14 @@ export const makeBaseBreadcrumb = (
defaultMessage: 'Observability',
}),
href: observabilityPath,
'data-test-subj': 'observabilityPathBreadcrumb',
},
{
text: i18n.translate('xpack.synthetics.breadcrumbs.overviewBreadcrumbText', {
defaultMessage: 'Synthetics',
}),
href: uptimePath,
'data-test-subj': 'syntheticsPathBreadcrumb',
},
];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ export class DefaultAlertService {
setupStatusRule() {
return this.createDefaultAlertIfNotExist(
SYNTHETICS_STATUS_RULE,
`Synthetics status internal alert`,
`Synthetics status internal rule`,
'1m'
);
}

setupTlsRule() {
return this.createDefaultAlertIfNotExist(
SYNTHETICS_TLS_RULE,
`Synthetics internal TLS alert`,
`Synthetics internal TLS rule`,
'1m'
);
}
Expand Down Expand Up @@ -115,14 +115,10 @@ export class DefaultAlertService {
}

updateStatusRule() {
return this.updateDefaultAlert(
SYNTHETICS_STATUS_RULE,
`Synthetics status internal alert`,
'1m'
);
return this.updateDefaultAlert(SYNTHETICS_STATUS_RULE, `Synthetics status internal rule`, '1m');
}
updateTlsRule() {
return this.updateDefaultAlert(SYNTHETICS_TLS_RULE, `Synthetics internal TLS alert`, '1m');
return this.updateDefaultAlert(SYNTHETICS_TLS_RULE, `Synthetics internal TLS rule`, '1m');
}

async updateDefaultAlert(ruleType: DefaultRuleType, name: string, interval: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const statusRule = {
consumer: 'uptime',
alertTypeId: 'xpack.synthetics.alerts.monitorStatus',
tags: ['SYNTHETICS_DEFAULT_ALERT'],
name: 'Synthetics status internal alert',
name: 'Synthetics status internal rule',
enabled: true,
throttle: null,
apiKeyOwner: 'elastic',
Expand Down Expand Up @@ -344,7 +344,7 @@ const tlsRule = {
consumer: 'uptime',
alertTypeId: 'xpack.synthetics.alerts.tls',
tags: ['SYNTHETICS_DEFAULT_ALERT'],
name: 'Synthetics internal TLS alert',
name: 'Synthetics internal TLS rule',
enabled: true,
throttle: null,
apiKeyOwner: 'elastic',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const defaultAlertRules = {
consumer: 'uptime',
alertTypeId: 'xpack.synthetics.alerts.monitorStatus',
tags: ['SYNTHETICS_DEFAULT_ALERT'],
name: 'Synthetics status internal alert',
name: 'Synthetics status internal rule',
enabled: true,
throttle: null,
apiKeyOwner: 'elastic',
Expand Down Expand Up @@ -137,7 +137,7 @@ const defaultAlertRules = {
consumer: 'uptime',
alertTypeId: 'xpack.synthetics.alerts.tls',
tags: ['SYNTHETICS_DEFAULT_ALERT'],
name: 'Synthetics internal TLS alert',
name: 'Synthetics internal TLS rule',
enabled: true,
throttle: null,
apiKeyOwner: 'elastic',
Expand Down

0 comments on commit 10016d7

Please sign in to comment.