Skip to content

Commit 1941790

Browse files
committed
added alert manager using alert branch temp5
1 parent 60d24b0 commit 1941790

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ItMonitoringExporter.java

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ public static void staticUnPrepare() throws Exception {
119119
if (operator != null) {
120120
operator.destroy();
121121
}
122-
// deletePrometheusGrafana();
123122
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
124123
logger.info("SUCCESS");
125124
}
@@ -396,7 +395,7 @@ private static void upgradeTraefikHostName() throws Exception {
396395
/**
397396
* Check that configuration can be reviewed via Prometheus.
398397
*
399-
* @throws Exception exception
398+
* @throws Exception if test fails
400399
*/
401400
@Test
402401
public void test01_CheckMetricsViaPrometheus() throws Exception {
@@ -412,7 +411,7 @@ public void test01_CheckMetricsViaPrometheus() throws Exception {
412411
/**
413412
* Replace monitoring exporter configuration and verify it was applied to both managed servers.
414413
*
415-
* @throws Exception exception
414+
* @throws Exception if test fails
416415
*/
417416
@Test
418417
public void test02_ReplaceConfiguration() throws Exception {
@@ -459,7 +458,7 @@ public void test02_ReplaceConfiguration() throws Exception {
459458
/**
460459
* Add additional monitoring exporter configuration and verify it was applied.
461460
*
462-
* @throws Exception exception
461+
* @throws Exception if test fails
463462
*/
464463
@Test
465464
public void test03_AppendConfiguration() throws Exception {
@@ -492,7 +491,7 @@ public void test03_AppendConfiguration() throws Exception {
492491
/**
493492
* Replace monitoring exporter configuration with only one attribute and verify it was applied.
494493
*
495-
* @throws Exception exception
494+
* @throws Exception if test fails
496495
*/
497496
@Test
498497
public void test04_ReplaceOneAttributeValueAsArrayConfiguration() throws Exception {
@@ -513,7 +512,7 @@ public void test04_ReplaceOneAttributeValueAsArrayConfiguration() throws Excepti
513512
* Append monitoring exporter configuration with one more attribute and verify it was applied
514513
* append to [a] new config [a,b].
515514
*
516-
* @throws Exception exception
515+
* @throws Exception if test fails
517516
*/
518517
@Test
519518
public void test05_AppendArrayWithOneExistedAndOneDifferentAttributeValueAsArrayConfiguration()
@@ -533,7 +532,7 @@ public void test05_AppendArrayWithOneExistedAndOneDifferentAttributeValueAsArray
533532
/**
534533
* Replace monitoring exporter configuration with empty configuration.
535534
*
536-
* @throws Exception exception
535+
* @throws Exception if test fails
537536
*/
538537
@Test
539538
public void test06_ReplaceWithEmptyConfiguration() throws Exception {
@@ -568,7 +567,7 @@ public void test07_AppendWithEmptyConfiguration() throws Exception {
568567
/**
569568
* Try to append monitoring exporter configuration with configuration file not in the yaml format.
570569
*
571-
* @throws Exception exception
570+
* @throws Exception if test fails
572571
*/
573572
@Test
574573
public void test08_1AppendWithNotYmlConfiguration() throws Exception {
@@ -601,7 +600,7 @@ public void test08_2ReplaceWithNotYmlConfiguration() throws Exception {
601600
* Try to append monitoring exporter configuration with configuration file in the corrupted yaml
602601
* format.
603602
*
604-
* @throws Exception exception
603+
* @throws Exception if test fails
605604
*/
606605
public void test09_AppendWithCorruptedYmlConfiguration() throws Exception {
607606
Assume.assumeFalse(QUICKTEST);
@@ -637,7 +636,7 @@ public void test10_ReplaceWithCorruptedYmlConfiguration() throws Exception {
637636
* Try to replace monitoring exporter configuration with configuration file with dublicated
638637
* values.
639638
*
640-
* @throws Exception exception
639+
* @throws Exception if test fails
641640
*/
642641
@Test
643642
public void test11_ReplaceWithDublicatedValuesConfiguration() throws Exception {
@@ -655,7 +654,7 @@ public void test11_ReplaceWithDublicatedValuesConfiguration() throws Exception {
655654
/**
656655
* Try to append monitoring exporter configuration with configuration file with duplicated values.
657656
*
658-
* @throws Exception exception
657+
* @throws Exception if test fails
659658
*/
660659
@Test
661660
public void test12_AppendWithDuplicatedValuesConfiguration() throws Exception {
@@ -758,7 +757,7 @@ public void test16_ChangeConfigInvalidPass() throws Exception {
758757
/**
759758
* Try to change monitoring exporter configuration with empty username.
760759
*
761-
* @throws Exception excpetion
760+
* @throws Exception if test fails
762761
*/
763762
@Test
764763
public void test17_ChangeConfigEmptyUser() throws Exception {
@@ -777,7 +776,7 @@ public void test17_ChangeConfigEmptyUser() throws Exception {
777776
/**
778777
* Try to change monitoring exporter configuration with empty pass.
779778
*
780-
* @throws Exception exception
779+
* @throws Exception if test fails
781780
*/
782781
@Test
783782
public void test18_ChangeConfigEmptyPass() throws Exception {
@@ -796,7 +795,7 @@ public void test18_ChangeConfigEmptyPass() throws Exception {
796795
/**
797796
* Test End to End example from MonitoringExporter github project
798797
*
799-
* @throws Exception
798+
* @throws Exception if test fails
800799
*/
801800
@Test
802801
public void test19_EndToEndViaChart() throws Exception {
@@ -821,8 +820,10 @@ public void test19_EndToEndViaChart() throws Exception {
821820
installPrometheusGrafanaViaChart();
822821
fireAlert();
823822
} finally {
823+
/*
824824
uninstallWebHookPrometheusGrafanaViaChart();
825825
uninstallMySQL();
826+
826827
String crdCmd =
827828
" kubectl delete -f " + monitoringExporterEndToEndDir + "/demo-domains/domain1.yaml";
828829
ExecCommand.exec(crdCmd);
@@ -831,6 +832,8 @@ public void test19_EndToEndViaChart() throws Exception {
831832
if (operator1 != null) {
832833
operator1.destroy();
833834
}
835+
*/
836+
834837
}
835838
testCompletedSuccessfully = true;
836839
logger.info("SUCCESS - " + testMethodName);
@@ -847,9 +850,12 @@ private void fireAlert() throws Exception {
847850

848851
TestUtils.checkPodReady("domain1-admin-server", "default");
849852
TestUtils.checkPodReady("domain1-managed-server-1", "default");
853+
//sleep for 1 min to fire alert
854+
Thread.sleep(60000);
850855
String webhookPod = getPodName("webhook", "webhook");
851856
String command = "kubectl -n webhook logs " + webhookPod;
852857
ExecResult webhookResult = TestUtils.exec(command);
858+
logger.info(" webhook log " + webhookResult.stdout());
853859
assertTrue( webhookResult.stdout().contains("Some WLS cluster has only one running server for more than 1 minutes"));
854860
}
855861

@@ -946,7 +952,7 @@ private HtmlPage submitConfigureForm(
946952
* Remove monitoring exporter directory if exists and clone latest from github for monitoring
947953
* exporter code
948954
*
949-
* @throws Exception if could not run the command successfully to clone from github
955+
* @throws Exception if could not run the command successfully to install database
950956
*/
951957
private static void setupPVMYSQL() throws Exception {
952958
String pvDir = monitoringExporterEndToEndDir + "pvDir";
@@ -1036,7 +1042,7 @@ private static void setupPVMYSQL() throws Exception {
10361042
/**
10371043
* Install wls image tool and update wls pods
10381044
*
1039-
* @throws Exception if could not run the command successfully to clone from github
1045+
* @throws Exception if could not run the command successfully to create WLSImage and deploy
10401046
*/
10411047
private static void createWLSImageAndDeploy() throws Exception {
10421048
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
@@ -1080,7 +1086,7 @@ private static void createWLSImageAndDeploy() throws Exception {
10801086
/**
10811087
* Install Prometheus and Grafana using helm chart
10821088
*
1083-
* @throws Exception if could not run the command successfully to clone from github
1089+
* @throws Exception if could not run the command successfully to install Prometheus and Grafana
10841090
*/
10851091
private static void installPrometheusGrafanaViaChart() throws Exception {
10861092
// delete any running pods
@@ -1139,7 +1145,7 @@ private static void installPrometheusGrafanaViaChart() throws Exception {
11391145
/**
11401146
* Install Prometheus and Grafana using helm chart
11411147
*
1142-
* @throws Exception if could not run the command successfully to clone from github
1148+
* @throws Exception if could not run the command successfully to install webhook and alert manager
11431149
*/
11441150
private static void installWebHookAndAlertManager() throws Exception {
11451151

@@ -1162,7 +1168,7 @@ private static void installWebHookAndAlertManager() throws Exception {
11621168
/**
11631169
* Uninstall Prometheus and Grafana using helm chart
11641170
*
1165-
* @throws Exception if could not run the command successfully to clone from github
1171+
* @throws Exception if could not run the command successfully to uninstall deployments
11661172
*/
11671173
private static void uninstallWebHookPrometheusGrafanaViaChart() throws Exception {
11681174
logger.info("Uninstalling webhook");
@@ -1199,7 +1205,7 @@ private static void uninstallWebHookPrometheusGrafanaViaChart() throws Exception
11991205
/**
12001206
* Unnstall MYSQL
12011207
*
1202-
* @throws Exception if could not run the command successfully to clone from github
1208+
* @throws Exception if could not run the command successfully to uninstall MySQL
12031209
*/
12041210
private static void uninstallMySQL() throws Exception {
12051211
String monitoringExporterEndToEndDir =
@@ -1218,7 +1224,7 @@ private static void uninstallMySQL() throws Exception {
12181224
/**
12191225
* Delete PvDir via docker
12201226
*
1221-
* @throws Exception if could not run the command successfully to clone from github
1227+
* @throws Exception if could not run the command successfully to delete PV
12221228
*/
12231229
private static void deletePvDir() throws Exception {
12241230
String pvDir = monitoringExporterEndToEndDir + "pvDir";
@@ -1276,7 +1282,7 @@ private static void createCrossNSRBACFile(String domainNS, String operatorNS) th
12761282
* call operator to scale to specified number of replicas
12771283
*
12781284
* @param replicas - number of managed servers
1279-
* @throws Exception exception
1285+
* @throws Exception if scaling fails
12801286
*/
12811287
private void scaleCluster(int replicas) throws Exception {
12821288
logger.info("Scale up/down to " + replicas + " managed servers");
@@ -1288,7 +1294,7 @@ private void scaleCluster(int replicas) throws Exception {
12881294
*
12891295
* @param searchKey - metric query expression
12901296
* @param expectedVal - expected metrics to search
1291-
* @throws Exception exception
1297+
* @throws Exception if command to check metrics fails
12921298
*/
12931299
private static boolean checkMetricsViaPrometheus(String searchKey, String expectedVal)
12941300
throws Exception {

0 commit comments

Comments
 (0)