Skip to content

Commit 6887f05

Browse files
committed
Merge branch 'monexp2' into 'main'
Converted ItMonitoringExporterWebApp and ItMonitoringExporterSamples to be run in internal OKE See merge request weblogic-cloud/weblogic-kubernetes-operator!4568
2 parents 887414d + 09cf299 commit 6887f05

File tree

4 files changed

+68
-20
lines changed

4 files changed

+68
-20
lines changed

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,6 @@ private void installPrometheusGrafana(String promChartVersion,
544544
}
545545
logger.info("Grafana is running");
546546
// create ingress rules with non-tls host routing, tls host routing and path routing for Traefik
547-
/*
548-
createTraefikIngressRoutingRulesForMonitoring(monitoringNS, prometheusReleaseName + "-server",
549-
"traefik/traefik-ingress-rules-monitoring.yaml");
550-
551-
*/
552547

553548
createIngressPathRouting(monitoringNS, "/api",
554549
prometheusReleaseName + "-server", 80, ingressClassName);
@@ -563,17 +558,7 @@ public void tearDownAll() {
563558

564559
if (traefikHelmParams != null) {
565560
logger.info("Uninstalling Traefik");
566-
/*
567-
Path dstFileProm = Paths.get(TestConstants.RESULTS_ROOT,
568-
monitoringNS,
569-
prometheusReleaseName + "-server",
570-
"traefik", "traefik-ingress-rules-monitoring.yaml");
571-
deleteTraefikIngressRoutingRules(dstFileProm);
572-
Path dstFileDomain = Paths.get(TestConstants.RESULTS_ROOT,
573-
domain1Namespace, domain1Uid, "traefik-ingress-rules-exporter.yaml");
574-
deleteTraefikIngressRoutingRules(dstFileDomain);
575-
576-
*/
561+
577562
assertThat(uninstallTraefik(traefikHelmParams))
578563
.as("Test uninstall traefik returns true")
579564
.withFailMessage("uninstallTraefik() did not return true")

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
5252
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
5353
import static oracle.weblogic.kubernetes.TestConstants.OKD;
54+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER_PRIVATEIP;
5455
import static oracle.weblogic.kubernetes.TestConstants.PROMETHEUS_CHART_VERSION;
5556
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
5657
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
@@ -68,8 +69,10 @@
6869
import static oracle.weblogic.kubernetes.assertions.TestAssertions.isPodReady;
6970
import static oracle.weblogic.kubernetes.assertions.TestAssertions.searchPodLogForKey;
7071
import static oracle.weblogic.kubernetes.assertions.impl.Kubernetes.listPods;
72+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressPathRouting;
7173
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createTestWebAppWarFile;
7274
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
75+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
7376
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.scaleAndVerifyCluster;
7477
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
7578
import static oracle.weblogic.kubernetes.utils.ImageUtils.createImageAndPushToRepo;
@@ -105,7 +108,7 @@
105108
* Verify WebLogic metrics can be accessed via Prometheus
106109
*/
107110
@DisplayName("Verify end to end sample, provided in the Monitoring Exporter github project")
108-
@Tag("oke-sequential")
111+
@Tag("oke-gate")
109112
@Tag("kind-parallel")
110113
@Tag("okd-wls-mrg")
111114
@IntegrationTest
@@ -129,6 +132,7 @@ class ItMonitoringExporterSamples {
129132
private static String webhookNS = null;
130133
PrometheusParams promHelmParams = null;
131134
GrafanaParams grafanaHelmParams = null;
135+
private static String ingressIP = null;
132136

133137
private static V1Service webhookService = null;
134138
private static V1Deployment webhookDepl = null;
@@ -222,6 +226,8 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
222226
// install and verify NGINX
223227
nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0);
224228
String nginxServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
229+
ingressIP = getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace) != null
230+
? getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace) : K8S_NODEPORT_HOST;
225231
logger.info("NGINX service name: {0}", nginxServiceName);
226232
nodeportshttp = getServiceNodePort(nginxNamespace, nginxServiceName, "http");
227233
nodeportshttps = getServiceNodePort(nginxNamespace, nginxServiceName, "https");
@@ -270,7 +276,11 @@ void testEndToEndViaChart() throws Exception {
270276
= createIngressForDomainAndVerify(domain2Uid, domain2Namespace, 0, clusterNameMsPortMap,
271277
false, nginxHelmParams.getIngressClassName(), false, 0);
272278
logger.info("verify access to Monitoring Exporter");
273-
verifyMonExpAppAccessThroughNginx(ingressHost2List.get(0), managedServersCount, nodeportshttp);
279+
if (OKE_CLUSTER_PRIVATEIP) {
280+
verifyMonExpAppAccessThroughNginx(ingressHost2List.get(0), managedServersCount, ingressIP);
281+
} else {
282+
verifyMonExpAppAccessThroughNginx(ingressHost2List.get(0), managedServersCount, nodeportshttp);
283+
}
274284
} else {
275285
String clusterService = domain2Uid + "-cluster-cluster-1";
276286
String hostName = createRouteForOKD(clusterService, domain2Namespace);
@@ -374,10 +384,16 @@ private void installPrometheusGrafana(String promChartVersion,
374384
host = "[" + host + "]";
375385
}
376386
hostPortPrometheus = host + ":" + nodeportPrometheus;
387+
if (OKE_CLUSTER_PRIVATEIP) {
388+
hostPortPrometheus = ingressIP;
389+
}
377390
if (OKD) {
378391
hostPortPrometheus = createRouteForOKD("prometheus" + releaseSuffix
379392
+ "-service", monitoringNS) + ":" + nodeportPrometheus;
380393
}
394+
String ingressClassName = nginxHelmParams.getIngressClassName();
395+
createIngressPathRouting(monitoringNS, "/api",
396+
prometheusReleaseName + "-server", 80, ingressClassName);
381397
}
382398
//if prometheus already installed change CM for specified domain
383399
if (!prometheusRegexValue.equals(prometheusDomainRegexValue)) {

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import static oracle.weblogic.kubernetes.TestConstants.GRAFANA_CHART_VERSION;
4646
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
4747
import static oracle.weblogic.kubernetes.TestConstants.OKD;
48+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER_PRIVATEIP;
4849
import static oracle.weblogic.kubernetes.TestConstants.PROMETHEUS_CHART_VERSION;
4950
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
5051
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -58,6 +59,8 @@
5859
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.copyFileToPod;
5960
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.deleteNamespace;
6061
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.exec;
62+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressPathRouting;
63+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
6164
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.createIngressForDomainAndVerify;
6265
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyNginx;
6366
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.checkMetricsViaPrometheus;
@@ -91,7 +94,7 @@
9194
@DisplayName("Verify WebLogic Metric is processed as expected by MonitoringExporter WebApp via Prometheus and Grafana")
9295
@IntegrationTest
9396
@Tag("olcne-mrg")
94-
@Tag("oke-sequential")
97+
@Tag("oke-gate")
9598
@Tag("kind-sequential")
9699
@Tag("okd-wls-mrg")
97100
class ItMonitoringExporterWebApp {
@@ -108,6 +111,7 @@ class ItMonitoringExporterWebApp {
108111
private static int nodeportshttp = 0;
109112
private static int nodeportshttps = 0;
110113
private static List<String> ingressHost1List = null;
114+
private static String ingressIP = null;
111115

112116
private static String monitoringNS = null;
113117
PrometheusParams promHelmParams = null;
@@ -193,6 +197,8 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
193197
nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0);
194198

195199
String nginxServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
200+
ingressIP = getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace) != null
201+
? getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace) : K8S_NODEPORT_HOST;
196202
logger.info("NGINX service name: {0}", nginxServiceName);
197203
nodeportshttp = getServiceNodePort(nginxNamespace, nginxServiceName, "http");
198204
nodeportshttps = getServiceNodePort(nginxNamespace, nginxServiceName, "https");
@@ -210,6 +216,9 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
210216
host = "[" + host + "]";
211217
}
212218
exporterUrl = String.format("http://%s:%s/wls-exporter/", host, nodeportshttp);
219+
if (OKE_CLUSTER_PRIVATEIP) {
220+
exporterUrl = String.format("http://%s/wls-exporter/", ingressIP);
221+
}
213222
HashMap<String, String> labels = new HashMap<>();
214223
labels.put("app", "monitoring");
215224
labels.put("weblogic.domainUid", "test");
@@ -249,7 +258,11 @@ void testBasicFunctionality() throws Exception {
249258
ingressHost1List
250259
= createIngressForDomainAndVerify(domain1Uid, domain1Namespace, 0, clusterNameMsPortMap,
251260
false, ingressClassName, false, 0);
252-
verifyMonExpAppAccessThroughNginx(ingressHost1List.get(0), 1, nodeportshttp);
261+
if (OKE_CLUSTER_PRIVATEIP) {
262+
verifyMonExpAppAccessThroughNginx(ingressHost1List.get(0), 1, ingressIP);
263+
} else {
264+
verifyMonExpAppAccessThroughNginx(ingressHost1List.get(0), 1, nodeportshttp);
265+
}
253266
// Need to expose the admin server external service to access the console in OKD cluster only
254267
} else {
255268
String hostName = createRouteForOKD(clusterService, domain1Namespace);
@@ -425,10 +438,16 @@ private void installPrometheusGrafana(String promChartVersion,
425438
host = "[" + host + "]";
426439
}
427440
hostPortPrometheus = host + ":" + nodeportPrometheus;
441+
if (OKE_CLUSTER_PRIVATEIP) {
442+
hostPortPrometheus = ingressIP;
443+
}
428444
if (OKD) {
429445
hostPortPrometheus = createRouteForOKD("prometheus" + releaseSuffix
430446
+ "-service", monitoringNS) + ":" + nodeportPrometheus;
431447
}
448+
String ingressClassName = nginxHelmParams.getIngressClassName();
449+
createIngressPathRouting(monitoringNS, "/api",
450+
prometheusReleaseName + "-server", 80, ingressClassName);
432451
}
433452
//if prometheus already installed change CM for specified domain
434453
if (!prometheusRegexValue.equals(prometheusDomainRegexValue)) {

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,34 @@ public static void verifyMonExpAppAccessThroughNginx(String nginxHost, int repli
11511151
+ "from all managed servers in the domain via http");
11521152
}
11531153

