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] Unskip alert functional test #101562

Merged
merged 5 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -46,7 +46,7 @@ export const AlertQueryBar = ({ query = '', onChange }: Props) => {
}}
query={{ query: inputVal, language: 'kuery' }}
aria-label={labels.ALERT_KUERY_BAR_ARIA}
data-test-subj="xpack.uptime.alerts.monitorStatus.filterBar"
dataTestSubj="xpack.uptime.alerts.monitorStatus.filterBar"
autoSubmit={true}
disableLanguageSwitcher={true}
isInvalid={!!(inputVal && !query)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ export const AlertMonitorStatus: React.FC<Props> = ({
}) => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(
fetchOverviewFilters({
dateRangeStart: 'now-24h',
dateRangeEnd: 'now',
locations: alertParams.filters?.['observer.geo.name'] ?? [],
ports: alertParams.filters?.['url.port'] ?? [],
tags: alertParams.filters?.tags ?? [],
schemes: alertParams.filters?.['monitor.type'] ?? [],
})
);
if (!window.location.pathname.includes('/app/uptime')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// filters inside uptime app already loaded
dispatch(
fetchOverviewFilters({
dateRangeStart: 'now-24h',
dateRangeEnd: 'now',
locations: alertParams.filters?.['observer.geo.name'] ?? [],
ports: alertParams.filters?.['url.port'] ?? [],
tags: alertParams.filters?.tags ?? [],
schemes: alertParams.filters?.['monitor.type'] ?? [],
})
);
}
}, [alertParams, dispatch]);

const overviewFilters = useSelector(overviewFiltersSelector);
Expand Down
10 changes: 6 additions & 4 deletions x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to maintain our own delay function. bluebird exports one and it's used in other places.


export default ({ getPageObjects, getService }: FtrProviderContext) => {
// FLAKY: https://github.com/elastic/kibana/issues/88177
describe.skip('uptime alerts', () => {
describe('uptime alerts', () => {
const pageObjects = getPageObjects(['common', 'uptime']);
const supertest = getService('supertest');
const retry = getService('retry');
Expand Down Expand Up @@ -91,11 +91,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
// put the fetch code in a retry block with a timeout.
let alert: any;
await retry.tryForTime(60 * 1000, async () => {
// add a delay before next call to not overload the server
await delay(1500);
const apiResponse = await supertest.get('/api/alerts/_find?search=uptime-test');
const alertsFromThisTest = apiResponse.body.data.filter(
({ name }: { name: string }) => name === 'uptime-test'
);
expect(alertsFromThisTest).to.have.length(1);
expect(alertsFromThisTest.length >= 1).to.be(true);
alert = alertsFromThisTest[0];
});

Expand Down Expand Up @@ -124,7 +126,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(timerangeUnit).to.be('h');
expect(timerangeCount).to.be(1);
expect(JSON.stringify(filters)).to.eql(
`{"url.port":["5678"],"observer.geo.name":["mpls"],"monitor.type":["http"],"tags":[]}`
`{"tags":[],"url.port":["5678"],"observer.geo.name":["mpls"],"monitor.type":["http"]}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need for this change or just the result of doing some testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, seems like the order has changed.

);
} finally {
await supertest.delete(`/api/alerts/alert/${id}`).set('kbn-xsrf', 'true').expect(204);
Expand Down