Skip to content

Commit 70f9cf7

Browse files
committed
fixed method to retrieve clusterDNS
1 parent 35c6660 commit 70f9cf7

File tree

1 file changed

+39
-0
lines changed
  • integration-tests/src/test/java/oracle/kubernetes/operator/utils

1 file changed

+39
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,39 @@ public static void copyFile(String fromFile, String toFile) throws Exception {
11891189
Files.copy(new File(fromFile).toPath(), Paths.get(toFile), StandardCopyOption.REPLACE_EXISTING);
11901190
}
11911191

1192+
/**
1193+
* retrieve IP address info for cluster service.
1194+
*
1195+
* @param domainUID - name of domain.
1196+
* @param clusterName - name Web Logic cluster
1197+
* @param domainNS - domain namespace
1198+
* @throws Exception - exception will be thrown if kubectl command will fail
1199+
*/
1200+
public static String retrieveClusterIP(String domainUID, String clusterName, String domainNS)
1201+
throws Exception {
1202+
// kubectl get service domainonpvwlst-cluster-cluster-1 | grep ClusterIP | awk '{print $3}'
1203+
StringBuffer cmd = new StringBuffer("kubectl get service ");
1204+
cmd.append(domainUID);
1205+
cmd.append("-cluster-");
1206+
cmd.append(clusterName);
1207+
cmd.append(" -n ").append(domainNS);
1208+
cmd.append(" | grep ClusterIP | awk '{print $3}' ");
1209+
logger.info(
1210+
" Get ClusterIP for "
1211+
+ clusterName
1212+
+ " in namespace "
1213+
+ domainNS
1214+
+ " with command: '"
1215+
+ cmd
1216+
+ "'");
1217+
1218+
ExecResult result = ExecCommand.exec(cmd.toString());
1219+
String stdout = result.stdout();
1220+
logger.info(" ClusterIP for cluster: " + clusterName + " found: ");
1221+
logger.info(stdout);
1222+
return stdout;
1223+
}
1224+
11921225
/**
11931226
* Create dir to save Web Service App files. Copy the shell script file and all App files over to
11941227
* the admin pod Run the shell script to build WARs files and deploy the Web Service App and it's
@@ -1224,6 +1257,7 @@ public static void buildDeployWebServiceAppInPod(
12241257
String domainNS = domain.getDomainNS();
12251258
int managedServerPort = ((Integer) (domain.getDomainMap()).get("managedServerPort")).intValue();
12261259
String wsServiceName = (args.length == 0) ? BaseTest.TESTWSSERVICE : args[0];
1260+
/*
12271261
String clusterDNS =
12281262
domain.getDomainUid()
12291263
+ "-cluster-"
@@ -1232,6 +1266,11 @@ public static void buildDeployWebServiceAppInPod(
12321266
+ domainNS
12331267
+ ".svc.cluster.local:"
12341268
+ managedServerPort;
1269+
*/
1270+
String clusterDNS =
1271+
retrieveClusterIP(domain.getDomainUid(), domain.getClusterName(), domainNS)
1272+
+ ":"
1273+
+ managedServerPort;
12351274
logger.info(
12361275
"Build and deploy WebService App: "
12371276
+ appName

0 commit comments

Comments
 (0)