107107import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .createIngressForDomainAndVerify ;
108108import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyNginx ;
109109import static oracle .weblogic .kubernetes .utils .MonitoringUtils .checkMetricsViaPrometheus ;
110+ import static oracle .weblogic .kubernetes .utils .MonitoringUtils .checkPrometheusAlert ;
110111import static oracle .weblogic .kubernetes .utils .MonitoringUtils .cleanupPromGrafanaClusterRoles ;
111112import static oracle .weblogic .kubernetes .utils .MonitoringUtils .createAndVerifyDomain ;
112113import static oracle .weblogic .kubernetes .utils .MonitoringUtils .createAndVerifyMiiImage ;
@@ -379,7 +380,7 @@ void testEndToEndViaChart() throws Exception {
379380 }
380381 }
381382
382- private void fireAlert () throws ApiException {
383+ private void fireAlert () throws Exception {
383384 // scale domain2
384385 logger .info ("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers." ,
385386 cluster1Name , domain2Uid , domain2Namespace , 1 );
@@ -388,6 +389,15 @@ private void fireAlert() throws ApiException {
388389 domain2Uid + "-" + MANAGED_SERVER_NAME_BASE , replicaCount , managedServersCount ,
389390 null , null );
390391
392+ logger .info ("Wait for the prometheus to create alert " );
393+ checkPrometheusAlert ("ClusterWarning" , hostPortPrometheus ,
394+ prometheusReleaseName
395+ + "." + monitoringNS );
396+
397+ logger .info ("Wait for the prometheus to fire alert " );
398+ checkPrometheusAlert ("firing" , hostPortPrometheus ,
399+ prometheusReleaseName
400+ + "." + monitoringNS );
391401 //check webhook log for firing alert
392402 List <V1Pod > pods = listPods (webhookNS , "app=webhook" ).getItems ();
393403 assertNotNull ((pods ), "No pods are running in namespace : " + webhookNS );
@@ -402,7 +412,7 @@ private void fireAlert() throws ApiException {
402412
403413 testUntil (withLongRetryPolicy ,
404414 assertDoesNotThrow (() -> searchPodLogForKey (pod ,
405- "Some WLS cluster has only one running server for more than 1 minutes " ),
415+ "Some WLS cluster has only one running server for more than 15 secs " ),
406416 "webhook failed to fire alert" ),
407417 logger ,
408418 "webhook to fire alert" );
@@ -554,7 +564,7 @@ public void tearDownAll() {
554564 deletePersistentVolumeClaim ("pvc-" + grafanaReleaseName , monitoringNS );
555565 deletePersistentVolume ("pv-test" + grafanaReleaseName );
556566 deleteNamespace (monitoringNS );
557- uninstallDeploymentService (webhookDepl , webhookService );
567+ // uninstallDeploymentService(webhookDepl, webhookService);
558568 uninstallDeploymentService (coordinatorDepl , coordinatorService );
559569 if (nginxHelmParams != null ) {
560570 assertThat (uninstallNginx (nginxHelmParams .getHelmParams ()))
0 commit comments