Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"));
Expand All @@ -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"));
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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");
}
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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/";
Expand Down Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/test/resources/exporter/rest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/test/resources/exporter/rest_jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- JVMRuntime:
key: name
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
query_sync:
url: http://coordinator:8999/
refreshInterval: 5
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query_sync:
url: http://coordinator:8999/
refreshInterval: 5
metricsNameSnakeCase: true
restPort: 8001
queries:
- applicationRuntimes:
key: name
Expand Down