@@ -8,123 +8,208 @@ import expect from '@kbn/expect';
88import { FtrProviderContext } from '../../ftr_provider_context' ;
99
1010export default ( { getPageObjects, getService } : FtrProviderContext ) => {
11- describe ( 'overview page alert flyout controls' , function ( ) {
12- const DEFAULT_DATE_START = 'Sep 10, 2019 @ 12:40:08.078' ;
13- const DEFAULT_DATE_END = 'Sep 11, 2019 @ 19:40:08.078' ;
11+ describe ( 'uptime alerts' , ( ) => {
1412 const pageObjects = getPageObjects ( [ 'common' , 'uptime' ] ) ;
1513 const supertest = getService ( 'supertest' ) ;
1614 const retry = getService ( 'retry' ) ;
17- let alerts : any ;
1815
19- before ( async ( ) => {
20- alerts = getService ( 'uptime' ) . alerts ;
21- } ) ;
16+ describe ( 'overview page alert flyout controls' , function ( ) {
17+ const DEFAULT_DATE_START = 'Sep 10, 2019 @ 12:40:08.078' ;
18+ const DEFAULT_DATE_END = 'Sep 11, 2019 @ 19:40:08.078' ;
19+ let alerts : any ;
2220
23- it ( 'can open alert flyout' , async ( ) => {
24- await pageObjects . uptime . goToUptimeOverviewAndLoadData ( DEFAULT_DATE_START , DEFAULT_DATE_END ) ;
25- await alerts . openFlyout ( ) ;
26- } ) ;
21+ before ( async ( ) => {
22+ alerts = getService ( 'uptime' ) . alerts ;
23+ } ) ;
2724
28- it ( 'can set alert name' , async ( ) => {
29- await alerts . setAlertName ( 'uptime-test' ) ;
30- } ) ;
25+ it ( 'can open alert flyout' , async ( ) => {
26+ await pageObjects . uptime . goToUptimeOverviewAndLoadData (
27+ DEFAULT_DATE_START ,
28+ DEFAULT_DATE_END
29+ ) ;
30+ await alerts . openFlyout ( 'monitorStatus' ) ;
31+ } ) ;
3132
32- it ( 'can set alert tags ' , async ( ) => {
33- await alerts . setAlertTags ( [ 'uptime' , 'another' ] ) ;
34- } ) ;
33+ it ( 'can set alert name ' , async ( ) => {
34+ await alerts . setAlertName ( 'uptime-test' ) ;
35+ } ) ;
3536
36- it ( 'can set alert interval ' , async ( ) => {
37- await alerts . setAlertInterval ( '11' ) ;
38- } ) ;
37+ it ( 'can set alert tags ' , async ( ) => {
38+ await alerts . setAlertTags ( [ 'uptime' , 'another' ] ) ;
39+ } ) ;
3940
40- it ( 'can set alert throttle interval' , async ( ) => {
41- await alerts . setAlertThrottleInterval ( '30 ') ;
42- } ) ;
41+ it ( 'can set alert interval' , async ( ) => {
42+ await alerts . setAlertInterval ( '11 ') ;
43+ } ) ;
4344
44- it ( 'can set alert status number of time' , async ( ) => {
45- await alerts . setAlertStatusNumTimes ( '3' ) ;
46- } ) ;
47- it ( 'can set alert time range' , async ( ) => {
48- await alerts . setAlertTimerangeSelection ( '1' ) ;
49- } ) ;
50- it ( 'can set monitor hours' , async ( ) => {
51- await alerts . setMonitorStatusSelectableToHours ( ) ;
52- } ) ;
45+ it ( 'can set alert throttle interval' , async ( ) => {
46+ await alerts . setAlertThrottleInterval ( '30' ) ;
47+ } ) ;
5348
54- it ( 'can set kuery bar filters ' , async ( ) => {
55- await pageObjects . uptime . setAlertKueryBarText ( 'monitor.id: "0001-up" ') ;
56- } ) ;
49+ it ( 'can set alert status number of time ' , async ( ) => {
50+ await alerts . setAlertStatusNumTimes ( '3 ') ;
51+ } ) ;
5752
58- it ( 'can select location filter' , async ( ) => {
59- await alerts . clickAddFilterLocation ( ) ;
60- await alerts . clickLocationExpression ( 'mpls' ) ;
61- } ) ;
53+ it ( 'can set alert time range' , async ( ) => {
54+ await alerts . setAlertTimerangeSelection ( '1' ) ;
55+ } ) ;
6256
63- it ( 'can select port filter' , async ( ) => {
64- await alerts . clickAddFilterPort ( ) ;
65- await alerts . clickPortExpression ( '5678' ) ;
66- } ) ;
57+ it ( 'can set monitor hours' , async ( ) => {
58+ await alerts . setMonitorStatusSelectableToHours ( ) ;
59+ } ) ;
6760
68- it ( 'can select type/scheme filter' , async ( ) => {
69- await alerts . clickAddFilterType ( ) ;
70- await alerts . clickTypeExpression ( 'http' ) ;
71- } ) ;
61+ it ( 'can set kuery bar filters' , async ( ) => {
62+ await pageObjects . uptime . setAlertKueryBarText ( 'monitor.id: "0001-up"' ) ;
63+ } ) ;
64+
65+ it ( 'can select location filter' , async ( ) => {
66+ await alerts . clickAddFilterLocation ( ) ;
67+ await alerts . clickLocationExpression ( 'mpls' ) ;
68+ } ) ;
69+
70+ it ( 'can select port filter' , async ( ) => {
71+ await alerts . clickAddFilterPort ( ) ;
72+ await alerts . clickPortExpression ( '5678' ) ;
73+ } ) ;
74+
75+ it ( 'can select type/scheme filter' , async ( ) => {
76+ await alerts . clickAddFilterType ( ) ;
77+ await alerts . clickTypeExpression ( 'http' ) ;
78+ } ) ;
79+
80+ it ( 'can save alert' , async ( ) => {
81+ await alerts . clickSaveAlertButton ( ) ;
82+ } ) ;
7283
73- it ( 'can save alert' , async ( ) => {
74- await alerts . clickSaveAlertButton ( ) ;
84+ it ( 'posts an alert, verifies its presence, and deletes the alert' , async ( ) => {
85+ // The creation of the alert could take some time, so the first few times we query after
86+ // the previous line resolves, the API may not be done creating the alert yet, so we
87+ // put the fetch code in a retry block with a timeout.
88+ let alert : any ;
89+ await retry . tryForTime ( 15000 , async ( ) => {
90+ const apiResponse = await supertest . get ( '/api/alert/_find?search=uptime-test' ) ;
91+ const alertsFromThisTest = apiResponse . body . data . filter (
92+ ( { name } : { name : string } ) => name === 'uptime-test'
93+ ) ;
94+ expect ( alertsFromThisTest ) . to . have . length ( 1 ) ;
95+ alert = alertsFromThisTest [ 0 ] ;
96+ } ) ;
97+
98+ // Ensure the parameters and other stateful data
99+ // on the alert match up with the values we provided
100+ // for our test helper to input into the flyout.
101+ const {
102+ actions,
103+ alertTypeId,
104+ consumer,
105+ id,
106+ params : { numTimes, timerange, locations, filters } ,
107+ schedule : { interval } ,
108+ tags,
109+ } = alert ;
110+
111+ try {
112+ // we're not testing the flyout's ability to associate alerts with action connectors
113+ expect ( actions ) . to . eql ( [ ] ) ;
114+
115+ expect ( alertTypeId ) . to . eql ( 'xpack.uptime.alerts.monitorStatus' ) ;
116+ expect ( consumer ) . to . eql ( 'uptime' ) ;
117+ expect ( interval ) . to . eql ( '11m' ) ;
118+ expect ( tags ) . to . eql ( [ 'uptime' , 'another' ] ) ;
119+ expect ( numTimes ) . to . be ( 3 ) ;
120+ expect ( timerange . from ) . to . be ( 'now-1h' ) ;
121+ expect ( timerange . to ) . to . be ( 'now' ) ;
122+ expect ( locations ) . to . eql ( [ 'mpls' ] ) ;
123+ expect ( filters ) . to . eql (
124+ '{"bool":{"filter":[{"bool":{"should":[{"match_phrase":{"monitor.id":"0001-up"}}],' +
125+ '"minimum_should_match":1}},{"bool":{"filter":[{"bool":{"should":[{"match":{"observer.geo.name":"mpls"}}],' +
126+ '"minimum_should_match":1}},{"bool":{"filter":[{"bool":{"should":[{"match":{"url.port":5678}}],' +
127+ '"minimum_should_match":1}},{"bool":{"should":[{"match":{"monitor.type":"http"}}],"minimum_should_match":1}}]}}]}}]}}'
128+ ) ;
129+ } finally {
130+ await supertest
131+ . delete ( `/api/alert/${ id } ` )
132+ . set ( 'kbn-xsrf' , 'true' )
133+ . expect ( 204 ) ;
134+ }
135+ } ) ;
75136 } ) ;
76137
77- it ( 'posts an alert, verifies its presence, and deletes the alert' , async ( ) => {
78- // The creation of the alert could take some time, so the first few times we query after
79- // the previous line resolves, the API may not be done creating the alert yet, so we
80- // put the fetch code in a retry block with a timeout.
81- let alert : any ;
82- await retry . tryForTime ( 15000 , async ( ) => {
83- const apiResponse = await supertest . get ( '/api/alert/_find?search=uptime-test' ) ;
84- const alertsFromThisTest = apiResponse . body . data . filter (
85- ( { name } : { name : string } ) => name === 'uptime-test'
86- ) ;
87- expect ( alertsFromThisTest ) . to . have . length ( 1 ) ;
88- alert = alertsFromThisTest [ 0 ] ;
89- } ) ;
90-
91- // Ensure the parameters and other stateful data
92- // on the alert match up with the values we provided
93- // for our test helper to input into the flyout.
94- const {
95- actions,
96- alertTypeId,
97- consumer,
98- id,
99- params : { numTimes, timerange, locations, filters } ,
100- schedule : { interval } ,
101- tags,
102- } = alert ;
103-
104- try {
105- // we're not testing the flyout's ability to associate alerts with action connectors
106- expect ( actions ) . to . eql ( [ ] ) ;
107-
108- expect ( alertTypeId ) . to . eql ( 'xpack.uptime.alerts.monitorStatus' ) ;
109- expect ( consumer ) . to . eql ( 'uptime' ) ;
110- expect ( interval ) . to . eql ( '11m' ) ;
111- expect ( tags ) . to . eql ( [ 'uptime' , 'another' ] ) ;
112- expect ( numTimes ) . to . be ( 3 ) ;
113- expect ( timerange . from ) . to . be ( 'now-1h' ) ;
114- expect ( timerange . to ) . to . be ( 'now' ) ;
115- expect ( locations ) . to . eql ( [ 'mpls' ] ) ;
116- expect ( filters ) . to . eql (
117- '{"bool":{"filter":[{"bool":{"should":[{"match_phrase":{"monitor.id":"0001-up"}}],' +
118- '"minimum_should_match":1}},{"bool":{"filter":[{"bool":{"should":[{"match":{"observer.geo.name":"mpls"}}],' +
119- '"minimum_should_match":1}},{"bool":{"filter":[{"bool":{"should":[{"match":{"url.port":5678}}],' +
120- '"minimum_should_match":1}},{"bool":{"should":[{"match":{"monitor.type":"http"}}],"minimum_should_match":1}}]}}]}}]}}'
138+ describe ( 'tls alert' , function ( ) {
139+ const DEFAULT_DATE_START = 'Sep 10, 2019 @ 12:40:08.078' ;
140+ const DEFAULT_DATE_END = 'Sep 11, 2019 @ 19:40:08.078' ;
141+ let alerts : any ;
142+ const alertId = 'uptime-tls' ;
143+
144+ before ( async ( ) => {
145+ alerts = getService ( 'uptime' ) . alerts ;
146+ } ) ;
147+
148+ it ( 'can open alert flyout' , async ( ) => {
149+ await pageObjects . uptime . goToUptimeOverviewAndLoadData (
150+ DEFAULT_DATE_START ,
151+ DEFAULT_DATE_END
121152 ) ;
122- } finally {
123- await supertest
124- . delete ( `/api/alert/${ id } ` )
125- . set ( 'kbn-xsrf' , 'true' )
126- . expect ( 204 ) ;
127- }
153+ await alerts . openFlyout ( 'tls' ) ;
154+ } ) ;
155+
156+ it ( 'can set alert name' , async ( ) => {
157+ await alerts . setAlertName ( alertId ) ;
158+ } ) ;
159+
160+ it ( 'can set alert tags' , async ( ) => {
161+ await alerts . setAlertTags ( [ 'uptime' , 'certs' ] ) ;
162+ } ) ;
163+
164+ it ( 'can set alert interval' , async ( ) => {
165+ await alerts . setAlertInterval ( '11' ) ;
166+ } ) ;
167+
168+ it ( 'can set alert throttle interval' , async ( ) => {
169+ await alerts . setAlertThrottleInterval ( '30' ) ;
170+ } ) ;
171+
172+ it ( 'can save alert' , async ( ) => {
173+ await alerts . clickSaveAlertButton ( ) ;
174+ } ) ;
175+
176+ it ( 'has created a valid alert with expected parameters' , async ( ) => {
177+ let alert : any ;
178+ await retry . tryForTime ( 15000 , async ( ) => {
179+ const apiResponse = await supertest . get ( `/api/alert/_find?search=${ alertId } ` ) ;
180+ const alertsFromThisTest = apiResponse . body . data . filter (
181+ ( { name } : { name : string } ) => name === alertId
182+ ) ;
183+ expect ( alertsFromThisTest ) . to . have . length ( 1 ) ;
184+ alert = alertsFromThisTest [ 0 ] ;
185+ } ) ;
186+
187+ // Ensure the parameters and other stateful data
188+ // on the alert match up with the values we provided
189+ // for our test helper to input into the flyout.
190+ const {
191+ actions,
192+ alertTypeId,
193+ consumer,
194+ id,
195+ params,
196+ schedule : { interval } ,
197+ tags,
198+ } = alert ;
199+ try {
200+ expect ( actions ) . to . eql ( [ ] ) ;
201+ expect ( alertTypeId ) . to . eql ( 'xpack.uptime.alerts.tls' ) ;
202+ expect ( consumer ) . to . eql ( 'uptime' ) ;
203+ expect ( tags ) . to . eql ( [ 'uptime' , 'certs' ] ) ;
204+ expect ( params ) . to . eql ( { } ) ;
205+ expect ( interval ) . to . eql ( '11m' ) ;
206+ } finally {
207+ await supertest
208+ . delete ( `/api/alert/${ id } ` )
209+ . set ( 'kbn-xsrf' , 'true' )
210+ . expect ( 204 ) ;
211+ }
212+ } ) ;
128213 } ) ;
129214 } ) ;
130215} ;
0 commit comments