Skip to content

Commit d8f3db9

Browse files
committed
Merge branch 'forwardport-2mr-2main' into 'main'
forward port 2 MRs from R42 to Main See merge request weblogic-cloud/weblogic-kubernetes-operator!4865
2 parents e132eec + 7df5cbb commit d8f3db9

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

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

+20-5
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createTestWebAppWarFile;
7575
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host;
7676
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
77+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
7778
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
7879
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runClientInsidePod;
7980
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runJavacInsidePod;
@@ -139,6 +140,9 @@ class ItIstioDBOperator {
139140
private static String hostHeader;
140141
Map<String, String> httpHeaders;
141142

143+
private static final String istioNamespace = "istio-system";
144+
private static final String istioIngressServiceName = "istio-ingressgateway";
145+
142146
/**
143147
* Start DB service and create RCU schema.
144148
* Assigns unique namespaces for operator and domains.
@@ -418,7 +422,11 @@ private void runJmsClientOnAdminPod(String action, String queue) {
418422
* @returns true if MBean is found otherwise false
419423
**/
420424
private boolean checkJmsServerRuntime(String jmsServer, String managedServer) throws UnknownHostException {
421-
String hostAndPort = getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort);
425+
// In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
426+
String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null
427+
? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace)
428+
: getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort);
429+
422430
if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
423431
hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) + ":" + ISTIO_HTTP_HOSTPORT;
424432
}
@@ -437,7 +445,10 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) th
437445
* @returns true if MBean is found otherwise false
438446
**/
439447
private boolean checkStoreRuntime(String storeName, String managedServer) throws UnknownHostException {
440-
String hostAndPort = getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort);
448+
String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null
449+
? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace)
450+
: getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort);
451+
441452
if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
442453
hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) + ":" + ISTIO_HTTP_HOSTPORT;
443454
}
@@ -458,9 +469,13 @@ private boolean checkStoreRuntime(String storeName, String managedServer) throws
458469
* @returns true if MBean is found otherwise false
459470
**/
460471
private boolean checkJtaRecoveryServiceRuntime(String managedServer,
461-
String recoveryService, String active) throws UnknownHostException {
462-
463-
String hostAndPort = getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort);
472+
String recoveryService,
473+
String active) throws UnknownHostException {
474+
475+
String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null
476+
? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace)
477+
: getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort);
478+
464479
if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
465480
hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) + ":" + ISTIO_HTTP_HOSTPORT;
466481
}

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

+29
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.nio.file.Paths;
99
import java.util.HashMap;
1010
import java.util.List;
11+
import java.util.concurrent.Callable;
1112

1213
import oracle.weblogic.kubernetes.logging.LoggingFacade;
1314
import org.awaitility.core.ConditionFactory;
@@ -350,6 +351,34 @@ public static boolean callWebAppAndCheckForServerNameInResponse(
350351
return false;
351352
}
352353

354+
/**
355+
* Call a web app and wait for the response code 200.
356+
* @param curlCmd curl command to call the web app
357+
* @return true if 200 response code is returned, false otherwise
358+
*/
359+
public static Callable<Boolean> callWebAppAndWaitTillReady(String curlCmd) {
360+
LoggingFacade logger = getLogger();
361+
String httpStatusCode = "200";
362+
363+
return () -> {
364+
final ExecResult result = ExecCommand.exec(curlCmd);
365+
final String responseCode = result.stdout().trim();
366+
367+
if (result != null) {
368+
logger.info("result.stdout: \n{0}", result.stdout());
369+
logger.info("result.stderr: \n{0}", result.stderr());
370+
logger.info("result.exitValue: \n{0}", result.exitValue());
371+
}
372+
373+
if (result.exitValue() != 0 || !responseCode.equals(httpStatusCode)) {
374+
logger.info("callWebApp did not return {0} response code, got {1}", httpStatusCode, responseCode);
375+
return false;
376+
}
377+
378+
return true;
379+
};
380+
}
381+
353382
/**
354383
* Call a web app and wait for the response code 200.
355384
* @param curlCmd curl command to call the web app

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

+6
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,12 @@ public static void verifyAdminServerAccess(boolean isTLS,
913913
consoleAccessible = true;
914914
break;
915915
}
916+
917+
try {
918+
Thread.sleep(5000);
919+
} catch (InterruptedException ignore) {
920+
// ignore
921+
}
916922
} catch (IOException | InterruptedException ex) {
917923
getLogger().severe(ex.getMessage());
918924
}

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
7272
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
7373
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
74-
//import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCommandResultContainsMsg;
74+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withLongRetryPolicy;
7575
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
7676
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
7777
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
@@ -743,6 +743,11 @@ public static void createNginxIngressPathRoutingRules(String domainNamespace,
743743
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
744744

745745
logger.info("Executing curl command {0}", curlCmd);
746+
testUntil(
747+
withLongRetryPolicy,
748+
callWebAppAndWaitTillReady(curlCmd),
749+
logger,
750+
"Waiting until Web App available");
746751
assertTrue(callWebAppAndWaitTillReady(curlCmd, 60));
747752
}
748753

0 commit comments

Comments
 (0)