Skip to content

Commit d8872a9

Browse files
sankarpnrjeberhard
authored andcommitted
podman changes for tests - part4
1 parent 0091699 commit d8872a9

16 files changed

+470
-373
lines changed

Jenkinsfile.podman

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ nodes:
404404
hostPort: 1511
405405
- containerPort: 32159
406406
hostPort: 2160
407+
- containerPort: 32169
408+
hostPort: 2172
409+
protocol: TCP
410+
- containerPort: 32170
411+
hostPort: 2173
412+
protocol: TCP
407413
extraMounts:
408414
- hostPath: ${pv_root}
409415
containerPath: ${pv_root}

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

Lines changed: 101 additions & 140 deletions
Large diffs are not rendered by default.

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

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package oracle.weblogic.kubernetes;
55

6+
import java.net.InetAddress;
7+
import java.net.UnknownHostException;
68
import java.nio.file.Path;
79
import java.nio.file.Paths;
810
import java.util.ArrayList;
@@ -45,6 +47,10 @@
4547
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
4648
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
4749
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
50+
import static oracle.weblogic.kubernetes.TestConstants.IT_EXTERNALLB_TUNNELING_HTTPS_CONAINERPORT;
51+
import static oracle.weblogic.kubernetes.TestConstants.IT_EXTERNALLB_TUNNELING_HTTPS_HOSTPORT;
52+
import static oracle.weblogic.kubernetes.TestConstants.IT_EXTERNALLB_TUNNELING_HTTP_CONAINERPORT;
53+
import static oracle.weblogic.kubernetes.TestConstants.IT_EXTERNALLB_TUNNELING_HTTP_HOSTPORT;
4854
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
4955
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOSTNAME;
5056
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
@@ -57,11 +63,11 @@
5763
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_RELEASE_NAME;
5864
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
5965
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
60-
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
6166
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
6267
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallTraefik;
6368
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
6469
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
70+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host;
6571
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
6672
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
6773
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
@@ -130,6 +136,7 @@ class ItExternalLbTunneling {
130136
private static Path jksTrustFile;
131137
private static String tlsSecretName = domainUid + "-test-tls-secret";
132138
private String clusterSvcRouteHost = null;
139+
private static String hostAddress = K8S_NODEPORT_HOST;
133140

134141
/**
135142
* Install Operator.
@@ -138,9 +145,13 @@ class ItExternalLbTunneling {
138145
JUnit engine parameter resolution mechanism
139146
*/
140147
@BeforeAll
141-
public static void initAll(@Namespaces(3) List<String> namespaces) {
148+
public static void initAll(@Namespaces(3) List<String> namespaces) throws UnknownHostException {
142149
logger = getLogger();
143150
logger.info("K8S_NODEPORT_HOSTNAME {0} K8S_NODEPORT_HOST {1}", K8S_NODEPORT_HOSTNAME, K8S_NODEPORT_HOST);
151+
if (TestConstants.KIND_CLUSTER
152+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
153+
hostAddress = formatIPv6Host(InetAddress.getLocalHost().getHostAddress());
154+
}
144155

145156
// get a new unique opNamespace
146157
logger.info("Assigning unique namespace for Operator");
@@ -177,7 +188,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
177188
// Prepare the config map sparse model file from the template by replacing
178189
// Public Address of the custom channel with K8S_NODEPORT_HOST
179190
Map<String, String> configTemplateMap = new HashMap<>();
180-
configTemplateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
191+
configTemplateMap.put("INGRESS_HOST", hostAddress);
181192

182193
Path srcFile = Paths.get(RESOURCE_DIR,
183194
"wdt-models", "tunneling.model.template.yaml");
@@ -207,11 +218,12 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
207218

208219
if (!OKD) {
209220
logger.info("Installing Traefik controller using helm");
210-
traefikHelmParams = installAndVerifyTraefik(traefikNamespace, 0, 0).getHelmParams();
221+
traefikHelmParams = installAndVerifyTraefik(traefikNamespace,
222+
IT_EXTERNALLB_TUNNELING_HTTP_CONAINERPORT, IT_EXTERNALLB_TUNNELING_HTTPS_CONAINERPORT).getHelmParams();
211223
}
212224

213225
// Create SSL certificate and key using openSSL with SAN extension
214-
createCertKeyFiles(K8S_NODEPORT_HOST);
226+
createCertKeyFiles(hostAddress);
215227
// Create kubernates secret using genereated certificate and key
216228
createSecretWithTLSCertKey(tlsSecretName);
217229
// Import the tls certificate into a JKS truststote to be used while
@@ -262,7 +274,7 @@ void testExternalRmiAccessThruTraefik() {
262274
templateMap.put("DOMAIN_NS", domainNamespace);
263275
templateMap.put("DOMAIN_UID", domainUid);
264276
templateMap.put("CLUSTER", clusterName);
265-
templateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
277+
templateMap.put("INGRESS_HOST", hostAddress);
266278

267279
Path srcTraefikHttpFile = Paths.get(RESOURCE_DIR,
268280
"tunneling", "traefik.tunneling.template.yaml");
@@ -281,11 +293,14 @@ void testExternalRmiAccessThruTraefik() {
281293

282294
// Get the ingress service nodeport corresponding to non-tls service
283295
// Get the Traefik Service Name traefik-release-{ns}
284-
String service =
285-
TRAEFIK_RELEASE_NAME + "-" + traefikNamespace.substring(3);
296+
String service
297+
= TRAEFIK_RELEASE_NAME + "-" + traefikNamespace.substring(3);
286298
logger.info("TRAEFIK_SERVICE {0} in {1}", service, traefikNamespace);
287-
int httpTunnelingPort =
288-
getServiceNodePort(traefikNamespace, service, "web");
299+
int httpTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTP_CONAINERPORT;
300+
if (TestConstants.KIND_CLUSTER
301+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
302+
httpTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTP_HOSTPORT;
303+
}
289304
assertNotEquals(-1, httpTunnelingPort,
290305
"Could not get the Traefik HttpTunnelingPort service node port");
291306
logger.info("HttpTunnelingPort for Traefik {0}", httpTunnelingPort);
@@ -320,7 +335,7 @@ void testExternalRmiAccessThruTraefikHttpsTunneling() {
320335
templateMap.put("DOMAIN_UID", domainUid);
321336
templateMap.put("CLUSTER", clusterName);
322337
templateMap.put("TLS_CERT", tlsSecretName);
323-
templateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
338+
templateMap.put("INGRESS_HOST", hostAddress);
324339

325340
Path srcTraefikHttpsFile = Paths.get(RESOURCE_DIR,
326341
"tunneling", "traefik.tls.tunneling.template.yaml");
@@ -339,11 +354,14 @@ void testExternalRmiAccessThruTraefikHttpsTunneling() {
339354

340355
// Get the ingress service nodeport corresponding to tls service
341356
// Get the Traefik Service Name traefik-release-{ns}
342-
String service =
343-
TRAEFIK_RELEASE_NAME + "-" + traefikNamespace.substring(3);
357+
String service
358+
= TRAEFIK_RELEASE_NAME + "-" + traefikNamespace.substring(3);
344359
logger.info("TRAEFIK_SERVICE {0} in {1}", service, traefikNamespace);
345-
int httpsTunnelingPort =
346-
getServiceNodePort(traefikNamespace, service, "websecure");
360+
int httpsTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTPS_CONAINERPORT;
361+
if (TestConstants.KIND_CLUSTER
362+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
363+
httpsTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTPS_HOSTPORT;
364+
}
347365
assertNotEquals(-1, httpsTunnelingPort,
348366
"Could not get the Traefik HttpsTunnelingPort service node port");
349367
logger.info("HttpsTunnelingPort for Traefik {0}", httpsTunnelingPort);
@@ -441,8 +459,7 @@ private void runExtHttpsClient(String routeHost, int httpsTunnelingPort, int ser
441459
logger.info("java command to be run {0}", javasCmd.toString());
442460

443461
// Note it takes a couples of iterations before the client success
444-
testUntil(
445-
runJmsClient(new String(javasCmd)),
462+
testUntil(runJmsClient(new String(javasCmd)),
446463
logger,
447464
"Wait for Https JMS Client to access WLS");
448465
}
@@ -503,7 +520,7 @@ private void runExtClient(String routeHost, int httpTunnelingPort, int serverCou
503520
javaCmd.append(String.valueOf(checkConnection));
504521
logger.info("java command to be run {0}", javaCmd.toString());
505522

506-
// Note it takes a couples of iterations before the client success
523+
// Note it takes a couples of iterations before the client success
507524
testUntil(runJmsClient(new String(javaCmd)), logger, "Wait for Http JMS Client to access WLS");
508525
}
509526

@@ -604,7 +621,7 @@ public void tearDownAll() {
604621
private static void createCertKeyFiles(String cn) {
605622

606623
Map<String, String> sanConfigTemplateMap = new HashMap<>();
607-
sanConfigTemplateMap.put("INGRESS_HOST", K8S_NODEPORT_HOST);
624+
sanConfigTemplateMap.put("INGRESS_HOST", hostAddress);
608625

609626
Path srcFile = Paths.get(RESOURCE_DIR,
610627
"tunneling", "san.config.template.txt");

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.File;
77
import java.io.FileOutputStream;
88
import java.io.IOException;
9+
import java.net.InetAddress;
910
import java.net.http.HttpResponse;
1011
import java.nio.file.Files;
1112
import java.nio.file.Path;
@@ -20,12 +21,15 @@
2021
import java.util.Properties;
2122

2223
import io.kubernetes.client.custom.V1Patch;
24+
import io.kubernetes.client.openapi.ApiException;
2325
import io.kubernetes.client.openapi.models.V1Container;
2426
import io.kubernetes.client.openapi.models.V1EnvVar;
27+
import io.kubernetes.client.openapi.models.V1Ingress;
2528
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
2629
import io.kubernetes.client.openapi.models.V1ObjectMeta;
2730
import io.kubernetes.client.openapi.models.V1PersistentVolumeClaimVolumeSource;
2831
import io.kubernetes.client.openapi.models.V1Pod;
32+
import io.kubernetes.client.openapi.models.V1ServiceBackendPort;
2933
import io.kubernetes.client.openapi.models.V1Volume;
3034
import io.kubernetes.client.openapi.models.V1VolumeMount;
3135
import oracle.weblogic.domain.AdminServer;
@@ -39,6 +43,7 @@
3943
import oracle.weblogic.domain.Model;
4044
import oracle.weblogic.domain.ServerPod;
4145
import oracle.weblogic.domain.ServerService;
46+
import oracle.weblogic.kubernetes.actions.impl.Ingress;
4247
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
4348
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
4449
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
@@ -96,6 +101,7 @@
96101
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainResourceWithNewIntrospectVersion;
97102
import static oracle.weblogic.kubernetes.actions.impl.Cluster.scaleCluster;
98103
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
104+
import static oracle.weblogic.kubernetes.actions.impl.Ingress.updateIngress;
99105
import static oracle.weblogic.kubernetes.actions.impl.Pod.getPod;
100106
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podStateNotChanged;
101107
import static oracle.weblogic.kubernetes.assertions.TestAssertions.verifyRollingRestartOccurred;
@@ -106,6 +112,7 @@
106112
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
107113
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
108114
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
115+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host;
109116
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.generateNewModelFileWithUpdatedDomainUid;
110117
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
111118
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
@@ -153,6 +160,7 @@
153160
import static org.junit.jupiter.api.Assertions.assertNotEquals;
154161
import static org.junit.jupiter.api.Assertions.assertNotNull;
155162
import static org.junit.jupiter.api.Assertions.assertTrue;
163+
import static org.junit.jupiter.api.Assertions.fail;
156164

157165
/**
158166
* Tests related to introspectVersion attribute.
@@ -402,7 +410,7 @@ void testDomainIntrospectVersionNotRolling() {
402410
*/
403411
@Test
404412
@DisplayName("Test introspectVersion rolling server pods when admin server port is changed")
405-
void testDomainIntrospectVersionRolling() {
413+
void testDomainIntrospectVersionRolling() throws ApiException {
406414

407415
final int newAdminPort = 7005;
408416

@@ -495,6 +503,11 @@ void testDomainIntrospectVersionRolling() {
495503
for (int i = 1; i <= cluster1ReplicaCount; i++) {
496504
managedServerNames.add(cluster1ManagedServerNameBase + i);
497505
}
506+
507+
if (TestConstants.KIND_CLUSTER
508+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
509+
updateIngressBackendServicePort(newAdminPort);
510+
}
498511

499512
//verify admin server accessibility and the health of cluster members
500513
verifyMemberHealth(adminServerPodName, managedServerNames,
@@ -1262,7 +1275,7 @@ private static void createDomain() {
12621275
if (TestConstants.KIND_CLUSTER
12631276
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
12641277
hostHeader = createIngressHostRouting(introDomainNamespace, domainUid, adminServerName, adminPort);
1265-
assertDoesNotThrow(() -> verifyAdminServerRESTAccess("localhost",
1278+
assertDoesNotThrow(() -> verifyAdminServerRESTAccess(formatIPv6Host(InetAddress.getLocalHost().getHostAddress()),
12661279
TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
12671280
}
12681281

@@ -1370,7 +1383,8 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m
13701383
Map<String, String> headers = null;
13711384
if (TestConstants.KIND_CLUSTER
13721385
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
1373-
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
1386+
hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress())
1387+
+ ":" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
13741388
headers = new HashMap<>();
13751389
headers.put("host", hostHeader);
13761390
}
@@ -1554,4 +1568,18 @@ private DomainResource createDomainResourceWithConfigMap(String domainUid, Strin
15541568
return domain;
15551569
}
15561570

1571+
private void updateIngressBackendServicePort(int newAdminPort) throws ApiException {
1572+
String ingressName = introDomainNamespace + "-" + domainUid + "-" + adminServerName;
1573+
V1Ingress ingress = Ingress.getIngress(introDomainNamespace, ingressName).orElse(null);
1574+
if (ingress != null) {
1575+
logger.info("Updating ingress {0} with new admin port {1}", ingressName, newAdminPort);
1576+
ingress.getSpec().getRules().getFirst().getHttp()
1577+
.getPaths().getFirst().getBackend().getService()
1578+
.setPort(new V1ServiceBackendPort().number(newAdminPort));
1579+
updateIngress(introDomainNamespace, ingress);
1580+
} else {
1581+
fail("Failed to update ingress");
1582+
}
1583+
}
1584+
15571585
}

0 commit comments

Comments
 (0)