1154+
/**
1155+
* Verify the monitoring exporter app can be accessed from all managed servers in the domain through NGINX.
1156+
*
1157+
* @param nginxHost nginx host name
1158+
* @param replicaCount number of managed servers
1159+
* @param hostPort host:port combo or host string
1160+
*/
1161+
public static void verifyMonExpAppAccessThroughNginx(String nginxHost, int replicaCount, String hostPort) {
1162+
1163+
List<String> managedServerNames = new ArrayList<>();
1164+
for (int i = 1; i <= replicaCount; i++) {
1165+
managedServerNames.add(MANAGED_SERVER_NAME_BASE + i);
1166+
}
1167+
1168+
// check that NGINX can access the sample apps from all managed servers in the domain
1169+
String curlCmd =
1170+
String.format("curl -g --silent --show-error --noproxy '*' -H 'host: %s' http://%s:%s@%s/wls-exporter/metrics",
1171+
nginxHost,
1172+
ADMIN_USERNAME_DEFAULT,
1173+
ADMIN_PASSWORD_DEFAULT,
1174+
hostPort);
1175+
testUntil(withLongRetryPolicy,
1176+
callTestWebAppAndCheckForServerNameInResponse(curlCmd, managedServerNames, 50),
1177+
logger,
1178+
"Verify NGINX can access the monitoring exporter metrics \n"
1179+
+ "from all managed servers in the domain via http");
1180+
}
1181+
11541182
/**
11551183
* Verify the monitoring exporter app can be accessed from all managed servers in the domain through NGINX.
11561184
*

0 commit comments

Comments
 (0)