diff --git a/integration-tests/src/test/java/oracle/kubernetes/operator/ITMonitoringExporter.java b/integration-tests/src/test/java/oracle/kubernetes/operator/ITMonitoringExporter.java index 23ed3e8a66e..087af1a6a65 100644 --- a/integration-tests/src/test/java/oracle/kubernetes/operator/ITMonitoringExporter.java +++ b/integration-tests/src/test/java/oracle/kubernetes/operator/ITMonitoringExporter.java @@ -197,8 +197,13 @@ public void test03_AppendConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + // scale cluster to 1 managed server only to test functionality of the exporter without + // coordinator layer + scaleCluster(1); + // make sure some config is there HtmlPage page = submitConfigureForm(exporterUrl, "replace", configPath + "/rest_jvm.yml"); + assertTrue(page.asText().contains("JVMRuntime")); assertFalse(page.asText().contains("WebAppComponentRuntime")); // run append @@ -228,6 +233,8 @@ public void test04_ReplaceOneAttributeValueAsArrayConfiguration() throws Excepti logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); + HtmlPage page = submitConfigureForm(exporterUrl, "replace", configPath + "/rest_oneattribval.yml"); assertTrue(page.asText().contains("values: invocationTotalCount")); @@ -249,6 +256,7 @@ public void test05_AppendArrayWithOneExistedAndOneDifferentAttributeValueAsArray String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); HtmlPage page = submitConfigureForm(exporterUrl, "replace", configPath + "/rest_oneattribval.yml"); assertTrue(page.asText().contains("values: invocationTotalCount")); @@ -269,6 +277,7 @@ public void test06_ReplaceWithEmptyConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); HtmlPage page = submitConfigureForm(exporterUrl, "replace", configPath + "/rest_empty.yml"); assertTrue(page.asText().contains("queries:") && !page.asText().contains("values")); testCompletedSuccessfully = true; @@ -286,6 +295,7 @@ public void test07_AppendWithEmptyConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); final WebClient webClient = new WebClient(); HtmlPage originalPage = webClient.getPage(exporterUrl); assertNotNull(originalPage); @@ -306,6 +316,7 @@ public void test08_1AppendWithNotYmlConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); changeConfigNegative( "append", configPath + "/rest_notymlformat.yml", "Configuration is not in YAML format"); testCompletedSuccessfully = true; @@ -323,6 +334,7 @@ public void test08_2ReplaceWithNotYmlConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); changeConfigNegative( "replace", configPath + "/rest_notymlformat.yml", "Configuration is not in YAML format"); } @@ -358,6 +370,7 @@ public void test10_ReplaceWithCorruptedYmlConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); changeConfigNegative( "replace", configPath + "/rest_notyml.yml", @@ -377,6 +390,7 @@ public void test11_ReplaceWithDublicatedValuesConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); changeConfigNegative( "replace", configPath + "/rest_dublicatedval.yml", @@ -396,6 +410,7 @@ public void test12_AppendWithDublicatedValuesConfiguration() throws Exception { String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); changeConfigNegative( "append", configPath + "/rest_dublicatedval.yml", @@ -416,6 +431,7 @@ public void test13_ReplaceMetricsNameSnakeCaseFalseConfiguration() throws Except String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); logTestBegin(testMethodName); boolean testCompletedSuccessfully = false; + resetMonitoringExporterToPreBuiltConfig(); final WebClient webClient = new WebClient(); HtmlPage originalPage = webClient.getPage(exporterUrl); assertNotNull(originalPage); @@ -608,6 +624,8 @@ private HtmlPage submitConfigureForm( HtmlPage page2 = button.click(); assertNotNull(page2); assertFalse((page2.asText()).contains("Error 500--Internal Server Error")); + // wait time for coordinator to update both managed configuration + Thread.sleep(15 * 1000); return page2; } @@ -643,7 +661,7 @@ private static void gitCloneBuildMonitoringExporter() throws Exception { logger.info(" Cloning and building Weblogic Server Monitoring Exporter application"); // git clone exporter project removeAndClone - .append(" git clone https://github.com/oracle/weblogic-monitoring-exporter.git ") + .append(" git clone https://github.com/oracle/weblogic-monitoring-exporter.git ") .append(monitoringExporterSrcDir); TestUtils.exec(removeAndClone.toString()); } @@ -721,6 +739,21 @@ private static void deployMonitoringExporterPrometethusGrafana( "wlsexporter", exporterAppPath, BaseTest.getUsername(), BaseTest.getPassword()); } + private static void redeployMonitoringExporter(Domain domain) throws Exception { + String exporterAppPath = monitoringExporterDir + "/apps/monitoringexporter/wls-exporter.war"; + + domain.undeployWebAppViaREST( + "wlsexporter", exporterAppPath, BaseTest.getUsername(), BaseTest.getPassword()); + domain.deployWebAppViaREST( + "wlsexporter", exporterAppPath, BaseTest.getUsername(), BaseTest.getPassword()); + // check if exporter is up + domain.callWebAppAndVerifyLoadBalancing("wls-exporter", false); + } + + private static void resetMonitoringExporterToPreBuiltConfig() throws Exception { + redeployMonitoringExporter(domain); + } + private static void deletePrometheusGrafana() throws Exception { String samplesDir = monitoringExporterDir + "/src/samples/kubernetes/"; @@ -846,6 +879,17 @@ private static void upgradeTraefikHostName() throws Exception { TestUtils.exec(cmd.toString()); } + /** + * call operator to scale to specified number of replicas + * + * @param replicas - number of managed servers + * @throws Exception + */ + private void scaleCluster(int replicas) throws Exception { + logger.info("Scale up/down to " + replicas + " managed servers"); + operator.scale(domain.getDomainUid(), domain.getClusterName(), replicas); + } + /** * call webapp and verify load balancing by checking server name in the response * diff --git a/integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java b/integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java index 027e374e03c..b6d0c63757e 100644 --- a/integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java +++ b/integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java @@ -386,6 +386,36 @@ public void deployWebAppViaREST( } } + /** + * undeploy webapp using nodehost and nodeport + * + * @throws Exception + */ + public void undeployWebAppViaREST( + String webappName, String webappLocation, String username, String password) throws Exception { + StringBuffer cmd = new StringBuffer(); + cmd.append("curl --noproxy '*' --silent --user ") + .append(username) + .append(":") + .append(password) + .append(" -H X-Requested-By:MyClient -H Accept:application/json") + .append(" -H Content-Type:application/json -d \"{}\" ") + .append(" -X DELETE http://") + .append(getNodeHost()) + .append(":") + .append(getNodePort()) + .append("/management/weblogic/latest/edit/appDeployments/") + .append(webappName) + .append(" --write-out %{http_code} -o /dev/null"); + logger.fine("Command to undeploy webapp " + cmd); + ExecResult result = TestUtils.exec(cmd.toString()); + String output = result.stdout().trim(); + if (!output.contains("200")) { + throw new RuntimeException( + "FAILURE: Webapp undeployment failed with response code " + output); + } + } + /** * deploy webapp using t3 channel port for wlst * @@ -498,7 +528,7 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo } testAppUrl.append(webappName).append("/"); // curl cmd to call webapp - StringBuffer curlCmd = new StringBuffer("curl --silent "); + StringBuffer curlCmd = new StringBuffer("curl --silent --noproxy '*' "); curlCmd .append(" -H 'host: ") .append(domainUid) diff --git a/integration-tests/src/test/resources/exporter/rest.yml b/integration-tests/src/test/resources/exporter/rest.yml index 8ca726d3168..af836a54651 100644 --- a/integration-tests/src/test/resources/exporter/rest.yml +++ b/integration-tests/src/test/resources/exporter/rest.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_dublicatedval.yml b/integration-tests/src/test/resources/exporter/rest_dublicatedval.yml index 8716829523a..ad234e5dff7 100644 --- a/integration-tests/src/test/resources/exporter/rest_dublicatedval.yml +++ b/integration-tests/src/test/resources/exporter/rest_dublicatedval.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_jvm.yml b/integration-tests/src/test/resources/exporter/rest_jvm.yml index af1f861d05c..2cc998bd4e6 100644 --- a/integration-tests/src/test/resources/exporter/rest_jvm.yml +++ b/integration-tests/src/test/resources/exporter/rest_jvm.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - JVMRuntime: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_notyml.yml b/integration-tests/src/test/resources/exporter/rest_notyml.yml index 93951ab9b9b..18ddf78b397 100644 --- a/integration-tests/src/test/resources/exporter/rest_notyml.yml +++ b/integration-tests/src/test/resources/exporter/rest_notyml.yml @@ -1,6 +1,6 @@ # Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. - +restPort: 8001 query_sync: url: http://coordinator:8999/ refreshInterval: 5 diff --git a/integration-tests/src/test/resources/exporter/rest_oneattribval.yml b/integration-tests/src/test/resources/exporter/rest_oneattribval.yml index e958f3494d3..519b3533c34 100644 --- a/integration-tests/src/test/resources/exporter/rest_oneattribval.yml +++ b/integration-tests/src/test/resources/exporter/rest_oneattribval.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_snakecasefalse.yml b/integration-tests/src/test/resources/exporter/rest_snakecasefalse.yml index 3718c6c8d6c..7a52fabc90c 100644 --- a/integration-tests/src/test/resources/exporter/rest_snakecasefalse.yml +++ b/integration-tests/src/test/resources/exporter/rest_snakecasefalse.yml @@ -4,6 +4,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_snakecasetrue.yml b/integration-tests/src/test/resources/exporter/rest_snakecasetrue.yml index bfa3bd1aee9..135d8faf90b 100644 --- a/integration-tests/src/test/resources/exporter/rest_snakecasetrue.yml +++ b/integration-tests/src/test/resources/exporter/rest_snakecasetrue.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_twoattribs.yml b/integration-tests/src/test/resources/exporter/rest_twoattribs.yml index 92898324012..c32f3522532 100644 --- a/integration-tests/src/test/resources/exporter/rest_twoattribs.yml +++ b/integration-tests/src/test/resources/exporter/rest_twoattribs.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_webapp.yml b/integration-tests/src/test/resources/exporter/rest_webapp.yml index bfa3bd1aee9..135d8faf90b 100644 --- a/integration-tests/src/test/resources/exporter/rest_webapp.yml +++ b/integration-tests/src/test/resources/exporter/rest_webapp.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_workmanagers.yml b/integration-tests/src/test/resources/exporter/rest_workmanagers.yml index bcfef022404..ad572932b63 100755 --- a/integration-tests/src/test/resources/exporter/rest_workmanagers.yml +++ b/integration-tests/src/test/resources/exporter/rest_workmanagers.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name diff --git a/integration-tests/src/test/resources/exporter/rest_wseeclient.yml b/integration-tests/src/test/resources/exporter/rest_wseeclient.yml index 832b2469a66..ec71edf144b 100644 --- a/integration-tests/src/test/resources/exporter/rest_wseeclient.yml +++ b/integration-tests/src/test/resources/exporter/rest_wseeclient.yml @@ -5,6 +5,7 @@ query_sync: url: http://coordinator:8999/ refreshInterval: 5 metricsNameSnakeCase: true +restPort: 8001 queries: - applicationRuntimes: key: name