Skip to content

Commit 2de7c3f

Browse files
committed
Merge branch 'podman-conversion-02072024' into 'main'
conversion of tests to podman See merge request weblogic-cloud/weblogic-kubernetes-operator!4577
2 parents 4541a4a + 4318a25 commit 2de7c3f

14 files changed

+385
-270
lines changed

Jenkinsfile.podman

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pipeline {
6969
choice(name: 'MAVEN_PROFILE_NAME',
7070
description: 'Profile to use in mvn command to run the tests. Possible values are wls-srg (the default), integration-tests, toolkits-srg, kind-sequential and kind-upgrade. Refer to weblogic-kubernetes-operator/integration-tests/pom.xml on the branch.',
7171
choices: [
72+
'kind-parallel',
7273
'wls-srg',
7374
'integration-tests',
7475
'kind-sequential',
@@ -398,8 +399,12 @@ nodes:
398399
hostPort: 2480
399400
- containerPort: 32490
400401
hostPort: 2490
402+
- containerPort: 32156
403+
hostPort: 2156
401404
- containerPort: 30511
402405
hostPort: 1511
406+
- containerPort: 32159
407+
hostPort: 2160
403408
extraMounts:
404409
- hostPath: ${pv_root}
405410
containerPath: ${pv_root}

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

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.File;
77
import java.io.FileOutputStream;
8+
import java.net.http.HttpResponse;
89
import java.nio.file.Path;
910
import java.nio.file.Paths;
1011
import java.util.List;
@@ -15,22 +16,26 @@
1516
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
1617
import oracle.weblogic.kubernetes.annotations.Namespaces;
1718
import oracle.weblogic.kubernetes.logging.LoggingFacade;
19+
import oracle.weblogic.kubernetes.utils.OracleHttpClient;
1820
import org.junit.jupiter.api.BeforeAll;
1921
import org.junit.jupiter.api.DisplayName;
2022
import org.junit.jupiter.api.Tag;
2123
import org.junit.jupiter.api.Test;
2224

2325
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
2426
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
27+
import static oracle.weblogic.kubernetes.TestConstants.OKD;
2528
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
29+
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
2630
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
2731
import static oracle.weblogic.kubernetes.actions.TestActions.getNextIntrospectVersion;
2832
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
2933
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
3034
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
31-
import static oracle.weblogic.kubernetes.assertions.TestAssertions.adminNodePortAccessible;
35+
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminServerRESTAccess;
36+
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.verifyAdminServerRESTAccessInAdminPod;
3237
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
33-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isAppInServerPodReady;
38+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
3439
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
3540
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainOnPvUsingWdt;
3641
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
@@ -56,14 +61,17 @@ class ItAddNewDynamicClusterUsingWlst {
5661

5762
// domain constants
5863
private static final String domainUid = "dynasconfigcluster-domain-1";
59-
private static final String adminServerPodName = domainUid + "-admin-server";
64+
private static final String adminServerName = "admin-server";
65+
private static final String adminServerPodName = domainUid + "-" + adminServerName;
66+
private static final int adminPort = 7001;
6067
private static final String newManagedServerPrefix = "new-managed-server";
6168
private static final String newManagedServerPodPrefix = domainUid + "-" + newManagedServerPrefix;
6269
private static final String clusterName = "cluster-1";
6370
private static final String newClusterName = "cluster-2";
6471
private static final int replicaCount = 2;
6572
private static final String wlSecretName = "weblogic-credentials";
6673
private static String domainNamespace = null;
74+
private static String hostHeader;
6775

6876
private static LoggingFacade logger = null;
6977

@@ -104,6 +112,13 @@ void testDynamicClusterNotAsConfigCluster() {
104112
DomainResource domain = createDomainOnPvUsingWdt(domainUid, domainNamespace, wlSecretName,
105113
clusterName, replicaCount, ItAddNewDynamicClusterUsingWlst.class.getSimpleName());
106114
assertDomainNotNull(domain);
115+
116+
if (TestConstants.KIND_CLUSTER
117+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
118+
hostHeader = createIngressHostRouting(domainNamespace, domainUid, adminServerName, adminPort);
119+
assertDoesNotThrow(() -> verifyAdminServerRESTAccess("localhost",
120+
TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
121+
}
107122

108123
// get admin service node port
109124
logger.info("Getting node port for default channel");
@@ -116,15 +131,16 @@ void testDynamicClusterNotAsConfigCluster() {
116131

117132
logger.info("Validating WebLogic admin server access by login to console");
118133
if (OKE_CLUSTER) {
119-
testUntil(isAppInServerPodReady(domainNamespace,
120-
adminServerPodName, 7001, "/console/login/LoginForm.jsp", "Copyright"),
121-
logger, "Validating WebLogic admin server access by login to console");
122-
} else {
123-
testUntil(
124-
assertDoesNotThrow(() -> {
125-
return adminNodePortAccessible(serviceNodePort,
126-
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, routeHost);
127-
}, "Access to admin server node port failed"), logger, "Console login validation");
134+
testUntil(() -> verifyAdminServerRESTAccessInAdminPod(adminServerPodName, "7001",
135+
domainNamespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT),
136+
logger, "Validating WebLogic admin server access using REST api");
137+
} else if (OKD) {
138+
testUntil(() -> {
139+
String url = "http://" + routeHost + ":" + serviceNodePort + "/management/tenant-monitoring/servers/";
140+
HttpResponse<String> response;
141+
response = OracleHttpClient.get(url, null, true);
142+
return response.body().contains("RUNNING");
143+
}, logger, "Access to admin server failed");
128144
}
129145

130146
// create a new dynamic cluster using an online WLST script
@@ -143,7 +159,7 @@ private void createNewDynamicCluster() {
143159
// get port for default channel
144160
logger.info("Getting port for default channel");
145161
int defaultChannelPort = assertDoesNotThrow(()
146-
-> getServicePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"),
162+
-> getServicePort(domainNamespace, adminServerPodName, "default"),
147163
"Getting admin server default port failed");
148164
assertNotEquals(-1, defaultChannelPort, "Couldn't get valid port for default channel");
149165
logger.info("default channel port: {0}", defaultChannelPort);

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,11 +1001,7 @@ private void createDomain() {
10011001
.addEnvItem(new V1EnvVar()
10021002
.name("JAVA_OPTIONS")
10031003
.value("-Dweblogic.debug.DebugSituationalConfig=true "
1004-
+ "-Dweblogic.debug.DebugSituationalConfigDumpXml=true "
1005-
+ "-Dweblogic.kernel.debug=true "
1006-
+ "-Dweblogic.debug.DebugMessaging=true "
1007-
+ "-Dweblogic.debug.DebugConnection=true "
1008-
+ "-Dweblogic.ResolveDNSName=true"))
1004+
+ "-Dweblogic.debug.DebugSituationalConfigDumpXml=true "))
10091005
.addEnvItem(new V1EnvVar()
10101006
.name("USER_MEM_ARGS")
10111007
.value("-Djava.security.egd=file:/dev/./urandom "))
@@ -1020,7 +1016,7 @@ private void createDomain() {
10201016
.adminService(new AdminService()
10211017
.addChannelsItem(new Channel()
10221018
.channelName("default")
1023-
.nodePort(getNextFreePort())))));
1019+
.nodePort(0)))));
10241020
setPodAntiAffinity(domain);
10251021

10261022
// create cluster object

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 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.time.OffsetDateTime;
7+
import java.util.ArrayList;
68
import java.util.List;
79

810
import io.kubernetes.client.openapi.models.V1EnvVar;
@@ -29,6 +31,8 @@
2931
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
3032
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
3133
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
34+
import static oracle.weblogic.kubernetes.TestConstants.IT_DEDICATED_MODE_CONAINERPORT;
35+
import static oracle.weblogic.kubernetes.TestConstants.IT_DEDICATED_MODE_HOSTPORT;
3236
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
3337
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
3438
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
@@ -38,10 +42,11 @@
3842
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
3943
import static oracle.weblogic.kubernetes.TestConstants.WLS_DOMAIN_TYPE;
4044
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
41-
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
45+
import static oracle.weblogic.kubernetes.actions.TestActions.getPodCreationTimestamp;
46+
import static oracle.weblogic.kubernetes.actions.impl.Domain.scaleClusterWithRestApi;
4247
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
4348
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
44-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.scaleAndVerifyCluster;
49+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyClusterAfterScaling;
4550
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
4651
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
4752
import static oracle.weblogic.kubernetes.utils.OKDUtils.setTlsTerminationForRoute;
@@ -81,6 +86,7 @@ class ItDedicatedMode {
8186
domainUid + "-" + ADMIN_SERVER_NAME_BASE;
8287
private final String managedServerPodPrefix =
8388
domainUid + "-" + MANAGED_SERVER_NAME_BASE;
89+
private static int externalRestHttpsPort = IT_DEDICATED_MODE_CONAINERPORT;
8490

8591
// operator constants
8692
private static HelmParams opHelmParams;
@@ -138,7 +144,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
138144
// domainNamespaces parameter to something other than Operator ns (say wls)
139145
logger.info("Installing and verifying operator");
140146
installAndVerifyOperator(opNamespace, opNamespace + "-sa",
141-
true, 0, opHelmParams, domainNamespaceSelectionStrategy,
147+
true, externalRestHttpsPort, opHelmParams, domainNamespaceSelectionStrategy,
142148
false, domain2Namespace);
143149
logger.info("Operator installed on namespace {0} and domainNamespaces set to {1} ", opNamespace, domain2Namespace);
144150

@@ -180,16 +186,33 @@ void testDedicatedModeSameNamespace() {
180186
verifyDomainRunning(domain1Namespace);
181187
logger.info("WebLogic domain is managed in operator namespace Only");
182188

189+
List<OffsetDateTime> listOfPodCreationTimestamp = new ArrayList<>();
190+
for (int i = 1; i <= replicaCount; i++) {
191+
String managedServerPodName = managedServerPodPrefix + i;
192+
OffsetDateTime originalCreationTimestamp
193+
= assertDoesNotThrow(() -> getPodCreationTimestamp(domain1Namespace, "", managedServerPodName),
194+
String.format("getPodCreationTimestamp failed with ApiException for pod %s in namespace %s",
195+
managedServerPodName, domain1Namespace));
196+
listOfPodCreationTimestamp.add(originalCreationTimestamp);
197+
}
183198
// Scale up cluster-1 in domain1Namespace and verify it succeeds
184-
int externalRestHttpsPort = getServiceNodePort(opNamespace, "external-weblogic-operator-svc");
185-
logger.info("externalRestHttpsPort {0}", externalRestHttpsPort);
199+
String externalRestHttpshost;
200+
if (TestConstants.KIND_CLUSTER
201+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
202+
externalRestHttpshost = "localhost";
203+
externalRestHttpsPort = IT_DEDICATED_MODE_HOSTPORT;
204+
logger.info("Running in podman using Operator hostport {0}:{1}", externalRestHttpshost, externalRestHttpsPort);
205+
} else {
206+
logger.info("externalRestHttpsPort {0}", externalRestHttpsPort);
207+
externalRestHttpshost = null;
208+
}
186209

187210
logger.info("scaling the cluster from {0} servers to {1} servers", replicaCount, replicaCount + 1);
188-
scaleAndVerifyCluster(clusterName, domainUid, domain1Namespace,
189-
managedServerPodPrefix, replicaCount, replicaCount + 1,
190-
true, externalRestHttpsPort, opNamespace, opNamespace + "-sa",
191-
false, "", "", 0, "",
192-
"", null, null);
211+
scaleClusterWithRestApi(domainUid, clusterName, replicaCount + 1,
212+
externalRestHttpshost, externalRestHttpsPort, opNamespace, opServiceAccount);
213+
214+
verifyClusterAfterScaling(domainUid, domain1Namespace, managedServerPodPrefix,
215+
replicaCount, replicaCount + 1, null, null, listOfPodCreationTimestamp);
193216
}
194217

195218
private void createDomain(String domainNamespace) {

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
4343
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
4444
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
45+
import static oracle.weblogic.kubernetes.TestConstants.ITEXTERNALNODEPORTSERVICE_CONAINERPORT;
4546
import static oracle.weblogic.kubernetes.TestConstants.ITEXTERNALNODEPORTSERVICE_HOSTPORT;
4647
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
4748
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOSTNAME;
@@ -153,15 +154,14 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
153154
"weblogicenc", "weblogicenc");
154155

155156
// Prepare the config map sparse model file from the template by replacing
156-
// Public Address of the custom channel with K8S_NODEPORT_HOST
157+
// Public Address of the custom channel with K8S_NODEPORT_HOST
157158
Map<String, String> configTemplateMap = new HashMap<>();
159+
configTemplateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
158160
if (TestConstants.KIND_CLUSTER
159161
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
160-
configTemplateMap.put("INGRESS_HOST", "localhost");
161-
configTemplateMap.put("FREE_PORT", String.valueOf(ITEXTERNALNODEPORTSERVICE_HOSTPORT));
162+
configTemplateMap.put("FREE_PORT", String.valueOf(ITEXTERNALNODEPORTSERVICE_CONAINERPORT));
162163
} else {
163-
nextFreePort = getNextFreePort();
164-
configTemplateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
164+
nextFreePort = getNextFreePort();
165165
configTemplateMap.put("FREE_PORT", String.valueOf(nextFreePort));
166166
}
167167

@@ -230,8 +230,7 @@ void testExternalRmiAccessThruNodePortService() {
230230
templateMap.put("CLUSTER", clusterName);
231231
if (TestConstants.KIND_CLUSTER
232232
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
233-
templateMap.put("INGRESS_HOST", "localhost");
234-
templateMap.put("FREE_PORT", String.valueOf(ITEXTERNALNODEPORTSERVICE_HOSTPORT));
233+
templateMap.put("FREE_PORT", String.valueOf(ITEXTERNALNODEPORTSERVICE_CONAINERPORT));
235234
} else {
236235
templateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
237236
templateMap.put("FREE_PORT", String.valueOf(nextFreePort));
@@ -263,7 +262,13 @@ void testExternalRmiAccessThruNodePortService() {
263262

264263
// This test uses JMSclient which gets an InitialContext. For this, we need to specify the http port that
265264
// the client can access to get the Initial context.
266-
String hostAndPort = getHostAndPort(clusterSvcRouteHost + ":80", httpTunnelingPort);
265+
String hostAndPort;
266+
if (TestConstants.KIND_CLUSTER
267+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
268+
hostAndPort = getHostAndPort(clusterSvcRouteHost + ":80", ITEXTERNALNODEPORTSERVICE_HOSTPORT);
269+
} else {
270+
hostAndPort = getHostAndPort(clusterSvcRouteHost + ":80", httpTunnelingPort);
271+
}
267272

268273
// Make sure the JMS Connection LoadBalancing and message LoadBalancing
269274
// works from RMI client outside of k8s cluster

0 commit comments

Comments
 (0)