@@ -197,8 +197,13 @@ public void test03_AppendConfiguration() throws Exception {
197197 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
198198 logTestBegin (testMethodName );
199199 boolean testCompletedSuccessfully = false ;
200+ // scale cluster to 1 managed server only to test functionality of the exporter without
201+ // coordinator layer
202+ scaleCluster (1 );
203+
200204 // make sure some config is there
201205 HtmlPage page = submitConfigureForm (exporterUrl , "replace" , configPath + "/rest_jvm.yml" );
206+
202207 assertTrue (page .asText ().contains ("JVMRuntime" ));
203208 assertFalse (page .asText ().contains ("WebAppComponentRuntime" ));
204209 // run append
@@ -228,6 +233,8 @@ public void test04_ReplaceOneAttributeValueAsArrayConfiguration() throws Excepti
228233 logTestBegin (testMethodName );
229234 boolean testCompletedSuccessfully = false ;
230235
236+ resetMonitoringExporterToPreBuiltConfig ();
237+
231238 HtmlPage page =
232239 submitConfigureForm (exporterUrl , "replace" , configPath + "/rest_oneattribval.yml" );
233240 assertTrue (page .asText ().contains ("values: invocationTotalCount" ));
@@ -249,6 +256,7 @@ public void test05_AppendArrayWithOneExistedAndOneDifferentAttributeValueAsArray
249256 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
250257 logTestBegin (testMethodName );
251258 boolean testCompletedSuccessfully = false ;
259+ resetMonitoringExporterToPreBuiltConfig ();
252260 HtmlPage page =
253261 submitConfigureForm (exporterUrl , "replace" , configPath + "/rest_oneattribval.yml" );
254262 assertTrue (page .asText ().contains ("values: invocationTotalCount" ));
@@ -269,6 +277,7 @@ public void test06_ReplaceWithEmptyConfiguration() throws Exception {
269277 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
270278 logTestBegin (testMethodName );
271279 boolean testCompletedSuccessfully = false ;
280+ resetMonitoringExporterToPreBuiltConfig ();
272281 HtmlPage page = submitConfigureForm (exporterUrl , "replace" , configPath + "/rest_empty.yml" );
273282 assertTrue (page .asText ().contains ("queries:" ) && !page .asText ().contains ("values" ));
274283 testCompletedSuccessfully = true ;
@@ -286,6 +295,7 @@ public void test07_AppendWithEmptyConfiguration() throws Exception {
286295 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
287296 logTestBegin (testMethodName );
288297 boolean testCompletedSuccessfully = false ;
298+ resetMonitoringExporterToPreBuiltConfig ();
289299 final WebClient webClient = new WebClient ();
290300 HtmlPage originalPage = webClient .getPage (exporterUrl );
291301 assertNotNull (originalPage );
@@ -306,6 +316,7 @@ public void test08_1AppendWithNotYmlConfiguration() throws Exception {
306316 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
307317 logTestBegin (testMethodName );
308318 boolean testCompletedSuccessfully = false ;
319+ resetMonitoringExporterToPreBuiltConfig ();
309320 changeConfigNegative (
310321 "append" , configPath + "/rest_notymlformat.yml" , "Configuration is not in YAML format" );
311322 testCompletedSuccessfully = true ;
@@ -323,6 +334,7 @@ public void test08_2ReplaceWithNotYmlConfiguration() throws Exception {
323334 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
324335 logTestBegin (testMethodName );
325336 boolean testCompletedSuccessfully = false ;
337+ resetMonitoringExporterToPreBuiltConfig ();
326338 changeConfigNegative (
327339 "replace" , configPath + "/rest_notymlformat.yml" , "Configuration is not in YAML format" );
328340 }
@@ -358,6 +370,7 @@ public void test10_ReplaceWithCorruptedYmlConfiguration() throws Exception {
358370 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
359371 logTestBegin (testMethodName );
360372 boolean testCompletedSuccessfully = false ;
373+ resetMonitoringExporterToPreBuiltConfig ();
361374 changeConfigNegative (
362375 "replace" ,
363376 configPath + "/rest_notyml.yml" ,
@@ -377,6 +390,7 @@ public void test11_ReplaceWithDublicatedValuesConfiguration() throws Exception {
377390 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
378391 logTestBegin (testMethodName );
379392 boolean testCompletedSuccessfully = false ;
393+ resetMonitoringExporterToPreBuiltConfig ();
380394 changeConfigNegative (
381395 "replace" ,
382396 configPath + "/rest_dublicatedval.yml" ,
@@ -396,6 +410,7 @@ public void test12_AppendWithDublicatedValuesConfiguration() throws Exception {
396410 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
397411 logTestBegin (testMethodName );
398412 boolean testCompletedSuccessfully = false ;
413+ resetMonitoringExporterToPreBuiltConfig ();
399414 changeConfigNegative (
400415 "append" ,
401416 configPath + "/rest_dublicatedval.yml" ,
@@ -416,6 +431,7 @@ public void test13_ReplaceMetricsNameSnakeCaseFalseConfiguration() throws Except
416431 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
417432 logTestBegin (testMethodName );
418433 boolean testCompletedSuccessfully = false ;
434+ resetMonitoringExporterToPreBuiltConfig ();
419435 final WebClient webClient = new WebClient ();
420436 HtmlPage originalPage = webClient .getPage (exporterUrl );
421437 assertNotNull (originalPage );
@@ -608,6 +624,8 @@ private HtmlPage submitConfigureForm(
608624 HtmlPage page2 = button .click ();
609625 assertNotNull (page2 );
610626 assertFalse ((page2 .asText ()).contains ("Error 500--Internal Server Error" ));
627+ // wait time for coordinator to update both managed configuration
628+ Thread .sleep (15 * 1000 );
611629 return page2 ;
612630 }
613631
@@ -643,7 +661,8 @@ private static void gitCloneBuildMonitoringExporter() throws Exception {
643661 logger .info (" Cloning and building Weblogic Server Monitoring Exporter application" );
644662 // git clone exporter project
645663 removeAndClone
646- .append (" git clone https://github.com/oracle/weblogic-monitoring-exporter.git " )
664+ .append (
665+ " git clone -b load-balancer https://github.com/oracle/weblogic-monitoring-exporter.git " )
647666 .append (monitoringExporterSrcDir );
648667 TestUtils .exec (removeAndClone .toString ());
649668 }
@@ -721,6 +740,21 @@ private static void deployMonitoringExporterPrometethusGrafana(
721740 "wlsexporter" , exporterAppPath , BaseTest .getUsername (), BaseTest .getPassword ());
722741 }
723742
743+ private static void redeployMonitoringExporter (Domain domain ) throws Exception {
744+ String exporterAppPath = monitoringExporterDir + "/apps/monitoringexporter/wls-exporter.war" ;
745+
746+ domain .undeployWebAppViaREST (
747+ "wlsexporter" , exporterAppPath , BaseTest .getUsername (), BaseTest .getPassword ());
748+ domain .deployWebAppViaREST (
749+ "wlsexporter" , exporterAppPath , BaseTest .getUsername (), BaseTest .getPassword ());
750+ // check if exporter is up
751+ domain .callWebAppAndVerifyLoadBalancing ("wls-exporter" , false );
752+ }
753+
754+ private static void resetMonitoringExporterToPreBuiltConfig () throws Exception {
755+ redeployMonitoringExporter (domain );
756+ }
757+
724758 private static void deletePrometheusGrafana () throws Exception {
725759
726760 String samplesDir = monitoringExporterDir + "/src/samples/kubernetes/" ;
@@ -846,6 +880,17 @@ private static void upgradeTraefikHostName() throws Exception {
846880 TestUtils .exec (cmd .toString ());
847881 }
848882
883+ /**
884+ * call operator to scale to specified number of replicas
885+ *
886+ * @param replicas - number of managed servers
887+ * @throws Exception
888+ */
889+ private void scaleCluster (int replicas ) throws Exception {
890+ logger .info ("Scale up/down to " + replicas + " managed servers" );
891+ operator .scale (domain .getDomainUid (), domain .getClusterName (), replicas );
892+ }
893+
849894 /**
850895 * call webapp and verify load balancing by checking server name in the response
851896 *
0 commit comments