Skip to content

Commit 1d68b2e

Browse files
committed
Testing reachability of cluster channel port via test webapp
1 parent 762aa37 commit 1d68b2e

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public void testDomainLifecyle(Operator operator, Domain domain) throws Exceptio
275275
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
276276
}
277277
domain.verifyAdminServerExternalService(getUsername(), getPassword());
278-
domain.verifyHasClusterServiceChannelPort("TCP", 8011);
278+
domain.verifyHasClusterServiceChannelPort("TCP", 8011, TESTWEBAPP + "/");
279279
logger.info("Done - testDomainLifecyle");
280280
}
281281

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,13 @@ public void verifyAdminServerExternalService(String username, String password) t
286286
*
287287
* @param protocol
288288
* @param port
289+
* @param path
289290
* @throws Exception
290291
*/
291-
public void verifyHasClusterServiceChannelPort(String protocol, int port) throws Exception {
292+
public void verifyHasClusterServiceChannelPort(String protocol, int port, String path)
293+
throws Exception {
294+
295+
/* Make sure the service exists in k8s */
292296
if (!TestUtils.checkHasServiceChannelPort(
293297
this.getDomainUid() + "-cluster-" + this.clusterName, domainNS, protocol, port)) {
294298
throw new RuntimeException(
@@ -297,6 +301,35 @@ public void verifyHasClusterServiceChannelPort(String protocol, int port) throws
297301
+ "/"
298302
+ protocol);
299303
}
304+
305+
/* Make sure we can reach the port */
306+
StringBuffer testAppUrl = new StringBuffer("http://");
307+
testAppUrl
308+
.append(this.getDomainUid() + "-cluster-" + this.clusterName)
309+
.append(":")
310+
.append(port)
311+
.append("/");
312+
testAppUrl.append(path);
313+
// curl cmd to call webapp
314+
StringBuffer curlCmd =
315+
new StringBuffer(
316+
"kubectl exec " + this.getDomainUid() + "-" + this.adminServerName + " /usr/bin/curl ");
317+
curlCmd.append(testAppUrl.toString());
318+
319+
// curl cmd to get response code
320+
StringBuffer curlCmdResCode = new StringBuffer(curlCmd.toString());
321+
// -- means pass trailing args to command in exec, not exec itself
322+
curlCmdResCode.append(" -- --write-out %{http_code} -o /dev/null");
323+
324+
logger.info("Curl cmd with response code " + curlCmdResCode);
325+
logger.info("Curl cmd " + curlCmd);
326+
327+
// call webapp iteratively till its deployed/ready
328+
callWebAppAndWaitTillReady(curlCmdResCode.toString());
329+
330+
// execute curl and look for the managed server name in response
331+
callWebAppAndCheckForServerNameInResponse(curlCmd.toString(), true);
332+
logger.info("curlCmd " + curlCmd);
300333
}
301334

302335
/**
@@ -435,8 +468,8 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo
435468
StringBuffer curlCmdResCode = new StringBuffer(curlCmd.toString());
436469
curlCmdResCode.append(" --write-out %{http_code} -o /dev/null");
437470

438-
logger.info("Curd cmd with response code " + curlCmdResCode);
439-
logger.info("Curd cmd " + curlCmd);
471+
logger.info("Curl cmd with response code " + curlCmdResCode);
472+
logger.info("Curl cmd " + curlCmd);
440473

441474
// call webapp iteratively till its deployed/ready
442475
callWebAppAndWaitTillReady(curlCmdResCode.toString());

0 commit comments

Comments
 (0)