Skip to content

Commit 1693916

Browse files
hzhao-githubrjeberhard
authored andcommitted
Move ItManagedCoherence and ItRemoteConsole to oke
1 parent 7b99c9f commit 1693916

File tree

5 files changed

+87
-43
lines changed

5 files changed

+87
-43
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
4545
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
4646
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
47+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
4748
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
4849
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
4950
import static oracle.weblogic.kubernetes.utils.ImageUtils.createImageAndVerify;
@@ -67,9 +68,9 @@
6768
@DisplayName("Test to associate a Coherence Cluster with multiple WebLogic server clusters")
6869
@IntegrationTest
6970
@Tag("olcne")
70-
@Tag("oke-parallel")
7171
@Tag("kind-parallel")
7272
@Tag("okd-wls-mrg")
73+
@Tag("oke-gate")
7374
class ItManagedCoherence {
7475

7576
// constants for Coherence
@@ -178,7 +179,7 @@ void testMultiClusterCoherenceDomain() {
178179
traefikHelmParams.getReleaseName());
179180

180181
String clusterHostname = domainUid + "." + domainNamespace + ".cluster-1.test";
181-
// get ingress service Nodeport
182+
// get ingress service Name and Nodeport
182183
String ingressServiceName = traefikHelmParams.getReleaseName();
183184
String traefikNamespace = traefikHelmParams.getNamespace();
184185

@@ -187,7 +188,10 @@ void testMultiClusterCoherenceDomain() {
187188
"Getting Ingress Service node port failed");
188189
logger.info("Node port for {0} is: {1} :", ingressServiceName, ingressServiceNodePort);
189190

190-
String hostAndPort = getHostAndPort(clusterHostname, ingressServiceNodePort);
191+
String hostAndPort = getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) != null
192+
? getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace)
193+
: getHostAndPort(clusterHostname, ingressServiceNodePort);
194+
191195
assertTrue(checkCoheranceApp(clusterHostname, hostAndPort), "Failed to access Coherance App cation");
192196
// test adding data to the cache and retrieving them from the cache
193197
boolean testCompletedSuccessfully = assertDoesNotThrow(()
@@ -315,10 +319,14 @@ private boolean coherenceCacheTest(String hostName) {
315319

316320
private boolean coherenceCacheTest(String hostName, int ingressServiceNodePort) {
317321
logger.info("Starting to test the cache");
318-
319-
String hostAndPort = getHostAndPort(hostName, ingressServiceNodePort);
320-
logger.info("hostAndPort = {0} ", hostAndPort);
321-
322+
// get ingress service Name and Nodeport
323+
String ingressServiceName = traefikHelmParams.getReleaseName();
324+
String traefikNamespace = traefikHelmParams.getNamespace();
325+
326+
String hostAndPort = getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) != null
327+
? getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace)
328+
: getHostAndPort(hostName, ingressServiceNodePort);;
329+
logger.info("hostAndPort is: {0} ", hostAndPort);
322330

323331
// add the data to cache
324332
String[] firstNameList = {"Frodo", "Samwise", "Bilbo", "peregrin", "Meriadoc", "Gandalf"};

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReturnedCode;
5252
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createSSLenabledMiiDomainAndVerify;
5353
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
54+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
5455
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.createIngressAndRetryIfFail;
5556
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyNginx;
5657
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyTraefik;
@@ -78,9 +79,9 @@
7879
@IntegrationTest
7980
@DisabledOnSlimImage
8081
@Tag("olcne")
81-
@Tag("oke-parallel")
8282
@Tag("kind-parallel")
8383
@Tag("okd-wls-mrg")
84+
@Tag("oke-gate")
8485
class ItRemoteConsole {
8586

8687
private static String domainNamespace = null;
@@ -214,7 +215,11 @@ void testWlsRemoteConsoleConnectionUsingSSL() {
214215
int sslPort = getServicePort(
215216
domainNamespace, getExternalServicePodName(adminServerPodName), "default-secure");
216217
setTargetPortForRoute("domain1-admin-server-sslport-ext", domainNamespace, sslPort);
217-
String hostAndPort = getHostAndPort(adminSvcSslPortExtHost, sslNodePort);
218+
String ingressServiceName = traefikHelmParams.getReleaseName();
219+
String hostAndPort = getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) != null
220+
? getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace)
221+
: getHostAndPort(adminSvcSslPortExtHost, sslNodePort);
222+
218223
logger.info("The hostAndPort is {0}", hostAndPort);
219224

220225
//verify WebLogic console is accessible through default-secure nodeport
@@ -242,7 +247,6 @@ void testWlsRemoteConsoleConnectionUsingSSL() {
242247
logger.info("Executing remote console default-secure nodeport curl command {0}", curlCmd);
243248
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed");
244249
logger.info("Remote console is accessible through default-secure service");
245-
246250
}
247251

248252
/**
@@ -323,7 +327,10 @@ private static void createNginxIngressPathRoutingRules() {
323327
String nginxServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
324328
nginxNodePort = assertDoesNotThrow(() -> getServiceNodePort(nginxNamespace, nginxServiceName, "http"),
325329
"Getting Nginx loadbalancer service node port failed");
326-
String curlCmd = "curl --silent --show-error --noproxy '*' http://" + K8S_NODEPORT_HOST + ":" + nginxNodePort
330+
String hostAndPort = getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace) != null
331+
? getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace) : K8S_NODEPORT_HOST + ":" + nginxNodePort;
332+
333+
String curlCmd = "curl --silent --show-error --noproxy '*' http://" + hostAndPort
327334
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
328335

329336
logger.info("Executing curl command {0}", curlCmd);
@@ -344,10 +351,6 @@ private static void verifyWlsRemoteConsoleConnection() {
344351
logger.info("admin svc host = {0}", adminSvcExtHost);
345352
String hostAndPort = getHostAndPort(adminSvcExtHost, nodePort);
346353

347-
//The final complete curl command to run is like:
348-
//curl -v --show-error --user username:password http://localhost:8012/api/providers/AdminServerConnection -H
349-
//"Content-Type:application/json" --data "{ \"name\": \"asconn\", \"domainUrl\": \"http://myhost://nodeport\"}"
350-
//--write-out %{http_code} -o /dev/null
351354
String curlCmd = "curl -v --show-error --noproxy '*' --user "
352355
+ ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
353356
+ " http://localhost:8012/api/providers/AdminServerConnection -H "
@@ -366,17 +369,18 @@ private static void verifyRemoteConsoleConnectionThroughLB(int nodePortOfLB) {
366369
logger.info("LB nodePort is {0}", nodePortOfLB);
367370
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
368371

369-
//The final complete curl command to run is like:
370-
//curl -v --user username:password http://localhost:8012/api/providers/AdminServerConnection -H
371-
//"Content-Type:application/json" --data "{ \"name\": \"asconn\", \"domainUrl\": \"http://myhost://nodeport\"}"
372-
//--write-out %{http_code} -o /dev/null
372+
String ingressServiceName = traefikHelmParams.getReleaseName();
373+
String traefikNamespace = traefikHelmParams.getNamespace();
374+
String hostAndPort = getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) != null
375+
? getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) : K8S_NODEPORT_HOST + ":" + nodePortOfLB;
376+
373377
String curlCmd = "curl -v --user " + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
374378
+ " http://localhost:8012/api/providers/AdminServerConnection -H "
375379
+ "\"" + "Content-Type:application/json" + "\""
376380
+ " --data "
377381
+ "\"{ \\" + "\"name\\" + "\"" + ": " + "\\" + "\"" + "asconn\\" + "\"" + ", "
378382
+ "\\" + "\"" + "domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
379-
+ K8S_NODEPORT_HOST + ":" + nodePortOfLB + "\\" + "\" }" + "\""
383+
+ hostAndPort + "\\" + "\" }" + "\""
380384
+ " --write-out %{http_code} -o /dev/null";
381385
logger.info("Executing LB nodeport curl command {0}", curlCmd);
382386
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,12 @@ private static String buildCurlCommand(String hostName,
462462

463463
if (clusterAddress.length == 0) {
464464
//use a LBer ingress controller to build the curl command to run on local
465+
final String ingressServiceName = traefikHelmParams.getReleaseName();
465466
final String httpHeaderFile = LOGS_DIR + "/headers";
466467
logger.info("Build a curl command with hostname {0} and port {1}", hostName, servicePort);
467468

468-
String hostAndPort = getServiceExtIPAddrtOke(traefikNamespace, "Traefik") != null
469-
? getServiceExtIPAddrtOke(traefikNamespace, "Traefik") : getHostAndPort(hostName, servicePort);
469+
String hostAndPort = getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) != null
470+
? getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) : getHostAndPort(hostName, servicePort);
470471

471472
curlCmd.append(" --noproxy '*' -H 'host: ")
472473
.append(hostName)

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

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
import static oracle.weblogic.kubernetes.utils.FileUtils.isFileExistAndNotEmpty;
9999
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
100100
import static oracle.weblogic.kubernetes.utils.ImageUtils.createDiiImageAndVerify;
101+
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.getLbExternalIp;
101102
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDoesNotExist;
102103
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodEvictedStatusInOperatorLogs;
103104
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodExists;
@@ -1242,24 +1243,59 @@ public static String getHostAndPort(String hostName, int servicePort) {
12421243
* @param serviceName - service name
12431244
* @return external IP address of the given service on OKE
12441245
*/
1245-
public static String getServiceExtIPAddrtOke(String nameSpace, String serviceName) {
1246+
public static String getServiceExtIPAddrtOke(String serviceName, String nameSpace) {
12461247
LoggingFacade logger = getLogger();
12471248
String serviceExtIPAddr = null;
12481249

12491250
if (OKE_CLUSTER) {
1250-
String cmdToGetServiceExtIPAddr =
1251-
KUBERNETES_CLI + " get services -n " + nameSpace + " | awk '{print $4}' |tail -n+2";
1252-
logger.info("Command to get external IP address of {0} service {1}: ", serviceName, cmdToGetServiceExtIPAddr);
1253-
CommandParams params = new CommandParams().defaults();
1254-
params.command(cmdToGetServiceExtIPAddr);
1255-
ExecResult result = Command.withParams(params).executeAndReturnResult();
1256-
serviceExtIPAddr = result.stdout();
1257-
logger.info("get external IP address of {0} service returns: {1}", serviceName, serviceExtIPAddr);
1258-
}
1251+
testUntil(
1252+
isServiceExtIPAddrtOkeReady(serviceName, nameSpace),
1253+
logger,
1254+
"Waiting until external IP address of the service available");
12591255

1256+
serviceExtIPAddr =
1257+
assertDoesNotThrow(() -> getLbExternalIp(serviceName, nameSpace),
1258+
"Can't find external IP address of the service " + serviceName);
1259+
1260+
logger.info("External IP address of the service is {0} ", serviceExtIPAddr);
1261+
}
1262+
12601263
return serviceExtIPAddr;
12611264
}
12621265

1266+
/**
1267+
* Check if external IP address of a service is ready.
1268+
*
1269+
* @param nameSpace - nameSpace of service
1270+
* @param serviceName - service name
1271+
* @return external IP address of the given service on OKE
1272+
*/
1273+
public static Callable<Boolean> isServiceExtIPAddrtOkeReady(String serviceName, String nameSpace) {
1274+
LoggingFacade logger = getLogger();
1275+
// Regex for IP address that contains digit from 0 to 255.
1276+
String ipAddressNumber = "(\\d{1,2}|(0|1)\\d{2}|2[0-4]\\d|25[0-5])";
1277+
1278+
// Regex for a digit from 0 to 255 and followed by a dot, repeat 4 times to validate an IP address.
1279+
String regex = ipAddressNumber + "\\." + ipAddressNumber + "\\." + ipAddressNumber + "\\." + ipAddressNumber;
1280+
Pattern p = Pattern.compile(regex);
1281+
1282+
return () -> {
1283+
String serviceExtIPAddr =
1284+
assertDoesNotThrow(() -> getLbExternalIp(serviceName, nameSpace),
1285+
"Can't find external IP address of the service " + serviceName);
1286+
1287+
if (serviceExtIPAddr == null) {
1288+
return false;
1289+
}
1290+
1291+
logger.info("External IP address of the service returns {0} ", serviceExtIPAddr);
1292+
Matcher m = p.matcher(serviceExtIPAddr);
1293+
logger.info("Found external IP address of the service: {0} ", m.matches());
1294+
1295+
return m.matches();
1296+
};
1297+
}
1298+
12631299
/**
12641300
* Verify the command result contains expected message.
12651301
*

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
4949
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
5050
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
51-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCommandResultContainsMsg;
51+
//import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCommandResultContainsMsg;
5252
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
5353
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
5454
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
@@ -520,26 +520,21 @@ public static void createIngressAndRetryIfFail(int maxRetries,
520520
public static String getLbExternalIp(String lbrelname, String lbns) throws Exception {
521521
int i = 0;
522522
LoggingFacade logger = getLogger();
523-
StringBuffer cmd = new StringBuffer();
524-
cmd.append(KUBERNETES_CLI + " get svc ")
525-
.append(lbrelname)
526-
.append(" --namespace ")
527-
.append(lbns)
528-
.append(" -w ");
529-
verifyCommandResultContainsMsg(cmd.toString(), "running");
530-
531-
532523
String cmdip = KUBERNETES_CLI + " get svc --namespace " + lbns
533524
+ " -o jsonpath='{.items[?(@.metadata.name == \"" + lbrelname + "\")]"
534525
+ ".status.loadBalancer.ingress[0].ip}'";
526+
527+
logger.info("Command to retrieve external IP is: {0} ", cmdip);
528+
535529
ExecResult result = exec(cmdip, true);
536530
logger.info("The command returned exit value: " + result.exitValue()
537531
+ " command output: " + result.stderr() + "\n" + result.stdout());
538532

539533
if (result == null || result.exitValue() != 0 || result.stdout() == null) {
540534
return null;
541535
}
542-
logger.info(" LB_PUBLIC_IP = " + result.stdout().trim());
536+
537+
logger.info(" LB_PUBLIC_IP is " + result.stdout().trim());
543538
return result.stdout().trim();
544539
}
545540
}

0 commit comments

Comments
 (0)