Skip to content

Commit 2e987d6

Browse files
marinakogrjeberhard
authored andcommitted
Update MonitoringExporterFiltering tests to adjust changes for wls-exporter servlet package name changes
1 parent cc42623 commit 2e987d6

11 files changed

+332
-191
lines changed

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2025, 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 = [
@@ -168,7 +168,7 @@ pipeline {
168168
)
169169
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
170170
description: '',
171-
defaultValue: '2.1.2'
171+
defaultValue: '2.3.0'
172172
)
173173
string(name: 'PROMETHEUS_CHART_VERSION',
174174
description: '',

Jenkinsfile.armoke

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, 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

@@ -179,7 +179,7 @@ pipeline {
179179
)
180180
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
181181
description: '',
182-
defaultValue: '2.1.3'
182+
defaultValue: '2.3.0'
183183
)
184184
string(name: 'PROMETHEUS_CHART_VERSION',
185185
description: '',

Jenkinsfile.kindnightly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2025, 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 = [
@@ -185,7 +185,7 @@ pipeline {
185185
)
186186
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
187187
description: '',
188-
defaultValue: '2.1.2'
188+
defaultValue: '2.3.0'
189189
)
190190
string(name: 'PROMETHEUS_CHART_VERSION',
191191
description: '',

Jenkinsfile.ocne

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, 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

@@ -176,7 +176,7 @@ pipeline {
176176
)
177177
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
178178
description: '',
179-
defaultValue: '2.1.3'
179+
defaultValue: '2.3.0'
180180
)
181181
string(name: 'PROMETHEUS_CHART_VERSION',
182182
description: '',

Jenkinsfile.ocne19

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2024, 2025, 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

@@ -167,7 +167,7 @@ pipeline {
167167
)
168168
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
169169
description: '',
170-
defaultValue: '2.1.3'
170+
defaultValue: '2.3.0'
171171
)
172172
string(name: 'PROMETHEUS_CHART_VERSION',
173173
description: '',

Jenkinsfile.oke

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, 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

@@ -193,7 +193,7 @@ pipeline {
193193
)
194194
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
195195
description: '',
196-
defaultValue: '2.2.2'
196+
defaultValue: '2.3.0'
197197
)
198198
string(name: 'PROMETHEUS_CHART_VERSION',
199199
description: '',

Jenkinsfile.podman

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2024, 2025, 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 = [
@@ -178,7 +178,7 @@ pipeline {
178178
)
179179
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
180180
description: '',
181-
defaultValue: '2.1.2'
181+
defaultValue: '2.3.0'
182182
)
183183
string(name: 'PROMETHEUS_CHART_VERSION',
184184
description: '',

Jenkinsfile.podman.upgrade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2024, 2025, 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 = [
@@ -185,7 +185,7 @@ pipeline {
185185
)
186186
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
187187
description: '',
188-
defaultValue: '2.1.2'
188+
defaultValue: '2.3.0'
189189
)
190190
string(name: 'PROMETHEUS_CHART_VERSION',
191191
description: '',

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

Lines changed: 95 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, 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;
@@ -44,12 +44,14 @@
4444
import static oracle.weblogic.kubernetes.TestConstants.IT_MONITORINGEXPORTERMF_PROMETHEUS_HTTP_NODEPORT;
4545
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
4646
import static oracle.weblogic.kubernetes.TestConstants.KIND_CLUSTER;
47+
import static oracle.weblogic.kubernetes.TestConstants.MONITORING_EXPORTER_WEBAPP_VERSION;
4748
import static oracle.weblogic.kubernetes.TestConstants.OKD;
4849
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER_PRIVATEIP;
4950
import static oracle.weblogic.kubernetes.TestConstants.PROMETHEUS_CHART_VERSION;
5051
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
5152
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTPS_HOSTPORT;
5253
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
54+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
5355
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER;
5456
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER_DEFAULT;
5557
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -72,6 +74,7 @@
7274
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.installAndVerifyGrafana;
7375
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.installAndVerifyPrometheus;
7476
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.installMonitoringExporter;
77+
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.replaceValueInFile;
7578
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.uninstallPrometheusGrafana;
7679
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.verifyMonExpAppAccess;
7780
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
@@ -134,6 +137,7 @@ class ItMonitoringExporterMetricsFiltering {
134137
private static String grafanaReleaseName = "grafana" + releaseSuffix;
135138
private static String monitoringExporterDir;
136139
private static String hostPortPrometheus = null;
140+
private static String servletPath = "com.oracle.wls.exporter";
137141

138142

139143
/**
@@ -223,6 +227,14 @@ public void initAll(@Namespaces(4) List<String> namespaces) throws IOException {
223227
}
224228
assertDoesNotThrow(() -> setupDomainAndMonitoringTools(domain1Namespace, domain1Uid),
225229
"failed to setup domain and monitoring tools");
230+
231+
if (!isVersionAtLeast(MONITORING_EXPORTER_WEBAPP_VERSION, "2.3.0")) {
232+
logger.info("Monitoting Exporter Version is less than 2.3.0");
233+
servletPath = "com.oracle.wls.exporter.webapp";
234+
} else {
235+
servletPath = servletPath + ((WEBLOGIC_IMAGE_TAG.contains("14.1")
236+
|| WEBLOGIC_IMAGE_TAG.contains("12.")) ? ".javax" : ".jakarta");
237+
}
226238
}
227239

228240
/**
@@ -249,12 +261,21 @@ void testFilterIIncludedKeysFromTopLevel() throws Exception {
249261
void testFilterIIncludedKeysFromSubLevel() throws Exception {
250262
logger.info("Testing filtering only included specific app name in the metrics ");
251263
List<String> checkIncluded = new ArrayList<>();
252-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
264+
// Regular expression pattern to match servletName="ANYTHING.ExporterServlet"
265+
String checkKey1 = "servletName=\"" + servletPath + ".ExporterServlet\"";
266+
checkIncluded.add(checkKey1);
253267
List<String> checkExcluded = new ArrayList<>();
254-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
255-
256-
replaceConfigurationWithFilter(RESOURCE_DIR + "/exporter/rest_filter_included_servlet_name.yaml",
268+
// Regular expression pattern to match servletName="ANYTHING.ExporterServlet"
269+
String checkKey2 = "servletName=\"" + servletPath + ".MainServlet\"";
270+
checkExcluded.add(checkKey2);
271+
272+
String configurationFile = replaceValueInFile(
273+
"ItMonitoringExporterMetricsFiltering/testFilterIIncludedKeysFromSubLevel",
274+
"rest_filter_included_servlet_name.yaml",
275+
"com.oracle.wls.exporter.webapp", servletPath);
276+
replaceConfigurationWithFilter(configurationFile,
257277
checkIncluded, checkExcluded);
278+
258279
}
259280

260281
/**
@@ -266,13 +287,20 @@ void testFilterIIncludedKeysFromSubLevel() throws Exception {
266287
void testFilterIIncludedKeysFromBothLevels() throws Exception {
267288
logger.info("Testing filtering only included specific app name in the metrics ");
268289
List<String> checkIncluded = new ArrayList<>();
269-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
290+
String checkKey1 = "servletName=\"" + servletPath + ".ExporterServlet\"";
291+
checkIncluded.add(checkKey1);
270292
checkIncluded.add("app=\"wls-exporter\"");
271293
List<String> checkExcluded = new ArrayList<>();
272-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
294+
String checkKey2 = "servletName=\"" + servletPath + ".MainServlet\"";
295+
checkExcluded.add(checkKey2);
273296
checkExcluded.add("app=\"myear1\"");
274-
replaceConfigurationWithFilter(RESOURCE_DIR
275-
+ "/exporter/rest_filter_included_webapp_and_servlet_names.yaml",checkIncluded, checkExcluded);
297+
String configurationFile = replaceValueInFile(
298+
"ItMonitoringExporterMetricsFiltering/testFilterIIncludedKeysFromBothLevels",
299+
"rest_filter_included_webapp_and_servlet_names.yaml",
300+
"com.oracle.wls.exporter.webapp", servletPath);
301+
replaceConfigurationWithFilter(configurationFile,
302+
checkIncluded, checkExcluded);
303+
276304
}
277305

278306
/**
@@ -299,11 +327,16 @@ void testFilterExcludedKeysFromTopLevel() throws Exception {
299327
void testFilterExcludedKeysFromSubLevel() throws Exception {
300328
logger.info("Testing filtering only excluded specific app name in the metrics ");
301329
List<String> checkIncluded = new ArrayList<>();
302-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
330+
String checkKey1 = "servletName=\"" + servletPath + ".MainServlet\"";
331+
checkIncluded.add(checkKey1);
303332
List<String> checkExcluded = new ArrayList<>();
304-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
305-
306-
replaceConfigurationWithFilter(RESOURCE_DIR + "/exporter/rest_filter_excluded_servlet_name.yaml",
333+
String checkKey2 = "servletName=\"" + servletPath + ".ExporterServlet\"";
334+
checkExcluded.add(checkKey2);
335+
String configurationFile = replaceValueInFile(
336+
"ItMonitoringExporterMetricsFiltering/testFilterExcludedKeysFromSubLevel",
337+
"rest_filter_excluded_servlet_name.yaml",
338+
"com.oracle.wls.exporter.webapp", servletPath);
339+
replaceConfigurationWithFilter(configurationFile,
307340
checkIncluded, checkExcluded);
308341
}
309342

@@ -316,13 +349,19 @@ void testFilterExcludedKeysFromSubLevel() throws Exception {
316349
void testFilterExcludedKeysFromBothLevels() throws Exception {
317350
logger.info("Testing filtering only excluded specific app name in the metrics ");
318351
List<String> checkIncluded = new ArrayList<>();
319-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
352+
String checkKey1 = "servletName=\"" + servletPath + ".ExporterServlet\"";
353+
checkIncluded.add(checkKey1);
320354
checkIncluded.add("app=\"myear1\"");
321355
List<String> checkExcluded = new ArrayList<>();
322-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
356+
String checkKey2 = "servletName=\"" + servletPath + ".MainServlet\"";
357+
checkExcluded.add(checkKey2);
323358
checkExcluded.add("app=\"myear123\"");
324-
replaceConfigurationWithFilter(RESOURCE_DIR
325-
+ "/exporter/rest_filter_excluded_webapp_and_servlet_names.yaml",checkIncluded, checkExcluded);
359+
String configurationFile = replaceValueInFile(
360+
"ItMonitoringExporterMetricsFiltering/testFilterExcludedKeysFromBothLevels",
361+
"rest_filter_excluded_webapp_and_servlet_names.yaml",
362+
"com.oracle.wls.exporter.webapp", servletPath);
363+
replaceConfigurationWithFilter(configurationFile,
364+
checkIncluded, checkExcluded);
326365
}
327366

328367
/**
@@ -336,9 +375,13 @@ void testFilterIncludedTopExcludedKeysSubLevels() throws Exception {
336375
List<String> checkIncluded = new ArrayList<>();
337376
checkIncluded.add("app=\"wls-exporter\"");
338377
List<String> checkExcluded = new ArrayList<>();
339-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
340-
replaceConfigurationWithFilter(RESOURCE_DIR
341-
+ "/exporter/rest_filter_included_webapp_excluded_servlet_name.yaml",checkIncluded, checkExcluded);
378+
checkExcluded.add("servletName=\"" + servletPath + ".ExporterServlet\"");
379+
String configurationFile = replaceValueInFile(
380+
"ItMonitoringExporterMetricsFiltering/testFilterIncludedTopExcludedKeysSubLevels",
381+
"rest_filter_included_webapp_excluded_servlet_name.yaml",
382+
"com.oracle.wls.exporter.webapp", servletPath);
383+
replaceConfigurationWithFilter(configurationFile,
384+
checkIncluded, checkExcluded);
342385
}
343386

344387
/**
@@ -368,11 +411,16 @@ void testFilterIncludedExcludedKeysComboTopLevel() throws Exception {
368411
void testFilterIncludedExcludedKeysComboSubLevel() throws Exception {
369412
logger.info("Testing filtering included and excluded specific app names in the metrics ");
370413
List<String> checkIncluded = new ArrayList<>();
371-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp");
414+
checkIncluded.add("servletName=\"" + servletPath);
372415
List<String> checkExcluded = new ArrayList<>();
373-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
374-
replaceConfigurationWithFilter(RESOURCE_DIR
375-
+ "/exporter/rest_filter_included_excluded_servlet_name.yaml",checkIncluded, checkExcluded);
416+
checkExcluded.add("servletName=\"" + servletPath + ".ExporterServlet\"");
417+
String configurationFile = replaceValueInFile(
418+
"ItMonitoringExporterMetricsFiltering/testFilterIncludedExcludedKeysComboSubLevel",
419+
"rest_filter_included_excluded_servlet_name.yaml",
420+
"com.oracle.wls.exporter.webapp", servletPath);
421+
replaceConfigurationWithFilter(configurationFile,
422+
checkIncluded, checkExcluded);
423+
376424
}
377425

378426
/**
@@ -728,17 +776,21 @@ private void replaceConfigurationWithFilter(String configurationFile,
728776
}
729777

730778
private static void verifyMetrics(List<String> checkIncluded, List<String> checkExcluded) {
779+
boolean isRegexInc = false;
780+
boolean isRegexExc = false;
731781
for (String includedString : checkIncluded) {
782+
732783
assertTrue(verifyMonExpAppAccess("wls-exporter/metrics",
733-
includedString,
784+
includedString, isRegexInc,
734785
domain1Uid,
735786
domain1Namespace,
736787
false, cluster1Name),
737788
"monitoring exporter metrics can't filter to included " + includedString);
738789
}
739790
for (String excludedString : checkExcluded) {
791+
740792
assertFalse(verifyMonExpAppAccess("wls-exporter/metrics",
741-
excludedString,
793+
excludedString, isRegexExc,
742794
domain1Uid,
743795
domain1Namespace,
744796
false, cluster1Name),
@@ -759,7 +811,6 @@ private void appendConfiguration(String configFile) throws Exception {
759811
"Page does not contain expected Unable to Update Configuration");
760812
}
761813

762-
763814
private static void installTraefikIngressController() throws IOException {
764815
// install and verify Traefik
765816
logger.info("Installing Traefik controller using helm");
@@ -781,5 +832,22 @@ private int getTraefikLbNodePort(boolean isHttps) {
781832
-> getServiceNodePort(traefikNamespace, traefikHelmParams.getReleaseName(), isHttps ? "websecure" : "web"),
782833
"Getting web node port for Traefik loadbalancer failed");
783834
}
835+
836+
private static boolean isVersionAtLeast(String version, String minVersion) {
837+
String[] versionParts = version.split("\\.");
838+
String[] minVersionParts = minVersion.split("\\.");
839+
840+
for (int i = 0; i < 3; i++) {
841+
int verPart = Integer.parseInt(versionParts[i]); // Convert to integer
842+
int minVPart = Integer.parseInt(minVersionParts[i]);
843+
844+
if (verPart > minVPart) {
845+
return true;
846+
} else if (verPart < minVPart) {
847+
return false;
848+
}
849+
}
850+
return true; // Versions are equal
851+
}
784852
}
785853

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, 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;
@@ -311,7 +311,7 @@ public interface TestConstants {
311311

312312
//monitoring constants
313313
public static final String MONITORING_EXPORTER_WEBAPP_VERSION =
314-
getNonEmptySystemProperty("wko.it.monitoring.exporter.webapp.version", "2.1.3");
314+
getNonEmptySystemProperty("wko.it.monitoring.exporter.webapp.version", "2.3.0");
315315
public static final String MONITORING_EXPORTER_BRANCH =
316316
getNonEmptySystemProperty("wko.it.monitoring.exporter.branch", "main");
317317
public static final String PROMETHEUS_CHART_VERSION =

0 commit comments

Comments
 (0)