Skip to content

Commit 1303e5d

Browse files
marinakogrjeberhard
authored andcommitted
added restPort to exporter config, removed test dependencies
1 parent 4ae2a4b commit 1303e5d

File tree

13 files changed

+88
-3
lines changed

13 files changed

+88
-3
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITMonitoringExporter.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
*

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,36 @@ public void deployWebAppViaREST(
386386
}
387387
}
388388

389+
/**
390+
* undeploy webapp using nodehost and nodeport
391+
*
392+
* @throws Exception
393+
*/
394+
public void undeployWebAppViaREST(
395+
String webappName, String webappLocation, String username, String password) throws Exception {
396+
StringBuffer cmd = new StringBuffer();
397+
cmd.append("curl --noproxy '*' --silent --user ")
398+
.append(username)
399+
.append(":")
400+
.append(password)
401+
.append(" -H X-Requested-By:MyClient -H Accept:application/json")
402+
.append(" -H Content-Type:application/json -d \"{}\" ")
403+
.append(" -X DELETE http://")
404+
.append(getNodeHost())
405+
.append(":")
406+
.append(getNodePort())
407+
.append("/management/weblogic/latest/edit/appDeployments/")
408+
.append(webappName)
409+
.append(" --write-out %{http_code} -o /dev/null");
410+
logger.fine("Command to undeploy webapp " + cmd);
411+
ExecResult result = TestUtils.exec(cmd.toString());
412+
String output = result.stdout().trim();
413+
if (!output.contains("200")) {
414+
throw new RuntimeException(
415+
"FAILURE: Webapp undeployment failed with response code " + output);
416+
}
417+
}
418+
389419
/**
390420
* deploy webapp using t3 channel port for wlst
391421
*
@@ -498,7 +528,7 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo
498528
}
499529
testAppUrl.append(webappName).append("/");
500530
// curl cmd to call webapp
501-
StringBuffer curlCmd = new StringBuffer("curl --silent ");
531+
StringBuffer curlCmd = new StringBuffer("curl --silent --noproxy '*' ");
502532
curlCmd
503533
.append(" -H 'host: ")
504534
.append(domainUid)

integration-tests/src/test/resources/exporter/rest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
77
metricsNameSnakeCase: true
8+
restPort: 8001
89
queries:
910
- applicationRuntimes:
1011
key: name

integration-tests/src/test/resources/exporter/rest_dublicatedval.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
77
metricsNameSnakeCase: true
8+
restPort: 8001
89
queries:
910
- applicationRuntimes:
1011
key: name

integration-tests/src/test/resources/exporter/rest_jvm.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
77
metricsNameSnakeCase: true
8+
restPort: 8001
89
queries:
910
- JVMRuntime:
1011
key: name

integration-tests/src/test/resources/exporter/rest_notyml.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3-
3+
restPort: 8001
44
query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5

integration-tests/src/test/resources/exporter/rest_oneattribval.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
77
metricsNameSnakeCase: true
8+
restPort: 8001
89
queries:
910
- applicationRuntimes:
1011
key: name

integration-tests/src/test/resources/exporter/rest_snakecasefalse.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
7+
restPort: 8001
78
queries:
89
- applicationRuntimes:
910
key: name

integration-tests/src/test/resources/exporter/rest_snakecasetrue.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
77
metricsNameSnakeCase: true
8+
restPort: 8001
89
queries:
910
- applicationRuntimes:
1011
key: name

integration-tests/src/test/resources/exporter/rest_twoattribs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query_sync:
55
url: http://coordinator:8999/
66
refreshInterval: 5
77
metricsNameSnakeCase: true
8+
restPort: 8001
89
queries:
910
- applicationRuntimes:
1011
key: name

0 commit comments

Comments
 (0)