@@ -847,19 +847,23 @@ private void fireAlert() throws Exception {
847
847
848
848
TestUtils .checkPodReady ("domain1-admin-server" , "default" );
849
849
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 {
850
857
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 );
853
860
ExecResult result = ExecCommand .exec (cmd .toString ());
854
- String webhookPod = null ;
861
+ String podName = null ;
855
862
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 ();
862
864
}
865
+ assertNotNull (app + " was not created, can't find running pod " , podName );
866
+ return podName ;
863
867
}
864
868
865
869
private void changeConfigNegative (String effect , String configFile , String expectedErrorMsg )
@@ -973,18 +977,11 @@ private static void setupPVMYSQL() throws Exception {
973
977
crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/mysql/mysql.yaml" ;
974
978
TestUtils .exec (crdCmd );
975
979
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" );
985
982
TestUtils .checkPodReady (sqlPod , "default" );
986
983
Thread .sleep (15000 );
987
- result =
984
+ ExecResult result =
988
985
TestUtils .kubectlexecNoCheck (
989
986
sqlPod , "default" , " -- mysql -p123456 -e \" CREATE DATABASE domain1;\" " );
990
987
if (result .exitValue () != 0 ) {
@@ -1145,25 +1142,19 @@ private static void installPrometheusGrafanaViaChart() throws Exception {
1145
1142
* @throws Exception if could not run the command successfully to clone from github
1146
1143
*/
1147
1144
private static void installWebHookAndAlertManager () throws Exception {
1145
+
1146
+ logger .info ("building webhook image" );
1148
1147
String crdCmd = "cd " + monitoringExporterEndToEndDir + " && docker build ./webhook -t webhook-log:1.0" ;
1149
1148
TestUtils .exec (crdCmd );
1150
1149
1151
1150
// install webhook
1151
+ logger .info ("installing webhook " );
1152
1152
crdCmd = "kubectl create ns webhook " ;
1153
- TestUtils .exec (crdCmd );
1153
+ ExecCommand .exec (crdCmd );
1154
1154
1155
1155
crdCmd = "kubectl apply -f " + monitoringExporterEndToEndDir + "/webhook/server.yaml" ;
1156
1156
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" );
1167
1158
TestUtils .checkPodReady (webhookPod , "webhook" );
1168
1159
1169
1160
}
0 commit comments