Skip to content

Commit d5751c2

Browse files
vanajamukkararjeberhard
authored andcommitted
backporting podman conversion changes in ItMiiDomain and ItMiiDynamicUpdatePart3
1 parent 013cc79 commit d5751c2

File tree

4 files changed

+109
-37
lines changed

4 files changed

+109
-37
lines changed

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

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_PASSWORD;
6868
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
6969
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_USERNAME;
70-
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
70+
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTPS_HOSTPORT;
71+
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
7172
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER;
7273
import static oracle.weblogic.kubernetes.TestConstants.WLS_DOMAIN_TYPE;
7374
import static oracle.weblogic.kubernetes.actions.ActionConstants.ARCHIVE_DIR;
@@ -100,13 +101,13 @@
100101
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
101102
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkClusterReplicaCountMatches;
102103
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
104+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
103105
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
104106
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
105107
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isAppInServerPodReady;
106108
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.startPortForwardProcess;
107109
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.stopPortForwardProcess;
108110
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
109-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCredentials;
110111
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withLongRetryPolicy;
111112
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withQuickRetryPolicy;
112113
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
@@ -204,6 +205,8 @@ void testCreateMiiDomain() {
204205
final String hostName = "localhost";
205206
final int adminServerPort = 7001;
206207
final int adminServerSecurePort = 7008;
208+
String httpHostHeader = "";
209+
String httpsHostHeader = "";
207210

208211
// Create the repo secret to pull the image
209212
// this secret is used only for non-kind cluster
@@ -287,6 +290,18 @@ void testCreateMiiDomain() {
287290
"Could not get the default-secure external service node port");
288291
logger.info("Found the administration service nodePort {0}", sslNodePort);
289292
String hostAndPort = getHostAndPort(adminSvcSslPortExtHost, sslNodePort);
293+
// create ingress for admin service
294+
// use traefik LB for kind cluster with ingress host header in url
295+
String headers = "";
296+
if (TestConstants.KIND_CLUSTER
297+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
298+
httpHostHeader = createIngressHostRouting(domainNamespace, domainUid,
299+
"admin-server", adminServerPort);
300+
httpsHostHeader = createIngressHostRouting(domainNamespace, domainUid,
301+
"admin-server", adminServerSecurePort);
302+
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTPS_HOSTPORT;
303+
headers = " -H 'host: " + httpsHostHeader + "' ";
304+
}
290305

291306
final String resourcePath = "/weblogic/ready";
292307
if (OKE_CLUSTER) {
@@ -298,7 +313,7 @@ void testCreateMiiDomain() {
298313
adminServerPodName);
299314
} else {
300315
String curlCmd = "curl -skg --show-error --noproxy '*' "
301-
+ " https://" + hostAndPort
316+
+ headers + " https://" + hostAndPort
302317
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
303318
logger.info("Executing default-admin nodeport curl command {0}", curlCmd);
304319
assertTrue(callWebAppAndWaitTillReady(curlCmd, 10));
@@ -311,28 +326,27 @@ void testCreateMiiDomain() {
311326
"Could not get the default external service node port");
312327
logger.info("Found the default service nodePort {0}", nodePort);
313328
hostAndPort = getHostAndPort(adminSvcExtHost, nodePort);
314-
315-
if (!WEBLOGIC_SLIM) {
316-
if (OKE_CLUSTER) {
317-
testUntil(
318-
isAppInServerPodReady(domainNamespace,
319-
adminServerPodName, 7001, resourcePath, ""),
320-
logger, "verify EM console access {0} in server {1}",
321-
resourcePath,
322-
adminServerPodName);
323-
} else {
324-
String curlCmd2 = "curl -skg --show-error --noproxy '*' "
325-
+ " http://" + hostAndPort
326-
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
327-
logger.info("Executing default nodeport curl command {0}", curlCmd2);
328-
assertTrue(callWebAppAndWaitTillReady(curlCmd2, 5));
329-
}
330-
logger.info("ready app is accessible thru default service");
329+
if (TestConstants.KIND_CLUSTER
330+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
331+
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
332+
headers = " -H 'host: " + httpHostHeader + "' ";
333+
}
334+
if (OKE_CLUSTER) {
335+
testUntil(
336+
isAppInServerPodReady(domainNamespace,
337+
adminServerPodName, 7001, resourcePath, ""),
338+
logger, "verify EM console access {0} in server {1}",
339+
resourcePath,
340+
adminServerPodName);
331341
} else {
332-
logger.info("Checking Rest API management console in WebLogic slim image");
333-
verifyCredentials(7001, adminServerPodName, domainNamespace,
334-
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, true);
342+
String curlCmd2 = "curl -skg --show-error --noproxy '*' "
343+
+ headers + " http://" + hostAndPort
344+
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
345+
logger.info("Executing default nodeport curl command {0}", curlCmd2);
346+
assertTrue(callWebAppAndWaitTillReady(curlCmd2, 5));
335347
}
348+
logger.info("ready app is accessible thru default service");
349+
336350

337351
// Test that `kubectl port-foward` is able to forward a local port to default channel port (7001 in this test)
338352
// and default secure channel port (7002 in this test)

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

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import io.kubernetes.client.openapi.models.V1Pod;
1515
import oracle.weblogic.domain.DomainCondition;
1616
import oracle.weblogic.domain.DomainResource;
17+
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
18+
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
1719
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
1820
import oracle.weblogic.kubernetes.annotations.Namespaces;
1921
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -24,8 +26,12 @@
2426
import org.junit.jupiter.api.Tag;
2527
import org.junit.jupiter.api.Test;
2628

29+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
30+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
2731
import static oracle.weblogic.kubernetes.TestConstants.MII_DYNAMIC_UPDATE_EXPECTED_ERROR_MSG;
32+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
2833
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME;
34+
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
2935
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
3036
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_VERSION;
3137
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -45,7 +51,10 @@
4551
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodIntrospectVersionUpdated;
4652
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodsNotRolled;
4753
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkSystemResourceConfig;
54+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkSystemResourceConfigViaAdminPod;
55+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
4856
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
57+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifySystemResourceConfiguration;
4958
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
5059
import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName;
5160
import static oracle.weblogic.kubernetes.utils.K8sEvents.DOMAIN_FAILED;
@@ -80,6 +89,7 @@ class ItMiiDynamicUpdatePart3 {
8089
public static Path pathToChangReadsYaml = null;
8190
static LoggingFacade logger = null;
8291
private static String operatorPodName = null;
92+
private static String httpHostHeader = null;
8393

8494
/**
8595
* Install Operator.
@@ -318,15 +328,49 @@ void testMiiChangeDataSourceParameterWithCommitUpdateAndRoll() {
318328

319329
verifyPodIntrospectVersionUpdated(pods.keySet(), introspectVersion, helper.domainNamespace);
320330

331+
321332
// check datasource configuration using REST api
322-
int adminServiceNodePort
323-
= getServiceNodePort(helper.domainNamespace, getExternalServicePodName(helper.adminServerPodName), "default");
324-
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
325-
assertTrue(checkSystemResourceConfig(helper.adminSvcExtHost, adminServiceNodePort,
326-
"JDBCSystemResources/TestDataSource2/JDBCResource/JDBCDataSourceParams",
327-
"jdbc\\/TestDataSource2-2"), "JDBCSystemResource JNDIName not found");
333+
if (OKE_CLUSTER) {
334+
assertTrue(checkSystemResourceConfigViaAdminPod(helper.adminServerPodName, helper.domainNamespace,
335+
"JDBCSystemResources/TestDataSource2/JDBCResource/JDBCDataSourceParams",
336+
"jdbc\\/TestDataSource2-2"), "JDBCSystemResource JNDIName not found");
337+
} else {
338+
int adminServiceNodePort
339+
= getServiceNodePort(helper.domainNamespace, getExternalServicePodName(helper.adminServerPodName), "default");
340+
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
341+
342+
// create ingress for admin service
343+
// use traefik LB for kind cluster with ingress host header in url
344+
if (TestConstants.KIND_CLUSTER
345+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
346+
httpHostHeader = createIngressHostRouting(helper.domainNamespace, domainUid,
347+
helper.adminServerName, 7001);
348+
StringBuffer curlString = new StringBuffer("curl -g --user ");
349+
curlString.append(ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT)
350+
.append(" --noproxy '*' "
351+
+ " -H 'host: " + httpHostHeader + "' " + " http://" + "localhost:"
352+
+ TRAEFIK_INGRESS_HTTP_HOSTPORT)
353+
.append("/management/weblogic/latest/domainConfig")
354+
.append("/")
355+
.append("JDBCSystemResources/TestDataSource2/JDBCResource/JDBCDataSourceParams")
356+
.append("/");
357+
358+
logger.info("curl command {0}", new String(curlString));
359+
360+
assertTrue(Command
361+
.withParams(new CommandParams()
362+
.command(curlString.toString()))
363+
.executeAndVerify("jdbc\\/TestDataSource2-2"), "JDBCSystemResource JNDIName not found");
364+
} else {
365+
assertTrue(checkSystemResourceConfig(helper.adminSvcExtHost, adminServiceNodePort,
366+
"JDBCSystemResources/TestDataSource2/JDBCResource/JDBCDataSourceParams",
367+
"jdbc\\/TestDataSource2-2"), "JDBCSystemResource JNDIName not found");
368+
369+
}
370+
}
328371
logger.info("JDBCSystemResource configuration found");
329372

373+
330374
// check that the domain status condition contains the correct type and expected reason
331375
logger.info("verifying the domain status condition contains the correct type and expected status");
332376
helper.verifyDomainStatusConditionNoErrorMsg("Completed", "True");
@@ -363,13 +407,27 @@ void testMiiChangeDataSourceParameterWithCommitUpdateAndRoll() {
363407
verifyPodIntrospectVersionUpdated(pods.keySet(), introspectVersion, helper.domainNamespace);
364408

365409
// check datasource configuration is deleted using REST api
366-
adminServiceNodePort
367-
= getServiceNodePort(helper.domainNamespace, getExternalServicePodName(helper.adminServerPodName), "default");
368-
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
369-
assertFalse(checkSystemResourceConfig(helper.adminSvcExtHost, adminServiceNodePort, "JDBCSystemResources",
370-
"TestDataSource2"), "Found JDBCSystemResource datasource, should be deleted");
410+
if (OKE_CLUSTER) {
411+
assertFalse(checkSystemResourceConfigViaAdminPod(helper.adminServerPodName, helper.domainNamespace,
412+
"JDBCSystemResources",
413+
"TestDataSource2"), "Found JDBCSystemResource datasource, should be deleted");
414+
} else {
415+
int adminServiceNodePort
416+
= getServiceNodePort(helper.domainNamespace, getExternalServicePodName(helper.adminServerPodName), "default");
417+
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
418+
if (TestConstants.KIND_CLUSTER
419+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
420+
assertFalse(checkSystemResourceConfig(helper.adminSvcExtHost, adminServiceNodePort, "JDBCSystemResources",
421+
"TestDataSource2"), "Found JDBCSystemResource datasource, should be deleted");
422+
} else {
423+
verifySystemResourceConfiguration(null, adminServiceNodePort,
424+
"JDBCSystemResources", "TestDataSource2", "404", httpHostHeader);
425+
}
426+
}
371427
logger.info("JDBCSystemResource Datasource is deleted");
372428

429+
430+
373431
// check that the domain status condition contains the correct type and expected status
374432
logger.info("verifying the domain status condition contains the correct type and expected status");
375433
helper.verifyDomainStatusConditionNoErrorMsg("Completed", "True");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ private static String readRuntimeResource(String adminSvcExtHost, String domainN
10821082
int port = getServicePort(domainNamespace, adminServerPodName, "internal-t3");
10831083
String domainName = adminServerPodName.split("-" + ADMIN_SERVER_NAME_BASE)[0];
10841084
String serviceName = ADMIN_SERVER_NAME_BASE;
1085-
String ingressName = domainNamespace + "-" + domainName + "-" + serviceName;
1085+
String ingressName = domainNamespace + "-" + domainName + "-" + serviceName + "-" + port;
10861086
String hostHeader = domainNamespace + "." + domainName + "." + serviceName;;
10871087
Optional<String> ingressFound;
10881088
try {
@@ -1256,7 +1256,7 @@ public static boolean checkWeblogicMBean(String adminSvcExtHost,
12561256
int port = getServicePort(domainNamespace, adminServerPodName, "internal-t3");
12571257
String domainName = adminServerPodName.split("-" + ADMIN_SERVER_NAME_BASE)[0];
12581258
String serviceName = ADMIN_SERVER_NAME_BASE;
1259-
String ingressName = domainNamespace + "-" + domainName + "-" + serviceName;
1259+
String ingressName = domainNamespace + "-" + domainName + "-" + serviceName + "-" + port;
12601260
String hostHeader = domainNamespace + "." + domainName + "." + serviceName;;
12611261
Optional<String> ingressFound;
12621262
try {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2365,7 +2365,7 @@ public static String createIngressHostRouting(String domainNamespace, String dom
23652365
.paths(Collections.singletonList(httpIngressPath)));
23662366
ingressRules.add(ingressRule);
23672367

2368-
String ingressName = domainNamespace + "-" + domainUid + "-" + serviceName;
2368+
String ingressName = domainNamespace + "-" + domainUid + "-" + serviceName + '-' + port;
23692369
assertDoesNotThrow(() -> createIngress(ingressName, domainNamespace, null,
23702370
Files.readString(INGRESS_CLASS_FILE_NAME), ingressRules, null));
23712371

0 commit comments

Comments
 (0)