diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioDBOperator.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioDBOperator.java index 6b614c28df1..10d0b8bca87 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioDBOperator.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioDBOperator.java @@ -74,6 +74,7 @@ import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createTestWebAppWarFile; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort; +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runClientInsidePod; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.runJavacInsidePod; @@ -139,6 +140,9 @@ class ItIstioDBOperator { private static String hostHeader; Map httpHeaders; + private static final String istioNamespace = "istio-system"; + private static final String istioIngressServiceName = "istio-ingressgateway"; + /** * Start DB service and create RCU schema. * Assigns unique namespaces for operator and domains. @@ -418,7 +422,11 @@ private void runJmsClientOnAdminPod(String action, String queue) { * @returns true if MBean is found otherwise false **/ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) throws UnknownHostException { - String hostAndPort = getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort); + // In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort + String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null + ? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) + : getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort); + if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) + ":" + ISTIO_HTTP_HOSTPORT; } @@ -437,7 +445,10 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) th * @returns true if MBean is found otherwise false **/ private boolean checkStoreRuntime(String storeName, String managedServer) throws UnknownHostException { - String hostAndPort = getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort); + String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null + ? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) + : getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort); + if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) + ":" + ISTIO_HTTP_HOSTPORT; } @@ -458,9 +469,13 @@ private boolean checkStoreRuntime(String storeName, String managedServer) throws * @returns true if MBean is found otherwise false **/ private boolean checkJtaRecoveryServiceRuntime(String managedServer, - String recoveryService, String active) throws UnknownHostException { - - String hostAndPort = getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort); + String recoveryService, + String active) throws UnknownHostException { + + String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null + ? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) + : getHostAndPort(adminSvcExtRouteHost, wlDomainIstioIngressPort); + if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) + ":" + ISTIO_HTTP_HOSTPORT; } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/ApplicationUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/ApplicationUtils.java index 300f365f113..852233e95f9 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/ApplicationUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/ApplicationUtils.java @@ -8,6 +8,7 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.List; +import java.util.concurrent.Callable; import oracle.weblogic.kubernetes.logging.LoggingFacade; import org.awaitility.core.ConditionFactory; @@ -350,6 +351,34 @@ public static boolean callWebAppAndCheckForServerNameInResponse( return false; } + /** + * Call a web app and wait for the response code 200. + * @param curlCmd curl command to call the web app + * @return true if 200 response code is returned, false otherwise + */ + public static Callable callWebAppAndWaitTillReady(String curlCmd) { + LoggingFacade logger = getLogger(); + String httpStatusCode = "200"; + + return () -> { + final ExecResult result = ExecCommand.exec(curlCmd); + final String responseCode = result.stdout().trim(); + + if (result != null) { + logger.info("result.stdout: \n{0}", result.stdout()); + logger.info("result.stderr: \n{0}", result.stderr()); + logger.info("result.exitValue: \n{0}", result.exitValue()); + } + + if (result.exitValue() != 0 || !responseCode.equals(httpStatusCode)) { + logger.info("callWebApp did not return {0} response code, got {1}", httpStatusCode, responseCode); + return false; + } + + return true; + }; + } + /** * Call a web app and wait for the response code 200. * @param curlCmd curl command to call the web app diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java index bc55a364eaa..5e465ac46e2 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java @@ -913,6 +913,12 @@ public static void verifyAdminServerAccess(boolean isTLS, consoleAccessible = true; break; } + + try { + Thread.sleep(5000); + } catch (InterruptedException ignore) { + // ignore + } } catch (IOException | InterruptedException ex) { getLogger().severe(ex.getMessage()); } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/LoadBalancerUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/LoadBalancerUtils.java index ad4a2116085..95072202522 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/LoadBalancerUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/LoadBalancerUtils.java @@ -71,7 +71,7 @@ import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil; -//import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCommandResultContainsMsg; +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withLongRetryPolicy; import static oracle.weblogic.kubernetes.utils.ExecCommand.exec; import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret; import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; @@ -743,6 +743,11 @@ public static void createNginxIngressPathRoutingRules(String domainNamespace, + "/weblogic/ready --write-out %{http_code} -o /dev/null"; logger.info("Executing curl command {0}", curlCmd); + testUntil( + withLongRetryPolicy, + callWebAppAndWaitTillReady(curlCmd), + logger, + "Waiting until Web App available"); assertTrue(callWebAppAndWaitTillReady(curlCmd, 60)); }