@@ -48,11 +48,12 @@ public class ItMonitoringExporter extends BaseTest {
48
48
private static Operator operator1 = null ;
49
49
private static Domain domain = null ;
50
50
private static String myhost = "" ;
51
+ private static String metricsUrl = "" ;
51
52
private static String monitoringExporterDir = "" ;
53
+ private static String monitoringExporterEndToEndDir = "" ;
52
54
private static String resourceExporterDir = "" ;
53
55
private static String exporterUrl = "" ;
54
56
private static String configPath = "" ;
55
- private static String metricsUrl = "" ;
56
57
private static String prometheusPort = "32000" ;
57
58
// "heap_free_current{name="managed-server1"}[15s]" search for results for last 15secs
58
59
private static String prometheusSearchKey1 =
@@ -93,7 +94,8 @@ public static void staticPrepare() throws Exception {
93
94
resourceExporterDir =
94
95
BaseTest .getProjectRoot () + "/integration-tests/src/test/resources/exporter" ;
95
96
configPath = resourceExporterDir ;
96
-
97
+ monitoringExporterEndToEndDir =
98
+ monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
97
99
upgradeTraefikHostName ();
98
100
deployRunMonitoringExporter (domain , operator );
99
101
buildDeployWebServiceApp (domain , TESTWSAPP , TESTWSSERVICE );
@@ -799,8 +801,6 @@ public void test18_ChangeConfigEmptyPass() throws Exception {
799
801
@ Test
800
802
public void test19_EndToEndViaChart () throws Exception {
801
803
Assume .assumeFalse (QUICKTEST );
802
- String monitoringExporterEndToEndDir =
803
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
804
804
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
805
805
logTestBegin (testMethodName );
806
806
boolean testCompletedSuccessfully = false ;
@@ -819,31 +819,7 @@ public void test19_EndToEndViaChart() throws Exception {
819
819
createWLSImageAndDeploy ();
820
820
installWebHookAndAlertManager ();
821
821
installPrometheusGrafanaViaChart ();
822
- //fire alert by changing replicas
823
- replaceStringInFile (
824
- monitoringExporterEndToEndDir + "/demo-domains/domain1.yaml" , "replicas: 2" , "replicas: 1" );
825
- // apply new domain yaml and verify pod restart
826
- String crdCmd =
827
- " kubectl apply -f " + monitoringExporterEndToEndDir + "/demo-domains/domain1.yaml" ;
828
- TestUtils .exec (crdCmd );
829
-
830
- TestUtils .checkPodReady ("domain1-admin-server" , "default" );
831
- TestUtils .checkPodReady ("domain1-managed-server-1" , "default" );
832
- StringBuffer cmd = new StringBuffer ();
833
- cmd .append ("kubectl get pod -l app=webhook -o jsonpath=\" {.items[0].metadata.name} \" " );
834
- logger .info ("webhook pod name cmd =" + cmd );
835
- ExecResult result = ExecCommand .exec (cmd .toString ());
836
- String webhookPod = null ;
837
- if (result .exitValue () == 0 ) {
838
- webhookPod = result .stdout ().trim ();
839
- }
840
- String command = "kubectl -n webhook logs -f " + webhookPod ;
841
- ExecResult webhookResult = ExecCommand .exec (command );
842
- if (webhookResult .exitValue () == 0 ) {
843
- assertTrue ( webhookResult .stdout ().contains ("Some WLS cluster has only one running server for more than 1 minutes" ));
844
- }
845
-
846
-
822
+ fireAlert ();
847
823
} finally {
848
824
uninstallWebHookPrometheusGrafanaViaChart ();
849
825
uninstallMySQL ();
@@ -860,6 +836,32 @@ public void test19_EndToEndViaChart() throws Exception {
860
836
logger .info ("SUCCESS - " + testMethodName );
861
837
}
862
838
839
+ private void fireAlert () throws Exception {
840
+ logger .info ("Fire Alert by changing replca count" );
841
+ replaceStringInFile (
842
+ monitoringExporterEndToEndDir + "/demo-domains/domain1.yaml" , "replicas: 2" , "replicas: 1" );
843
+ // apply new domain yaml and verify pod restart
844
+ String crdCmd =
845
+ " kubectl apply -f " + monitoringExporterEndToEndDir + "/demo-domains/domain1.yaml" ;
846
+ TestUtils .exec (crdCmd );
847
+
848
+ TestUtils .checkPodReady ("domain1-admin-server" , "default" );
849
+ TestUtils .checkPodReady ("domain1-managed-server-1" , "default" );
850
+ 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 );
853
+ ExecResult result = ExecCommand .exec (cmd .toString ());
854
+ String webhookPod = null ;
855
+ 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" ));
862
+ }
863
+ }
864
+
863
865
private void changeConfigNegative (String effect , String configFile , String expectedErrorMsg )
864
866
throws Exception {
865
867
final WebClient webClient = new WebClient ();
@@ -943,9 +945,6 @@ private HtmlPage submitConfigureForm(
943
945
* @throws Exception if could not run the command successfully to clone from github
944
946
*/
945
947
private static void setupPVMYSQL () throws Exception {
946
-
947
- String monitoringExporterEndToEndDir =
948
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
949
948
String pvDir = monitoringExporterEndToEndDir + "pvDir" ;
950
949
if (new File (pvDir ).exists ()) {
951
950
logger .info (" PV dir already exists , cleaning " );
@@ -1043,9 +1042,6 @@ private static void setupPVMYSQL() throws Exception {
1043
1042
* @throws Exception if could not run the command successfully to clone from github
1044
1043
*/
1045
1044
private static void createWLSImageAndDeploy () throws Exception {
1046
- // monitoringExporterDir = "/scratch/opc/wl_k8s_test_results/acceptance_test_tmp/monitoring/";
1047
- String monitoringExporterEndToEndDir =
1048
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
1049
1045
operator1 = TestUtils .createOperator (OPERATOR1_YAML );
1050
1046
1051
1047
String command =
@@ -1090,8 +1086,6 @@ private static void createWLSImageAndDeploy() throws Exception {
1090
1086
* @throws Exception if could not run the command successfully to clone from github
1091
1087
*/
1092
1088
private static void installPrometheusGrafanaViaChart () throws Exception {
1093
- String monitoringExporterEndToEndDir =
1094
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
1095
1089
// delete any running pods
1096
1090
deletePrometheusGrafana ();
1097
1091
prometheusPort = "30000" ;
@@ -1151,9 +1145,6 @@ private static void installPrometheusGrafanaViaChart() throws Exception {
1151
1145
* @throws Exception if could not run the command successfully to clone from github
1152
1146
*/
1153
1147
private static void installWebHookAndAlertManager () throws Exception {
1154
- String monitoringExporterEndToEndDir =
1155
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
1156
-
1157
1148
String crdCmd = "cd " + monitoringExporterEndToEndDir + " && docker build ./webhook -t webhook-log:1.0" ;
1158
1149
TestUtils .exec (crdCmd );
1159
1150
@@ -1183,8 +1174,6 @@ private static void installWebHookAndAlertManager() throws Exception {
1183
1174
* @throws Exception if could not run the command successfully to clone from github
1184
1175
*/
1185
1176
private static void uninstallWebHookPrometheusGrafanaViaChart () throws Exception {
1186
- String monitoringExporterEndToEndDir =
1187
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
1188
1177
logger .info ("Uninstalling webhook" );
1189
1178
String crdCmd = "kubectl delete -f " + monitoringExporterEndToEndDir + "/webhook/server.yaml" ;
1190
1179
ExecCommand .exec (crdCmd );
@@ -1214,10 +1203,6 @@ private static void uninstallWebHookPrometheusGrafanaViaChart() throws Exception
1214
1203
crdCmd = "kubectl delete -f " + monitoringExporterEndToEndDir + "/prometheus/alert-persistence.yaml" ;
1215
1204
ExecCommand .exec (crdCmd );
1216
1205
Thread .sleep (15000 );
1217
-
1218
- //logger.info("Uninstalling namespace monitoring ");
1219
- crdCmd = "kubectl delete namespace monitoring" ;
1220
- //TestUtils.exec(crdCmd);
1221
1206
}
1222
1207
1223
1208
/**
@@ -1245,8 +1230,6 @@ private static void uninstallMySQL() throws Exception {
1245
1230
* @throws Exception if could not run the command successfully to clone from github
1246
1231
*/
1247
1232
private static void deletePvDir () throws Exception {
1248
- String monitoringExporterEndToEndDir =
1249
- monitoringExporterDir + "/src/samples/kubernetes/end2end/" ;
1250
1233
String pvDir = monitoringExporterEndToEndDir + "pvDir" ;
1251
1234
String crdCmd =
1252
1235
"cd "
0 commit comments