Skip to content

Commit 9565f00

Browse files
authored
Added tests for monitoring exporter filtering feature (#3812)
* Added tests for monitoring exporter filtering feature
1 parent ffc1114 commit 9565f00

21 files changed

+1175
-16
lines changed

Jenkinsfile.kindnightly

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
//
44
def kind_k8s_map = [
@@ -101,7 +101,8 @@ pipeline {
101101

102102
tools {
103103
maven 'maven-3.8.5'
104-
jdk 'jdk11'
104+
jdk 'OpenJDK 17.0.2'
105+
#jdk 'jdk11'
105106
}
106107

107108
environment {

Jenkinsfile.oke

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
//
44

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporterMetricsFiltering.java

Lines changed: 717 additions & 0 deletions
Large diffs are not rendered by default.

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/ImageUtils.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.utils;
@@ -343,9 +343,11 @@ public static String createImageAndVerify(String imageNameBase,
343343
if (archiveAppsList.size() != 0 && archiveAppsList.get(0) != null) {
344344
assertTrue(archiveApp(defaultAppParams()
345345
.srcDirList(archiveAppsList)));
346+
String appPath = archiveAppsList.get(0);
347+
346348
//archive provided ear or war file
347-
String appName = archiveAppsList.get(0).substring(archiveAppsList.get(0).lastIndexOf("/") + 1,
348-
appSrcDirList.get(0).lastIndexOf("."));
349+
String appName = appPath.substring(appPath.lastIndexOf("/") + 1,
350+
appPath.lastIndexOf("."));
349351

350352
// build the archive list
351353
String zipAppFile = String.format("%s/%s.zip", ARCHIVE_DIR, appName);
@@ -357,12 +359,15 @@ public static String createImageAndVerify(String imageNameBase,
357359
// build an application archive using what is in resources/apps/APP_NAME
358360
String zipFile = "";
359361
if (oneArchiveContainsMultiApps) {
360-
assertTrue(buildAppArchive(defaultAppParams()
361-
.srcDirList(buildAppDirList)),
362-
String.format("Failed to create app archive for %s", buildAppDirList.get(0)));
363-
zipFile = String.format("%s/%s.zip", ARCHIVE_DIR, buildAppDirList.get(0));
364-
// build the archive list
365-
archiveList.add(zipFile);
362+
for (String buildAppDirs : buildAppDirList) {
363+
assertTrue(buildAppArchive(defaultAppParams()
364+
.srcDirList(Collections.singletonList(buildAppDirs))
365+
.appName(buildAppDirs)),
366+
String.format("Failed to create app archive for %s", buildAppDirs));
367+
zipFile = String.format("%s/%s.zip", ARCHIVE_DIR, buildAppDirs);
368+
// build the archive list
369+
archiveList.add(zipFile);
370+
}
366371
} else if (buildCoherence) {
367372
// build the Coherence GAR file
368373
assertTrue(buildCoherenceArchive(defaultAppParams()

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.utils;
@@ -675,6 +675,19 @@ public static void cleanupPrometheusAdapterClusterRoles() {
675675
*/
676676
public static void installMonitoringExporter(String monitoringExporterDir) {
677677

678+
//adding ability to build monitoring exporter if branch is not main
679+
boolean toBuildMonitoringExporter = (!MONITORING_EXPORTER_BRANCH.equalsIgnoreCase(("main")));
680+
installMonitoringExporter(monitoringExporterDir, toBuildMonitoringExporter);
681+
}
682+
683+
/**
684+
* Download src from monitoring exporter github project and build or install webapp.
685+
*
686+
* @param monitoringExporterDir full path to monitoring exporter install location
687+
* @param toBuildMonitoringExporter if true build monitoring exporter webapp or download if false.
688+
*/
689+
public static void installMonitoringExporter(String monitoringExporterDir, boolean toBuildMonitoringExporter) {
690+
678691
String monitoringExporterSrcDir = Paths.get(monitoringExporterDir, "srcdir").toString();
679692
String monitoringExporterAppDir = Paths.get(monitoringExporterDir, "apps").toString();
680693

@@ -689,8 +702,7 @@ public static void installMonitoringExporter(String monitoringExporterDir) {
689702
assertDoesNotThrow(() -> deleteDirectory(monitoringAppAdministrationRestPort.toFile()));
690703
assertDoesNotThrow(() -> Files.createDirectories(monitoringAppAdministrationRestPort));
691704

692-
//adding ability to build monitoring exporter if branch is not main
693-
boolean toBuildMonitoringExporter = (!MONITORING_EXPORTER_BRANCH.equalsIgnoreCase(("main")));
705+
694706
monitoringExporterAppDir = monitoringApp.toString();
695707
String monitoringExporterAppNoRestPortDir = monitoringAppNoRestPort.toString();
696708
String monitoringExporterAppAdministrationRestPortDir = monitoringAppAdministrationRestPort.toString();
@@ -754,6 +766,35 @@ public static String createAndVerifyMiiImage(String monexpAppDir, String modelFi
754766
return myImage;
755767
}
756768

769+
/**
770+
* Create mii image with monitoring exporter webapp and one more app.
771+
* @param modelList - list of the paths to model files
772+
* @param monexpAppDir - location for monitoring exporter webapp
773+
* @param appName1 -extra app names
774+
* @param imageName - desired imagename
775+
*/
776+
public static String createAndVerifyMiiImage(String monexpAppDir, List<String> modelList,
777+
String appName1, String appName2,
778+
String imageName) {
779+
// create image with model files
780+
logger.info("Create image with model file with monitoring exporter app and verify");
781+
String appPath = String.format("%s/wls-exporter.war", monexpAppDir);
782+
List<String> appList = new ArrayList<>();
783+
appList.add(appPath);
784+
appList.add(appName1);
785+
appList.add(appName2);
786+
787+
// build the model file list
788+
//final List<String> modelList = Collections.singletonList(modelFilePath);
789+
String myImage =
790+
createMiiImageAndVerify(imageName, modelList, appList);
791+
792+
// login and push image to registry if necessary
793+
imageRepoLoginAndPushImageToRegistry(myImage);
794+
795+
return myImage;
796+
}
797+
757798
/**
758799
* Uninstall Prometheus and Grafana helm charts.
759800
*
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
query_sync:
5+
url: http://coordinator:8999/
6+
refreshInterval: 5
7+
metricsNameSnakeCase: true
8+
restPort: 8001
9+
queries:
10+
- applicationRuntimes:
11+
key: name
12+
keyName: app
13+
excludedKeyValues: "notexisted.*"
14+
componentRuntimes:
15+
type: WebAppComponentRuntime
16+
prefix: webapp_config_
17+
key: name
18+
values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs]
19+
stringValues:
20+
status: [ deployed, undeployed ]
21+
servlets:
22+
prefix: wls_servlet_
23+
key: servletName
24+
values: [invocationTotalCount, reloadTotal, executionTimeAverage, poolMaxCapacity, executionTimeTotal, reloadTotalCount, executionTimeHigh, executionTimeLow]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
query_sync:
5+
url: http://coordinator:8999/
6+
refreshInterval: 5
7+
metricsNameSnakeCase: true
8+
restPort: 8001
9+
queries:
10+
- applicationRuntimes:
11+
key: name
12+
keyName: app
13+
componentRuntimes:
14+
type: WebAppComponentRuntime
15+
prefix: webapp_config_
16+
key: name
17+
values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs]
18+
stringValues:
19+
status: [ deployed, undeployed ]
20+
servlets:
21+
prefix: wls_servlet_
22+
key: servletName
23+
excludedKeyValues: "notexisted.*"
24+
values: [invocationTotalCount, reloadTotal, executionTimeAverage, poolMaxCapacity, executionTimeTotal, reloadTotalCount, executionTimeHigh, executionTimeLow]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
query_sync:
4+
url: http://coordinator:8999/
5+
refreshInterval: 5
6+
metricsNameSnakeCase: true
7+
restPort: 8001
8+
queries:
9+
- applicationRuntimes:
10+
key: name
11+
keyName: app
12+
componentRuntimes:
13+
type: WebAppComponentRuntime
14+
prefix: webapp_config_
15+
key: name
16+
values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs]
17+
stringValues:
18+
status: [ deployed, undeployed ]
19+
servlets:
20+
prefix: wls_servlet_
21+
key: servletName
22+
excludedKeyValues: "com.oracle.wls.exporter.webapp.ExporterServlet.*"
23+
values: [invocationTotalCount, reloadTotal, executionTimeAverage, poolMaxCapacity, executionTimeTotal, reloadTotalCount, executionTimeHigh, executionTimeLow]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
query_sync:
5+
url: http://coordinator:8999/
6+
refreshInterval: 5
7+
metricsNameSnakeCase: true
8+
restPort: 8001
9+
queries:
10+
- applicationRuntimes:
11+
key: name
12+
keyName: app
13+
excludedKeyValues: "myear123"
14+
componentRuntimes:
15+
type: WebAppComponentRuntime
16+
prefix: webapp_config_
17+
key: name
18+
values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs]
19+
stringValues:
20+
status: [ deployed, undeployed ]
21+
servlets:
22+
prefix: wls_servlet_
23+
key: servletName
24+
excludedKeyValues: "com.oracle.wls.exporter.webapp.MainServlet"
25+
values: [invocationTotalCount, reloadTotal, executionTimeAverage, poolMaxCapacity, executionTimeTotal, reloadTotalCount, executionTimeHigh, executionTimeLow]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
query_sync:
5+
url: http://coordinator:8999/
6+
refreshInterval: 5
7+
metricsNameSnakeCase: true
8+
restPort: 8001
9+
queries:
10+
- applicationRuntimes:
11+
key: name
12+
keyName: app
13+
excludedKeyValues: "wls-exporter.*"
14+
componentRuntimes:
15+
type: WebAppComponentRuntime
16+
prefix: webapp_config_
17+
key: name
18+
values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs]
19+
stringValues:
20+
status: [ deployed, undeployed ]
21+
servlets:
22+
prefix: wls_servlet_
23+
key: servletName
24+
values: [invocationTotalCount, reloadTotal, executionTimeAverage, poolMaxCapacity, executionTimeTotal, reloadTotalCount, executionTimeHigh, executionTimeLow]

0 commit comments

Comments
 (0)