Skip to content

Commit 879c26e

Browse files
committed
Merge branch 'fixfiltermain' into 'main'
Port forward changes from 4.2 for MonitoringExporterFiltering fix See merge request weblogic-cloud/weblogic-kubernetes-operator!4923
2 parents bd7043d + 5667a8b commit 879c26e

File tree

14 files changed

+201
-71
lines changed

14 files changed

+201
-71
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,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

@@ -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 = [
@@ -193,7 +193,7 @@ pipeline {
193193
)
194194
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
195195
description: '',
196-
defaultValue: '2.1.2'
196+
defaultValue: '2.3.0'
197197
)
198198
string(name: 'PROMETHEUS_CHART_VERSION',
199199
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

@@ -181,7 +181,7 @@ pipeline {
181181
)
182182
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
183183
description: '',
184-
defaultValue: '2.1.3'
184+
defaultValue: '2.3.0'
185185
)
186186
string(name: 'PROMETHEUS_CHART_VERSION',
187187
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.okd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// Copyright (c) 2024, Oracle and/or its affiliates.
2+
// Copyright (c) 2024, 2025, Oracle and/or its affiliates.
33
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
//
55

@@ -149,7 +149,7 @@ pipeline {
149149
)
150150
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
151151
description: '',
152-
defaultValue: '2.1.3'
152+
defaultValue: '2.3.0'
153153
)
154154
string(name: 'PROMETHEUS_CHART_VERSION',
155155
description: '',

Jenkinsfile.oke

Lines changed: 4 additions & 4 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

@@ -86,13 +86,13 @@ pipeline {
8686

8787
string(name: 'OKE_KUBE_VERSION',
8888
description: 'kube version for oke cluster',
89-
defaultValue: '1.30.1'
89+
defaultValue: '1.31.1'
9090
)
9191
string(name: 'IMAGE_ID',
9292
description: 'oci image id for node pool, find image OCID for your region from https://docs.oracle.com/iaas/images/',
9393
//defaultValue OKE1.26.2: 'ocid1.image.oc1.phx.aaaaaaaaaizmtmozeudeeuq7o5ir7dkl2bkxbbb3tgomshqbqn6jpomrsjza'
9494
//1.27.2 oke defaultValue: 'ocid1.image.oc1.phx.aaaaaaaaypr5r5drojwytghw6e6mvpjsscrnkuwtmqlmvmix7kjb2zcnc7wa'
95-
defaultValue: 'ocid1.image.oc1.phx.aaaaaaaahgrs3zcwrvutjtni557ttrt62uggseijsmqxacr7dym423uaokcq'
95+
defaultValue: 'ocid1.image.oc1.phx.aaaaaaaatkz7laillswel25edlbmq67ino2y2pv6xhp2lml2vzha44ao5gtq'
9696

9797
)
9898
string(name: 'KUBECTL_VERSION',
@@ -196,7 +196,7 @@ pipeline {
196196
)
197197
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
198198
description: '',
199-
defaultValue: '2.1.3'
199+
defaultValue: '2.3.0'
200200
)
201201
string(name: 'PROMETHEUS_CHART_VERSION',
202202
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 = [
@@ -186,7 +186,7 @@ pipeline {
186186
)
187187
string(name: 'MONITORING_EXPORTER_WEBAPP_VERSION',
188188
description: '',
189-
defaultValue: '2.1.2'
189+
defaultValue: '2.3.0'
190190
)
191191
string(name: 'PROMETHEUS_CHART_VERSION',
192192
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: 92 additions & 29 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,13 @@ 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+
if (!isVersionAtLeast(MONITORING_EXPORTER_WEBAPP_VERSION, "2.3.0")) {
231+
logger.info("Monitoting Exporter Version is less than 2.3.0");
232+
servletPath = "com.oracle.wls.exporter.webapp";
233+
} else {
234+
servletPath = servletPath + ((WEBLOGIC_IMAGE_TAG.contains("14.1")
235+
|| WEBLOGIC_IMAGE_TAG.contains("12.")) ? ".javax" : ".jakarta");
236+
}
226237
}
227238

228239
/**
@@ -249,11 +260,19 @@ void testFilterIIncludedKeysFromTopLevel() throws Exception {
249260
void testFilterIIncludedKeysFromSubLevel() throws Exception {
250261
logger.info("Testing filtering only included specific app name in the metrics ");
251262
List<String> checkIncluded = new ArrayList<>();
252-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
263+
// Regular expression pattern to match servletName="ANYTHING.ExporterServlet"
264+
String checkKey1 = "servletName=\"" + servletPath + ".ExporterServlet\"";
265+
checkIncluded.add(checkKey1);
253266
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",
267+
// Regular expression pattern to match servletName="ANYTHING.ExporterServlet"
268+
String checkKey2 = "servletName=\"" + servletPath + ".MainServlet\"";
269+
checkExcluded.add(checkKey2);
270+
271+
String configurationFile = replaceValueInFile(
272+
"ItMonitoringExporterMetricsFiltering/testFilterIIncludedKeysFromSubLevel",
273+
"rest_filter_included_servlet_name.yaml",
274+
"com.oracle.wls.exporter.webapp", servletPath);
275+
replaceConfigurationWithFilter(configurationFile,
257276
checkIncluded, checkExcluded);
258277
}
259278

@@ -266,13 +285,19 @@ void testFilterIIncludedKeysFromSubLevel() throws Exception {
266285
void testFilterIIncludedKeysFromBothLevels() throws Exception {
267286
logger.info("Testing filtering only included specific app name in the metrics ");
268287
List<String> checkIncluded = new ArrayList<>();
269-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
288+
String checkKey1 = "servletName=\"" + servletPath + ".ExporterServlet\"";
289+
checkIncluded.add(checkKey1);
270290
checkIncluded.add("app=\"wls-exporter\"");
271291
List<String> checkExcluded = new ArrayList<>();
272-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
292+
String checkKey2 = "servletName=\"" + servletPath + ".MainServlet\"";
293+
checkExcluded.add(checkKey2);
273294
checkExcluded.add("app=\"myear1\"");
274-
replaceConfigurationWithFilter(RESOURCE_DIR
275-
+ "/exporter/rest_filter_included_webapp_and_servlet_names.yaml",checkIncluded, checkExcluded);
295+
String configurationFile = replaceValueInFile(
296+
"ItMonitoringExporterMetricsFiltering/testFilterIIncludedKeysFromBothLevels",
297+
"rest_filter_included_webapp_and_servlet_names.yaml",
298+
"com.oracle.wls.exporter.webapp", servletPath);
299+
replaceConfigurationWithFilter(configurationFile,
300+
checkIncluded, checkExcluded);
276301
}
277302

278303
/**
@@ -299,11 +324,16 @@ void testFilterExcludedKeysFromTopLevel() throws Exception {
299324
void testFilterExcludedKeysFromSubLevel() throws Exception {
300325
logger.info("Testing filtering only excluded specific app name in the metrics ");
301326
List<String> checkIncluded = new ArrayList<>();
302-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
327+
String checkKey1 = "servletName=\"" + servletPath + ".MainServlet\"";
328+
checkIncluded.add(checkKey1);
303329
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",
330+
String checkKey2 = "servletName=\"" + servletPath + ".ExporterServlet\"";
331+
checkExcluded.add(checkKey2);
332+
String configurationFile = replaceValueInFile(
333+
"ItMonitoringExporterMetricsFiltering/testFilterExcludedKeysFromSubLevel",
334+
"rest_filter_excluded_servlet_name.yaml",
335+
"com.oracle.wls.exporter.webapp", servletPath);
336+
replaceConfigurationWithFilter(configurationFile,
307337
checkIncluded, checkExcluded);
308338
}
309339

@@ -316,13 +346,19 @@ void testFilterExcludedKeysFromSubLevel() throws Exception {
316346
void testFilterExcludedKeysFromBothLevels() throws Exception {
317347
logger.info("Testing filtering only excluded specific app name in the metrics ");
318348
List<String> checkIncluded = new ArrayList<>();
319-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp.ExporterServlet\"");
349+
String checkKey1 = "servletName=\"" + servletPath + ".ExporterServlet\"";
350+
checkIncluded.add(checkKey1);
320351
checkIncluded.add("app=\"myear1\"");
321352
List<String> checkExcluded = new ArrayList<>();
322-
checkExcluded.add("servletName=\"com.oracle.wls.exporter.webapp.MainServlet\"");
353+
String checkKey2 = "servletName=\"" + servletPath + ".MainServlet\"";
354+
checkExcluded.add(checkKey2);
323355
checkExcluded.add("app=\"myear123\"");
324-
replaceConfigurationWithFilter(RESOURCE_DIR
325-
+ "/exporter/rest_filter_excluded_webapp_and_servlet_names.yaml",checkIncluded, checkExcluded);
356+
String configurationFile = replaceValueInFile(
357+
"ItMonitoringExporterMetricsFiltering/testFilterExcludedKeysFromBothLevels",
358+
"rest_filter_excluded_webapp_and_servlet_names.yaml",
359+
"com.oracle.wls.exporter.webapp", servletPath);
360+
replaceConfigurationWithFilter(configurationFile,
361+
checkIncluded, checkExcluded);
326362
}
327363

328364
/**
@@ -336,9 +372,13 @@ void testFilterIncludedTopExcludedKeysSubLevels() throws Exception {
336372
List<String> checkIncluded = new ArrayList<>();
337373
checkIncluded.add("app=\"wls-exporter\"");
338374
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);
375+
checkExcluded.add("servletName=\"" + servletPath + ".ExporterServlet\"");
376+
String configurationFile = replaceValueInFile(
377+
"ItMonitoringExporterMetricsFiltering/testFilterIncludedTopExcludedKeysSubLevels",
378+
"rest_filter_included_webapp_excluded_servlet_name.yaml",
379+
"com.oracle.wls.exporter.webapp", servletPath);
380+
replaceConfigurationWithFilter(configurationFile,
381+
checkIncluded, checkExcluded);
342382
}
343383

344384
/**
@@ -368,17 +408,21 @@ void testFilterIncludedExcludedKeysComboTopLevel() throws Exception {
368408
void testFilterIncludedExcludedKeysComboSubLevel() throws Exception {
369409
logger.info("Testing filtering included and excluded specific app names in the metrics ");
370410
List<String> checkIncluded = new ArrayList<>();
371-
checkIncluded.add("servletName=\"com.oracle.wls.exporter.webapp");
411+
checkIncluded.add("servletName=\"" + servletPath);
372412
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);
413+
checkExcluded.add("servletName=\"" + servletPath + ".ExporterServlet\"");
414+
String configurationFile = replaceValueInFile(
415+
"ItMonitoringExporterMetricsFiltering/testFilterIncludedExcludedKeysComboSubLevel",
416+
"rest_filter_included_excluded_servlet_name.yaml",
417+
"com.oracle.wls.exporter.webapp", servletPath);
418+
replaceConfigurationWithFilter(configurationFile,
419+
checkIncluded, checkExcluded);
376420
}
377421

378422
/**
379-
* Check filtering functionality of monitoring exporter for
380-
* not existed includedKeyValues .
381-
*/
423+
* Check filtering functionality of monitoring exporter for
424+
* not existed includedKeyValues .
425+
*/
382426
@Test
383427
@DisplayName("Test Filtering of the Metrics with includedKeyValues for not existed key of Monitoring Exporter on "
384428
+ " top level.")
@@ -728,17 +772,19 @@ private void replaceConfigurationWithFilter(String configurationFile,
728772
}
729773

730774
private static void verifyMetrics(List<String> checkIncluded, List<String> checkExcluded) {
775+
boolean isRegexInc = false;
776+
boolean isRegexExc = false;
731777
for (String includedString : checkIncluded) {
732778
assertTrue(verifyMonExpAppAccess("wls-exporter/metrics",
733-
includedString,
779+
includedString, isRegexInc,
734780
domain1Uid,
735781
domain1Namespace,
736782
false, cluster1Name),
737783
"monitoring exporter metrics can't filter to included " + includedString);
738784
}
739785
for (String excludedString : checkExcluded) {
740786
assertFalse(verifyMonExpAppAccess("wls-exporter/metrics",
741-
excludedString,
787+
excludedString, isRegexExc,
742788
domain1Uid,
743789
domain1Namespace,
744790
false, cluster1Name),
@@ -781,5 +827,22 @@ private int getTraefikLbNodePort(boolean isHttps) {
781827
-> getServiceNodePort(traefikNamespace, traefikHelmParams.getReleaseName(), isHttps ? "websecure" : "web"),
782828
"Getting web node port for Traefik loadbalancer failed");
783829
}
830+
831+
private static boolean isVersionAtLeast(String version, String minVersion) {
832+
String[] versionParts = version.split("\\.");
833+
String[] minVersionParts = minVersion.split("\\.");
834+
835+
for (int i = 0; i < 3; i++) {
836+
int verPart = Integer.parseInt(versionParts[i]); // Convert to integer
837+
int minVPart = Integer.parseInt(minVersionParts[i]);
838+
839+
if (verPart > minVPart) {
840+
return true;
841+
} else if (verPart < minVPart) {
842+
return false;
843+
}
844+
}
845+
return true; // Versions are equal
846+
}
784847
}
785848

0 commit comments

Comments
 (0)