@@ -6,25 +6,16 @@ import { nav } from '../../views/nav';
66import { silenceDetailsPage } from '../../views/silence-details-page' ;
77import { silencesListPage } from '../../views/silences-list-page' ;
88import { getValFromElement } from '../../views/utils' ;
9-
109import { overviewPage } from '../../views/overview-page' ;
1110import common = require( 'mocha/lib/interfaces/common' ) ;
11+ import { AlertsAlertState , SilenceComment , SilenceState , WatchdogAlert } from '../../fixtures/monitoring/constants' ;
12+ import { alerts } from '../../fixtures/monitoring/alert' ;
1213// Set constants for the operators that need to be installed for tests.
1314const MP = {
1415 namespace : 'openshift-monitoring' ,
1516 operatorName : 'Cluster Monitoring Operator' ,
1617} ;
1718
18- const ALERTNAME = 'Watchdog' ;
19- const NAMESPACE = 'openshift-monitoring' ;
20- const SEVERITY = 'None' ;
21- const ALERT_DESC = 'This is an alert meant to ensure that the entire alerting pipeline is functional. This alert is always firing, therefore it should always be firing in Alertmanager and always fire against a receiver. There are integrations with various notification mechanisms that send a notification when this alert is not firing. For example the "DeadMansSnitch" integration in PagerDuty.'
22- const ALERT_SUMMARY = 'An alert that should always be firing to certify that Alertmanager is working properly.'
23-
24- const SILENCE_COMMENT = 'test comment' ;
25-
26-
27-
2819describe ( 'BVT: Monitoring' , ( ) => {
2920
3021 before ( ( ) => {
@@ -101,38 +92,39 @@ describe('BVT: Monitoring', () => {
10192 listPage . ARRows . shouldBeLoaded ( ) ;
10293
10394 cy . log ( '5.2. filter Alerts and click on Alert' ) ;
104- listPage . filter . byName ( `${ ALERTNAME } ` ) ;
95+ listPage . filter . byName ( `${ WatchdogAlert . ALERTNAME } ` ) ;
10596 listPage . ARRows . countShouldBe ( 1 ) ;
106- listPage . ARRows . ARShouldBe ( `${ ALERTNAME } ` , `${ SEVERITY } ` , 1 , 'Firing' ) ;
97+ listPage . ARRows . ARShouldBe ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` , 1 , 'Firing' ) ;
10798 listPage . ARRows . expandRow ( ) ;
108- listPage . ARRows . AShouldBe ( `${ ALERTNAME } ` , `${ SEVERITY } ` , `${ NAMESPACE } ` ) ;
99+ listPage . ARRows . AShouldBe ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` , `${ WatchdogAlert . NAMESPACE } ` ) ;
109100 listPage . ARRows . clickAlert ( ) ;
110101
111102 cy . log ( '5.3. click on Alert Details Page' ) ;
112- commonPages . titleShouldHaveText ( `${ ALERTNAME } ` ) ;
113- commonPages . detailsPage . common ( `${ ALERTNAME } ` , `${ SEVERITY } ` ) ;
114- commonPages . detailsPage . alert ( `${ ALERTNAME } ` ) ;
103+ commonPages . titleShouldHaveText ( `${ WatchdogAlert . ALERTNAME } ` ) ;
104+ commonPages . detailsPage . common ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` ) ;
105+ commonPages . detailsPage . alert ( `${ WatchdogAlert . ALERTNAME } ` ) ;
115106
116107 const timeIntervalValue = getValFromElement ( `[data-ouia-component-id^="OUIA-Generated-TextInputBase"]` ) ;
117108 timeIntervalValue . then ( ( value ) => {
118109 expect ( value ) . to . not . be . empty ;
119110 } ) ;
120111
121112 cy . log ( '5.4. click on Alert Rule link' ) ;
122- detailsPage . clickAlertRule ( `${ ALERTNAME } ` ) ;
123- commonPages . titleShouldHaveText ( `${ ALERTNAME } ` ) ;
113+ detailsPage . clickAlertRule ( `${ WatchdogAlert . ALERTNAME } ` ) ;
114+ commonPages . titleShouldHaveText ( `${ WatchdogAlert . ALERTNAME } ` ) ;
124115 commonPages . detailsPage . alertRule ;
125- commonPages . detailsPage . common ( `${ ALERTNAME } ` , `${ SEVERITY } ` ) ;
116+ commonPages . detailsPage . common ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` ) ;
126117 cy . get ( `[class="pf-v6-c-code-block__content"]` ) . invoke ( 'text' ) . then ( ( expText ) => {
127118 cy . log ( `${ expText } ` ) ;
128119 cy . wrap ( expText ) . as ( 'alertExpression' ) ;
129- } ) ;
120+ } ) ;
121+
130122
131123 cy . log ( '5.5. click on Alert Details Page' ) ;
132- detailsPage . clickAlertDesc ( `${ ALERT_DESC } ` ) ;
133- commonPages . titleShouldHaveText ( `${ ALERTNAME } ` ) ;
134- commonPages . detailsPage . common ( `${ ALERTNAME } ` , `${ SEVERITY } ` ) ;
135- commonPages . detailsPage . alert ( `${ ALERTNAME } ` ) ;
124+ detailsPage . clickAlertDesc ( `${ WatchdogAlert . ALERT_DESC } ` ) ;
125+ commonPages . titleShouldHaveText ( `${ WatchdogAlert . ALERTNAME } ` ) ;
126+ commonPages . detailsPage . common ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` ) ;
127+ commonPages . detailsPage . alert ( `${ WatchdogAlert . ALERTNAME } ` ) ;
136128
137129 cy . log ( '5.6. click on Inspect on Alert Details Page' ) ;
138130 detailsPage . clickInspectAlertPage ( ) ;
@@ -152,63 +144,12 @@ describe('BVT: Monitoring', () => {
152144 cy . visit ( '/' ) ;
153145 cy . log ( '6.1 use sidebar nav to go to Observe > Alerting' ) ;
154146 nav . sidenav . clickNavLink ( [ 'Observe' , 'Alerting' ] ) ;
155-
156- cy . intercept ( 'GET' , '/api/prometheus/api/v1/rules?' , {
157- data : {
158- groups : [
159- {
160- file : 'dummy-file' ,
161- interval : 30 ,
162- name : 'general.rules' ,
163- rules : [
164- {
165- state : 'firing' ,
166- name : `${ ALERTNAME } ` ,
167- query : 'vector(1)' ,
168- duration : 0 ,
169- labels : {
170- // namespace: `${NAMESPACE}`,
171- prometheus : 'openshift-monitoring/k8s' ,
172- severity : `${ SEVERITY } ` ,
173- } ,
174- annotations : {
175- description :
176- `${ ALERT_DESC } ` ,
177- summary :
178- `${ ALERT_SUMMARY } ` ,
179- } ,
180- alerts : [
181- {
182- labels : {
183- alertname : `${ ALERTNAME } ` ,
184- namespace : `${ NAMESPACE } ` ,
185- severity : `${ SEVERITY } ` ,
186- } ,
187- annotations : {
188- description :
189- `${ ALERT_DESC } ` ,
190- summary :
191- `${ ALERT_SUMMARY } ` ,
192- } ,
193- state : 'firing' ,
194- activeAt : '2023-04-10T12:00:00.123456789Z' ,
195- value : '1e+00' ,
196- 'partialResponseStrategy' : 'WARN' ,
197- } ,
198- ] ,
199- health : 'ok' ,
200- type : 'alerting' ,
201- } ,
202- ] ,
203- } ,
204- ] ,
205- } ,
206- } ) ;
147+ alerts . getWatchdogAlert ( ) ;
207148
208149 cy . log ( '6.3 filter to Watchdog alert' ) ;
209150 nav . tabs . switchTab ( 'Alerts' ) ;
210151 listPage . ARRows . shouldBeLoaded ( ) ;
211- listPage . filter . byName ( `${ ALERTNAME } ` ) ;
152+ listPage . filter . byName ( `${ WatchdogAlert . ALERTNAME } ` ) ;
212153 listPage . ARRows . countShouldBe ( 1 ) ;
213154
214155 cy . log ( '6.4 silence alert' ) ;
@@ -222,9 +163,9 @@ describe('BVT: Monitoring', () => {
222163 silenceAlertPage . silenceAlertSectionDefault ( ) ;
223164 silenceAlertPage . durationSectionDefault ( ) ;
224165 silenceAlertPage . alertLabelsSectionDefault ( ) ;
225- silenceAlertPage . assertLabelNameLabelValueRegExNegMatcher ( 'alertname' , `${ ALERTNAME } ` , false , false ) ;
166+ silenceAlertPage . assertLabelNameLabelValueRegExNegMatcher ( 'alertname' , `${ WatchdogAlert . ALERTNAME } ` , false , false ) ;
226167 // silenceAlertPage.assertLabelNameLabelValueRegExNegMatcher('severity', `${SEVERITY}`, false, false);
227- silenceAlertPage . assertLabelNameLabelValueRegExNegMatcher ( 'namespace' , `${ NAMESPACE } ` , false , false ) ;
168+ silenceAlertPage . assertLabelNameLabelValueRegExNegMatcher ( 'namespace' , `${ WatchdogAlert . NAMESPACE } ` , false , false ) ;
228169 silenceAlertPage . assertLabelNameLabelValueRegExNegMatcher ( 'prometheus' , 'openshift-monitoring/k8s' , false , false ) ;
229170
230171 // Change duration
@@ -239,42 +180,42 @@ describe('BVT: Monitoring', () => {
239180 // Change duration back again
240181 silenceAlertPage . setForAndStartImmediately ( '2h' , true ) ;
241182 // Add comment and submit
242- silenceAlertPage . addComment ( SILENCE_COMMENT ) ;
183+ silenceAlertPage . addComment ( SilenceComment . SILENCE_COMMENT ) ;
243184 silenceAlertPage . clickSubmit ( ) ;
244185
245186 // After creating the Silence, should be redirected to its details page
246187 cy . log ( '6.6 Assert Silence details page' ) ;
247- silenceDetailsPage . assertSilenceDetailsPage ( `${ ALERTNAME } ` , 'Silence details' , 'alertname=Watchdog' ) ;
188+ silenceDetailsPage . assertSilenceDetailsPage ( `${ WatchdogAlert . ALERTNAME } ` , 'Silence details' , 'alertname=Watchdog' ) ;
248189
249190 cy . log ( '6.7 Click on Firing alerts' ) ;
250- silenceDetailsPage . clickOnFiringAlerts ( `${ ALERTNAME } ` ) ;
251- commonPages . titleShouldHaveText ( `${ ALERTNAME } ` ) ;
191+ silenceDetailsPage . clickOnFiringAlerts ( `${ WatchdogAlert . ALERTNAME } ` ) ;
192+ commonPages . titleShouldHaveText ( `${ WatchdogAlert . ALERTNAME } ` ) ;
252193 detailsPage . sectionHeaderShouldExist ( 'Alert details' ) ;
253194 detailsPage . labelShouldExist ( 'alertname=Watchdog' ) ;
254195
255196 cy . log ( '6.8 Click on Silenced by' ) ;
256- detailsPage . clickOnSilencedBy ( `${ ALERTNAME } ` ) ;
257- commonPages . titleShouldHaveText ( `${ ALERTNAME } ` ) ;
197+ detailsPage . clickOnSilencedBy ( `${ WatchdogAlert . ALERTNAME } ` ) ;
198+ commonPages . titleShouldHaveText ( `${ WatchdogAlert . ALERTNAME } ` ) ;
258199 detailsPage . sectionHeaderShouldExist ( 'Silence details' ) ;
259200 detailsPage . labelShouldExist ( 'alertname=Watchdog' ) ;
260201
261202 cy . log ( '6.9 shows the silenced Alert in the Silenced Alerts list' ) ;
262203 nav . sidenav . clickNavLink ( [ 'Observe' , 'Alerting' ] ) ;
263204 nav . tabs . switchTab ( 'Silences' ) ;
264205 silencesListPage . shouldBeLoaded ( ) ;
265- listPage . filter . removeIndividualTag ( 'Active' ) ;
266- listPage . filter . removeIndividualTag ( 'Pending' ) ;
267- silencesListPage . filter . byName ( `${ ALERTNAME } ` ) ;
206+ listPage . filter . removeIndividualTag ( SilenceState . ACTIVE ) ;
207+ listPage . filter . removeIndividualTag ( SilenceState . PENDING ) ;
208+ silencesListPage . filter . byName ( `${ WatchdogAlert . ALERTNAME } ` ) ;
268209 listPage . filter . clickFilter ( true , false ) ;
269- listPage . filter . selectFilterOption ( false , 'Active' , true ) ;
270- silencesListPage . rows . shouldBe ( `${ ALERTNAME } ` , 'Active' ) ;
210+ listPage . filter . selectFilterOption ( false , SilenceState . ACTIVE , true ) ;
211+ silencesListPage . rows . shouldBe ( `${ WatchdogAlert . ALERTNAME } ` , SilenceState . ACTIVE ) ;
271212
272213 cy . log ( '6.10 verify on Alerts list page again' ) ;
273214 nav . sidenav . clickNavLink ( [ 'Observe' , 'Alerting' ] ) ;
274215 listPage . filter . clearAllFilters ( ) ;
275- listPage . filter . selectFilterOption ( true , 'Silenced' , true ) ;
276- listPage . filter . byName ( `${ ALERTNAME } ` ) ;
277- listPage . ARRows . ARShouldBe ( `${ ALERTNAME } ` , `${ SEVERITY } ` , 1 , 'Silenced' ) ;
216+ listPage . filter . selectFilterOption ( true , AlertsAlertState . SILENCED , true ) ;
217+ listPage . filter . byName ( `${ WatchdogAlert . ALERTNAME } ` ) ;
218+ listPage . ARRows . ARShouldBe ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` , 1 , AlertsAlertState . SILENCED ) ;
278219
279220 cy . log ( '6.11 expires the Silence' ) ;
280221 listPage . ARRows . expandRow ( ) ;
@@ -284,8 +225,8 @@ describe('BVT: Monitoring', () => {
284225 cy . log ( '6.12 verify on Alerts list page again' ) ;
285226 nav . sidenav . clickNavLink ( [ 'Observe' , 'Alerting' ] ) ;
286227 listPage . filter . clearAllFilters ( ) ;
287- listPage . filter . byName ( `${ ALERTNAME } ` ) ;
288- listPage . ARRows . ARShouldBe ( `${ ALERTNAME } ` , `${ SEVERITY } ` , 1 , 'Firing' ) ;
228+ listPage . filter . byName ( `${ WatchdogAlert . ALERTNAME } ` ) ;
229+ listPage . ARRows . ARShouldBe ( `${ WatchdogAlert . ALERTNAME } ` , `${ WatchdogAlert . SEVERITY } ` , 1 , AlertsAlertState . FIRING ) ;
289230
290231 } ) ;
291232} ) ;
0 commit comments