Skip to content

Commit 60d24b0

Browse files
committed
added alert manager using alert branch temp4
1 parent bbffd98 commit 60d24b0

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

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

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -847,19 +847,23 @@ private void fireAlert() throws Exception {
847847

848848
TestUtils.checkPodReady("domain1-admin-server", "default");
849849
TestUtils.checkPodReady("domain1-managed-server-1", "default");
850+
String webhookPod = getPodName("webhook", "webhook");
851+
String command = "kubectl -n webhook logs " + webhookPod;
852+
ExecResult webhookResult = TestUtils.exec(command);
853+
assertTrue( webhookResult.stdout().contains("Some WLS cluster has only one running server for more than 1 minutes"));
854+
}
855+
856+
private static String getPodName(String app, String namespace) throws Exception {
850857
StringBuffer cmd = new StringBuffer();
851-
cmd.append("kubectl get pod -l app=webhook -o jsonpath=\"{.items[0].metadata.name} \"");
852-
logger.info("webhook pod name cmd =" + cmd);
858+
cmd.append("kubectl get pod -l app=" + app + " -n " + namespace + " -o jsonpath=\"{.items[0].metadata.name}\"");
859+
logger.info(" pod name cmd =" + cmd);
853860
ExecResult result = ExecCommand.exec(cmd.toString());
854-
String webhookPod = null;
861+
String podName = null;
855862
if (result.exitValue() == 0) {
856-
webhookPod = result.stdout().trim();
857-
}
858-
String command = "kubectl -n webhook logs -f " + webhookPod;
859-
ExecResult webhookResult = ExecCommand.exec(command);
860-
if (webhookResult.exitValue() == 0) {
861-
assertTrue( webhookResult.stdout().contains("Some WLS cluster has only one running server for more than 1 minutes"));
863+
podName = result.stdout().trim();
862864
}
865+
assertNotNull(app + " was not created, can't find running pod ", podName);
866+
return podName;
863867
}
864868

865869
private void changeConfigNegative(String effect, String configFile, String expectedErrorMsg)
@@ -973,18 +977,11 @@ private static void setupPVMYSQL() throws Exception {
973977
crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/mysql/mysql.yaml";
974978
TestUtils.exec(crdCmd);
975979

976-
StringBuffer cmd = new StringBuffer();
977-
cmd.append("kubectl get pod -l app=mysql -o jsonpath=\"{.items[0].metadata.name} \"");
978-
logger.fine("getSQL pod name cmd =" + cmd);
979-
ExecResult result = ExecCommand.exec(cmd.toString());
980-
String sqlPod = null;
981-
if (result.exitValue() == 0) {
982-
sqlPod = result.stdout().trim();
983-
}
984-
assertNotNull("DataBase was not created, can't find running pod", sqlPod);
980+
logger.fine("getSQL pod name ");
981+
String sqlPod = getPodName("mysql", "default");
985982
TestUtils.checkPodReady(sqlPod, "default");
986983
Thread.sleep(15000);
987-
result =
984+
ExecResult result =
988985
TestUtils.kubectlexecNoCheck(
989986
sqlPod, "default", " -- mysql -p123456 -e \"CREATE DATABASE domain1;\"");
990987
if (result.exitValue() != 0) {
@@ -1145,25 +1142,19 @@ private static void installPrometheusGrafanaViaChart() throws Exception {
11451142
* @throws Exception if could not run the command successfully to clone from github
11461143
*/
11471144
private static void installWebHookAndAlertManager() throws Exception {
1145+
1146+
logger.info("building webhook image");
11481147
String crdCmd = "cd " + monitoringExporterEndToEndDir + " && docker build ./webhook -t webhook-log:1.0";
11491148
TestUtils.exec(crdCmd);
11501149

11511150
// install webhook
1151+
logger.info("installing webhook ");
11521152
crdCmd = "kubectl create ns webhook ";
1153-
TestUtils.exec(crdCmd);
1153+
ExecCommand.exec(crdCmd);
11541154

11551155
crdCmd = "kubectl apply -f " + monitoringExporterEndToEndDir + "/webhook/server.yaml";
11561156
TestUtils.exec(crdCmd);
1157-
1158-
StringBuffer cmd = new StringBuffer();
1159-
cmd.append("kubectl get pod -n webhook -l app=webhook -o jsonpath=\"{.items[0].metadata.name} \"");
1160-
logger.info("webhook pod name cmd =" + cmd);
1161-
ExecResult result = ExecCommand.exec(cmd.toString());
1162-
String webhookPod = null;
1163-
if (result.exitValue() == 0) {
1164-
webhookPod = result.stdout().trim();
1165-
}
1166-
assertNotNull("Webhook was not created, can't find running pod", webhookPod);
1157+
String webhookPod = getPodName("webhook", "webhook");
11671158
TestUtils.checkPodReady(webhookPod, "webhook");
11681159

11691160
}

0 commit comments

Comments
 (0)