Skip to content

Commit 906b5d9

Browse files
authored
Fix for ItMultiDomainModelsWithLoadBalancer and ItMonitoringExporter tests (#2844)
* Fix for ItMultiDomainModelsWithLoadBalancer and ItMonitoringExporter tests
1 parent 7c8b9eb commit 906b5d9

File tree

2 files changed

+16
-53
lines changed

2 files changed

+16
-53
lines changed

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

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@
117117
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
118118
import static oracle.weblogic.kubernetes.actions.ActionConstants.WLS;
119119
import static oracle.weblogic.kubernetes.actions.TestActions.deleteImage;
120+
import static oracle.weblogic.kubernetes.actions.TestActions.deleteIngress;
120121
import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolume;
121122
import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolumeClaim;
122123
import static oracle.weblogic.kubernetes.actions.TestActions.deleteSecret;
123124
import static oracle.weblogic.kubernetes.actions.TestActions.getPod;
124125
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
126+
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
125127
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallNginx;
126128
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.copyFileToPod;
127129
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.deleteNamespace;
@@ -150,7 +152,6 @@
150152
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.editPrometheusCM;
151153
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.installAndVerifyGrafana;
152154
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.installAndVerifyPrometheus;
153-
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.searchForKey;
154155
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
155156
import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResource;
156157
import static oracle.weblogic.kubernetes.utils.PersistentVolumeUtils.createPVPVCAndVerify;
@@ -358,8 +359,10 @@ void testEndToEndViaChart() throws Exception {
358359
logger.info("Create wdt domain and verify that it's running");
359360
createAndVerifyDomain(wdtImage, domain2Uid, domain2Namespace, "Image", replicaCount, false);
360361
String ingressClassName = nginxHelmParams.getIngressClassName();
362+
Map<String, Integer> clusterNameMsPortMap1 = new HashMap<>();
363+
clusterNameMsPortMap1.put(cluster1Name, managedServerPort);
361364
ingressHost2List
362-
= createIngressForDomainAndVerify(domain2Uid, domain2Namespace, 0, clusterNameMsPortMap,
365+
= createIngressForDomainAndVerify(domain2Uid, domain2Namespace, 0, clusterNameMsPortMap1,
363366
false, ingressClassName, false, 0);
364367
logger.info("Installing Prometheus and Grafana");
365368
installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION,
@@ -612,6 +615,12 @@ void testBasicFunctionality() throws Exception {
612615
replaceMetricsDomainQualifierTrueConfiguration();
613616
logger.info("Testing replace with no restPort configuration");
614617
replaceMetricsNoRestPortConfiguration();
618+
619+
//cleanup
620+
List<String> ingresses = listIngresses(domain4Namespace);
621+
for (String ingress : ingresses) {
622+
deleteIngress(ingress, domain4Namespace);
623+
}
615624
}
616625

617626

@@ -814,58 +823,11 @@ private void installPrometheusGrafana(String promChartVersion,
814823
if (grafanaHelmParams == null) {
815824
//logger.info("Node Port for Grafana is " + nodeportgrafana);
816825
grafanaHelmParams = installAndVerifyGrafana("grafana",
817-
monitoringNS,
818-
monitoringExporterEndToEndDir + "/grafana/values.yaml",
819-
grafanaChartVersion);
826+
monitoringNS,
827+
monitoringExporterEndToEndDir + "/grafana/values.yaml",
828+
grafanaChartVersion);
820829
assertNotNull(grafanaHelmParams, "Grafana failed to install");
821-
int nodeportgrafana = grafanaHelmParams.getNodePort();
822-
//wait until it starts dashboard
823-
String curlCmd = String.format("curl -v -H 'Content-Type: application/json' "
824-
+ " -X GET http://admin:12345678@%s:%s/api/dashboards",
825-
K8S_NODEPORT_HOST, nodeportgrafana);
826-
withStandardRetryPolicy
827-
.conditionEvaluationListener(
828-
condition -> logger.info("Check access to grafana dashboard "
829-
+ "(elapsed time {0}ms, remaining time {1}ms)",
830-
condition.getElapsedTimeInMS(),
831-
condition.getRemainingTimeInMS()))
832-
.until(assertDoesNotThrow(() -> searchForKey(curlCmd, "grafana"),
833-
String.format("Check access to grafana dashboard"
834-
)));
835-
logger.info("installing grafana dashboard");
836-
// url
837-
String curlCmd0 =
838-
String.format("curl -v -H 'Content-Type: application/json' -H \"Content-Type: application/json\""
839-
+ " -X POST http://admin:12345678@%s:%s/api/datasources/"
840-
+ " --data-binary @%sgrafana/datasource.json",
841-
K8S_NODEPORT_HOST, nodeportgrafana, monitoringExporterEndToEndDir);
842-
843-
logger.info("Executing Curl cmd {0}", curlCmd);
844-
assertDoesNotThrow(() -> ExecCommand.exec(curlCmd0));
845-
846-
String curlCmd1 =
847-
String.format("curl -v -H 'Content-Type: application/json' -H \"Content-Type: application/json\""
848-
+ " -X POST http://admin:12345678@%s:%s/api/dashboards/db/"
849-
+ " --data-binary @%sgrafana/dashboard.json",
850-
K8S_NODEPORT_HOST, nodeportgrafana, monitoringExporterEndToEndDir);
851-
logger.info("Executing Curl cmd {0}", curlCmd1);
852-
assertDoesNotThrow(() -> ExecCommand.exec(curlCmd1));
853-
854-
String curlCmd2 = String.format("curl -v -H 'Content-Type: application/json' "
855-
+ " -X GET http://admin:12345678@%s:%s/api/dashboards/db/weblogic-server-dashboard",
856-
K8S_NODEPORT_HOST, nodeportgrafana);
857-
withStandardRetryPolicy
858-
.conditionEvaluationListener(
859-
condition -> logger.info("Check grafana dashboard metric against expected {0} "
860-
+ "(elapsed time {2}ms, remaining time {3}ms)",
861-
"wls_jvm_uptime",
862-
condition.getElapsedTimeInMS(),
863-
condition.getRemainingTimeInMS()))
864-
.until(assertDoesNotThrow(() -> searchForKey(curlCmd2, "wls_jvm_uptime"),
865-
String.format("Check grafana dashboard wls against expected %s",
866-
"wls_jvm_uptime")));
867830
}
868-
logger.info("Grafana is running");
869831
}
870832

871833
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
257257
clusterNameMsPortMap.put(CLUSTER_NAME_PREFIX + i, MANAGED_SERVER_PORT);
258258
}
259259
logger.info("Creating ingress for domain {0} in namespace {1}", domainUid, domainNamespace);
260+
String ingressClassName = nginxHelmParams.getIngressClassName();
260261
createIngressForDomainAndVerify(domainUid, domainNamespace, nodeportshttp, clusterNameMsPortMap, true,
261-
true, ADMIN_SERVER_PORT);
262+
ingressClassName, true, ADMIN_SERVER_PORT);
262263
}
263264

264265
}

0 commit comments

Comments
 (0)