Skip to content

Commit 815e129

Browse files
xiancaorjeberhard
authored andcommitted
convert ItMultiDomainModelsScale.java runnable for podman
1 parent 377dc5c commit 815e129

File tree

4 files changed

+89
-34
lines changed

4 files changed

+89
-34
lines changed

Jenkinsfile.podman

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ nodes:
392392
hostPort: 2480
393393
- containerPort: 32490
394394
hostPort: 2490
395+
- containerPort: 30511
396+
hostPort: 1511
395397
extraMounts:
396398
- hostPath: ${pv_root}
397399
containerPath: ${pv_root}

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

Lines changed: 84 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, 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;
55

6+
import java.nio.file.Files;
67
import java.nio.file.Path;
78
import java.util.ArrayList;
89
import java.util.Collections;
910
import java.util.HashMap;
1011
import java.util.List;
1112
import java.util.Map;
13+
import java.util.Optional;
1214

1315
import io.kubernetes.client.openapi.models.V1EnvVar;
1416
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
@@ -41,14 +43,19 @@
4143
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
4244
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
4345
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
46+
import static oracle.weblogic.kubernetes.TestConstants.INGRESS_CLASS_FILE_NAME;
4447
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
4548
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
4649
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
4750
import static oracle.weblogic.kubernetes.TestConstants.OKD;
51+
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_EXTERNAL_REST_HTTPSPORT;
4852
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
53+
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
4954
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
5055
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
5156
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
57+
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER;
58+
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER_DEFAULT;
5259
import static oracle.weblogic.kubernetes.TestConstants.WLS_DOMAIN_TYPE;
5360
import static oracle.weblogic.kubernetes.actions.ActionConstants.ARCHIVE_DIR;
5461
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -57,13 +64,17 @@
5764
import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource;
5865
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
5966
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
67+
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
6068
import static oracle.weblogic.kubernetes.actions.TestActions.startDomain;
6169
import static oracle.weblogic.kubernetes.assertions.TestAssertions.adminNodePortAccessible;
6270
import static oracle.weblogic.kubernetes.assertions.TestAssertions.doesDomainExist;
6371
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
6472
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminConsoleAccessible;
73+
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminServerRESTAccess;
6574
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
6675
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
76+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
77+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
6778
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
6879
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.scaleAndVerifyCluster;
6980
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.startPortForwardProcess;
@@ -111,6 +122,7 @@ class ItMultiDomainModelsScale {
111122

112123
// domain constants
113124
private static final int NUMBER_OF_CLUSTERS_MIIDOMAIN = 2;
125+
private static final String adminServerName = "admin-server";
114126
private static final String CLUSTER_NAME_PREFIX = "cluster-";
115127
private static final int MANAGED_SERVER_PORT = 8001;
116128
private static final int ADMIN_SERVER_PORT = 7001;
@@ -131,14 +143,14 @@ class ItMultiDomainModelsScale {
131143
private static String opServiceAccount = null;
132144
private static NginxParams nginxHelmParams = null;
133145
private static int nodeportshttp = 0;
134-
private static int externalRestHttpsPort = 0;
135146
private static LoggingFacade logger = null;
136147
private static String miiDomainNamespace = null;
137148
private static String domainInImageNamespace = null;
138149
private static String domainOnPVNamespace = null;
139150
private static String miiImage = null;
140151
private static String encryptionSecretName = "encryptionsecret";
141152
private String curlCmd = null;
153+
private static String hostHeader = null;
142154

143155
/**
144156
* Install operator and NGINX.
@@ -178,11 +190,9 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
178190
miiImage = createAndPushMiiImage();
179191

180192
// install and verify operator with REST API
181-
installAndVerifyOperator(opNamespace, opServiceAccount, true, 0,
193+
installAndVerifyOperator(opNamespace, opServiceAccount, true, OPERATOR_EXTERNAL_REST_HTTPSPORT,
182194
miiDomainNamespace, domainOnPVNamespace, domainInImageNamespace);
183195

184-
externalRestHttpsPort = getServiceNodePort(opNamespace, "external-weblogic-operator-svc");
185-
186196
// This test uses the operator restAPI to scale the domain. To do this in OKD cluster,
187197
// we need to expose the external service as route and set tls termination to passthrough
188198
logger.info("Create a route for the operator external service - only for OKD");
@@ -192,12 +202,17 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
192202
setTlsTerminationForRoute("external-weblogic-operator-svc", opNamespace);
193203

194204
if (!OKD) {
195-
// install and verify NGINX
196-
nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0);
197-
String nginxServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
198-
logger.info("NGINX service name: {0}", nginxServiceName);
199-
nodeportshttp = getServiceNodePort(nginxNamespace, nginxServiceName, "http");
200-
logger.info("NGINX http node port: {0}", nodeportshttp);
205+
if (WLSIMG_BUILDER.equals(WLSIMG_BUILDER_DEFAULT)) {
206+
// install and verify NGINX
207+
nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0);
208+
String nginxServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
209+
logger.info("NGINX service name: {0}", nginxServiceName);
210+
nodeportshttp = getServiceNodePort(nginxNamespace, nginxServiceName, "http");
211+
logger.info("NGINX http node port: {0}", nodeportshttp);
212+
} else {
213+
// if not using docker, use pre-installed Traefik controller
214+
nodeportshttp = TRAEFIK_INGRESS_HTTP_HOSTPORT;
215+
}
201216
}
202217
}
203218

@@ -247,11 +262,16 @@ void testScaleClustersByPatchingClusterResource(String domainType) {
247262
numberOfServers, replicaCount, curlCmd, managedServersBeforeScale);
248263
}
249264

250-
// verify admin console login using admin node port
251-
verifyAdminConsoleLoginUsingAdminNodePort(domainUid, domainNamespace);
252-
253-
// verify admin console login using ingress controller
254-
verifyAdminConsoleLoginUsingIngressController(domainUid, domainNamespace);
265+
// verify admin console login
266+
if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
267+
hostHeader = createIngressHostRoutingIfNotExists(domainNamespace, domainUid);
268+
assertDoesNotThrow(()
269+
-> verifyAdminServerRESTAccess("localhost", TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
270+
} else {
271+
verifyAdminConsoleLoginUsingAdminNodePort(domainUid, domainNamespace);
272+
// verify admin console login using ingress controller
273+
verifyAdminConsoleLoginUsingIngressController(domainUid, domainNamespace);
274+
}
255275

256276
final String hostName = "localhost";
257277
String forwardedPortNo = startPortForwardProcess(hostName, domainNamespace, domainUid, ADMIN_SERVER_PORT);
@@ -293,22 +313,27 @@ void testScaleClustersWithRestApi(String domainType) {
293313
curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
294314
List<String> managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, replicaCount);
295315
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
296-
replicaCount, numberOfServers, true, externalRestHttpsPort, opNamespace, opServiceAccount,
316+
replicaCount, numberOfServers, true, OPERATOR_EXTERNAL_REST_HTTPSPORT, opNamespace, opServiceAccount,
297317
false, "", "", 0, "", "", curlCmd, managedServersBeforeScale);
298318

299319
// then scale cluster back to 2 servers
300320
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
301321
clusterName, domainUid, domainNamespace, numberOfServers, replicaCount);
302322
managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, numberOfServers);
303323
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
304-
numberOfServers, replicaCount, true, externalRestHttpsPort, opNamespace, opServiceAccount,
324+
numberOfServers, replicaCount, true, OPERATOR_EXTERNAL_REST_HTTPSPORT, opNamespace, opServiceAccount,
305325
false, "", "", 0, "", "", curlCmd, managedServersBeforeScale);
306326

307-
// verify admin console login using admin node port
308-
verifyAdminConsoleLoginUsingAdminNodePort(domainUid, domainNamespace);
309-
310-
// verify admin console login using ingress controller
311-
verifyAdminConsoleLoginUsingIngressController(domainUid, domainNamespace);
327+
// verify admin console login
328+
if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
329+
hostHeader = createIngressHostRoutingIfNotExists(domainNamespace, domainUid);
330+
assertDoesNotThrow(()
331+
-> verifyAdminServerRESTAccess("localhost", TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
332+
} else {
333+
verifyAdminConsoleLoginUsingAdminNodePort(domainUid, domainNamespace);
334+
// verify admin console login using ingress controller
335+
verifyAdminConsoleLoginUsingIngressController(domainUid, domainNamespace);
336+
}
312337

313338
// shutdown domain and verify the domain is shutdown
314339
shutdownDomainAndVerify(domainNamespace, domainUid, replicaCount);
@@ -349,7 +374,7 @@ void testScaleClustersWithWLDF(String domainType) {
349374
logger.info("BR: curlCmdForWLDFScript = {0}", curlCmdForWLDFScript);
350375

351376
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
352-
replicaCount, replicaCount + 1, false, 0, opNamespace, opServiceAccount,
377+
replicaCount, replicaCount + 1, false, OPERATOR_EXTERNAL_REST_HTTPSPORT, opNamespace, opServiceAccount,
353378
true, domainHome, "scaleUp", 1,
354379
WLDF_OPENSESSION_APP, curlCmdForWLDFScript, curlCmd, managedServersBeforeScale);
355380

@@ -363,11 +388,16 @@ void testScaleClustersWithWLDF(String domainType) {
363388
true, domainHome, "scaleDown", 1,
364389
WLDF_OPENSESSION_APP, curlCmdForWLDFScript, curlCmd, managedServersBeforeScale);
365390

366-
// verify admin console login using admin node port
367-
verifyAdminConsoleLoginUsingAdminNodePort(domainUid, domainNamespace);
368-
369-
// verify admin console login using ingress controller
370-
verifyAdminConsoleLoginUsingIngressController(domainUid, domainNamespace);
391+
// verify admin console login
392+
if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
393+
hostHeader = createIngressHostRoutingIfNotExists(domainNamespace, domainUid);
394+
assertDoesNotThrow(()
395+
-> verifyAdminServerRESTAccess("localhost", TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
396+
} else {
397+
verifyAdminConsoleLoginUsingAdminNodePort(domainUid, domainNamespace);
398+
// verify admin console login using ingress controller
399+
verifyAdminConsoleLoginUsingIngressController(domainUid, domainNamespace);
400+
}
371401

372402
// shutdown domain and verify the domain is shutdown
373403
shutdownDomainAndVerify(domainNamespace, domainUid, replicaCount);
@@ -560,9 +590,9 @@ private static String generateCurlCmd(String domainUid, String domainNamespace,
560590
if (host.contains(":")) {
561591
host = "[" + host + "]";
562592
}
563-
return String.format("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s:%s/%s/index.jsp",
593+
return String.format("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp",
564594
domainUid + "." + domainNamespace + "." + clusterName + ".test",
565-
host, nodeportshttp, appContextRoot);
595+
getHostAndPort(host, nodeportshttp), appContextRoot);
566596
}
567597
}
568598

@@ -712,8 +742,14 @@ private static void createRouteForOKDOrIngressForDomain(DomainResource domain) {
712742

713743
if (!OKD) {
714744
logger.info("Creating ingress for domain {0} in namespace {1}", domainUid, domainNamespace);
715-
createIngressForDomainAndVerify(domainUid, domainNamespace, nodeportshttp, clusterNameMsPortMap,
716-
true, nginxHelmParams.getIngressClassName(), true, ADMIN_SERVER_PORT);
745+
if (WLSIMG_BUILDER.equals(WLSIMG_BUILDER_DEFAULT)) {
746+
createIngressForDomainAndVerify(domainUid, domainNamespace, nodeportshttp, clusterNameMsPortMap,
747+
true, nginxHelmParams.getIngressClassName(), true, ADMIN_SERVER_PORT);
748+
} else {
749+
assertDoesNotThrow(()
750+
-> createIngressForDomainAndVerify(domainUid, domainNamespace, TRAEFIK_INGRESS_HTTP_HOSTPORT,
751+
clusterNameMsPortMap, true, Files.readString(INGRESS_CLASS_FILE_NAME), true, ADMIN_SERVER_PORT));
752+
}
717753
}
718754
}
719755

@@ -810,4 +846,19 @@ private void verifyAdminConsoleLoginUsingIngressController(String domainUid, Str
810846
}
811847
}
812848

849+
private String createIngressHostRoutingIfNotExists(String domainNamespace,
850+
String domainUid) {
851+
String ingressName = domainNamespace + "-" + domainUid + "-" + adminServerName;
852+
String hostHeader = "";
853+
try {
854+
List<String> ingresses = listIngresses(domainNamespace);
855+
Optional<String> ingressFound = ingresses.stream().filter(ingress -> ingress.equals(ingressName)).findAny();
856+
if (ingressFound.isEmpty()) {
857+
hostHeader = createIngressHostRouting(domainNamespace, domainUid, adminServerName, 7001);
858+
}
859+
} catch (Exception ex) {
860+
logger.severe(ex.getMessage());
861+
}
862+
return hostHeader;
863+
}
813864
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public interface TestConstants {
6565
public static final String OPERATOR_SERVICE_NAME = "internal-weblogic-operator-svc";
6666
public static final String OPERATOR_GITHUB_CHART_REPO_URL =
6767
"https://oracle.github.io/weblogic-kubernetes-operator/charts";
68+
public static final int OPERATOR_EXTERNAL_REST_HTTPSPORT = 30511;
6869

6970
// kind constants
7071
public static final String KIND_REPO = getKindRepoValue("wko.it.kind.repo");

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
5555
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
5656
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
57+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
5758
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
5859
//import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCommandResultContainsMsg;
5960
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
@@ -444,7 +445,7 @@ public static List<String> createIngressForDomainAndVerify(String domainUid,
444445
host = "[" + host + "]";
445446
}
446447
String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: " + ingressHost
447-
+ "' http://" + host + ":" + nodeport
448+
+ "' http://" + getHostAndPort(host, nodeport)
448449
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
449450

450451
logger.info("Executing curl command {0}", curlCmd);

0 commit comments

Comments
 (0)