Skip to content

Commit

Permalink
forward port 2 MRs from R42 to Main
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhao-github authored and rjeberhard committed Nov 13, 2024
1 parent 6654b26 commit 7df5cbb
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,6 +140,9 @@ class ItIstioDBOperator {
private static String hostHeader;
Map<String, String> 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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Boolean> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit 7df5cbb

Please sign in to comment.