Skip to content

Commit 1225c90

Browse files
authored
Merge pull request #854 from oracle/feature/OWLS-70864-integ
Test Network Access Point on WL Clusters
2 parents 2f1ff60 + 7ad9f9d commit 1225c90

File tree

5 files changed

+138
-21
lines changed

5 files changed

+138
-21
lines changed

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public void testAdminT3ChannelWithJMS(Domain domain) throws Exception {
251251
c.close();
252252
logger.info("Done - testAdminT3ChannelWithJMS");
253253
}
254+
254255
/**
255256
* Restarting the domain should not have any impact on Operator managing the domain, web app load
256257
* balancing and node port service
@@ -271,6 +272,7 @@ public void testDomainLifecyle(Operator operator, Domain domain) throws Exceptio
271272
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
272273
}
273274
domain.verifyAdminServerExternalService(getUsername(), getPassword());
275+
domain.verifyHasClusterServiceChannelPort("TCP", 8011, TESTWEBAPP + "/");
274276
logger.info("Done - testDomainLifecyle");
275277
}
276278

@@ -315,22 +317,23 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
315317

316318
// make sure cluster service endpoint is updated with the scaled up servers before verifying
317319
// load balancing
318-
int i = 0;
319-
while (i < BaseTest.getMaxIterationsPod()) {
320-
int numberOfServersInEndpoint =
321-
domain.getNumberOfServersInClusterServiceEndpoint((String) domainMap.get("clusterName"));
322-
if (replicaCnt != numberOfServersInEndpoint) {
323-
// check for last iteration
324-
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
325-
throw new RuntimeException("FAILURE: Cluster Serice Endpoint is not updated");
326-
}
327-
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
328-
i++;
329-
} else {
330-
logger.info("Number of servers addresses in endpoint is same as replica count ");
331-
break;
332-
}
333-
}
320+
// int i = 0;
321+
// while (i < BaseTest.getMaxIterationsPod()) {
322+
// int numberOfServersInEndpoint =
323+
// domain.getNumberOfServersInClusterServiceEndpoint((String)
324+
// domainMap.get("clusterName"));
325+
// if (replicaCnt != numberOfServersInEndpoint) {
326+
// // check for last iteration
327+
// if (i == (BaseTest.getMaxIterationsPod() - 1)) {
328+
// throw new RuntimeException("FAILURE: Cluster Serice Endpoint is not updated");
329+
// }
330+
// Thread.sleep(BaseTest.getWaitTimePod() * 1000);
331+
// i++;
332+
// } else {
333+
// logger.info("Number of servers addresses in endpoint is same as replica count ");
334+
// break;
335+
// }
336+
// }
334337
// commenting the load balance check, bug 29325139
335338
// domain.verifyWebAppLoadBalancing(TESTWEBAPP);
336339

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
433433
// load input yaml to map and add configOverrides
434434
Map<String, Object> domainMap = TestUtils.loadYaml(domainonpvwlstFile);
435435
domainMap.put("configOverrides", "sitconfigcm");
436+
domainMap.put(
437+
"configOverridesFile",
438+
"/integration-tests/src/test/resources/domain-home-on-pv/customsitconfig");
436439
domainMap.put("domainUID", "customsitdomain");
437440
domainMap.put("adminNodePort", new Integer("30704"));
438441
domainMap.put("t3ChannelPort", new Integer("30051"));

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

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public void verifyServersReady() throws Exception {
234234
}
235235
}
236236
}
237+
237238
/**
238239
* verify nodeport by accessing admin REST endpoint
239240
*
@@ -280,6 +281,73 @@ public void verifyAdminServerExternalService(String username, String password) t
280281
}
281282
}
282283

284+
/**
285+
* Verify that we have the channel set for the cluster
286+
*
287+
* @param protocol
288+
* @param port
289+
* @param path
290+
* @throws Exception
291+
*/
292+
public void verifyHasClusterServiceChannelPort(String protocol, int port, String path)
293+
throws Exception {
294+
295+
/* Make sure the service exists in k8s */
296+
if (!TestUtils.checkHasServiceChannelPort(
297+
this.getDomainUid() + "-cluster-" + this.clusterName, domainNS, protocol, port)) {
298+
throw new RuntimeException(
299+
"FAILURE: Cannot find channel port in cluster, but expecting one: "
300+
+ port
301+
+ "/"
302+
+ protocol);
303+
}
304+
305+
/*
306+
* Construct a curl command that will be run via kubectl exec on the admin server
307+
*/
308+
StringBuffer curlCmd =
309+
new StringBuffer(
310+
"kubectl exec " + this.getDomainUid() + "-" + this.adminServerName + " /usr/bin/curl ");
311+
312+
/*
313+
* Make sure we can reach the port,
314+
* first via each managed server URL
315+
*/
316+
for (int i = 1; i <= TestUtils.getClusterReplicas(domainUid, clusterName, domainNS); i++) {
317+
StringBuffer serverAppUrl = new StringBuffer("http://");
318+
serverAppUrl
319+
.append(this.getDomainUid() + "-" + managedServerNameBase + i)
320+
.append(":")
321+
.append(port)
322+
.append("/");
323+
serverAppUrl.append(path);
324+
325+
callWebAppAndWaitTillReady(
326+
new StringBuffer(curlCmd.toString())
327+
.append(serverAppUrl.toString())
328+
.append(" -- --write-out %{http_code} -o /dev/null")
329+
.toString());
330+
}
331+
332+
/*
333+
* Make sure we can reach the port,
334+
* second via cluster URL which should round robin through each managed server.
335+
* Use the callWebAppAndCheckForServerNameInResponse method with verifyLoadBalancing
336+
* enabled to verify each managed server is responding.
337+
*/
338+
StringBuffer clusterAppUrl = new StringBuffer("http://");
339+
clusterAppUrl
340+
.append(this.getDomainUid() + "-cluster-" + this.clusterName)
341+
.append(":")
342+
.append(port)
343+
.append("/");
344+
clusterAppUrl.append(path);
345+
346+
// execute curl and look for each managed server name in response
347+
callWebAppAndCheckForServerNameInResponse(
348+
new StringBuffer(curlCmd.toString()).append(clusterAppUrl.toString()).toString(), true);
349+
}
350+
283351
/**
284352
* deploy webapp using nodehost and nodeport
285353
*
@@ -416,8 +484,8 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo
416484
StringBuffer curlCmdResCode = new StringBuffer(curlCmd.toString());
417485
curlCmdResCode.append(" --write-out %{http_code} -o /dev/null");
418486

419-
logger.info("Curd cmd with response code " + curlCmdResCode);
420-
logger.info("Curd cmd " + curlCmd);
487+
logger.info("Curl cmd with response code " + curlCmdResCode);
488+
logger.info("Curl cmd " + curlCmd);
421489

422490
// call webapp iteratively till its deployed/ready
423491
callWebAppAndWaitTillReady(curlCmdResCode.toString());
@@ -1102,9 +1170,12 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
11021170
domainMap.values().removeIf(Objects::isNull);
11031171

11041172
// create config map and secret for custom sit config
1105-
if (domainMap.get("configOverrides") != null) {
1173+
if ((domainMap.get("configOverrides") != null)
1174+
&& (domainMap.get("configOverridesFile") != null)) {
11061175
// write hostname in config file for public address
11071176

1177+
String configOverridesFile = domainMap.get("configOverridesFile").toString();
1178+
11081179
String cmd =
11091180
"kubectl -n "
11101181
+ domainNS
@@ -1114,7 +1185,7 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
11141185
+ domainMap.get("configOverrides")
11151186
+ " --from-file "
11161187
+ BaseTest.getProjectRoot()
1117-
+ "/integration-tests/src/test/resources/domain-home-on-pv/customsitconfig";
1188+
+ configOverridesFile;
11181189
ExecResult result = ExecCommand.exec(cmd);
11191190
if (result.exitValue() != 0) {
11201191
throw new RuntimeException(

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,39 @@ public static boolean checkPVReleased(String pvBaseName, String namespace) throw
220220
}
221221
return true;
222222
}
223+
224+
/**
225+
* NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) domain1-cluster-cluster-1 ClusterIP 10.105.146.61
226+
* <none> 30032/TCP,8001/TCP domain1-managed-server1 ClusterIP None <none> 30032/TCP,8001/TCP
227+
*
228+
* @param service
229+
* @param namespace
230+
* @param protocol
231+
* @param port
232+
* @return
233+
* @throws Exception
234+
*/
235+
public static boolean checkHasServiceChannelPort(
236+
String service, String namespace, String protocol, int port) throws Exception {
237+
StringBuffer cmd = new StringBuffer("kubectl get services ");
238+
cmd.append(" -n ").append(namespace);
239+
logger.info(" Find services in namespage " + namespace + " with command: '" + cmd + "'");
240+
241+
ExecResult result = ExecCommand.exec(cmd.toString());
242+
String stdout = result.stdout();
243+
logger.info(" Services found: ");
244+
logger.info(stdout);
245+
String stdoutlines[] = stdout.split("\\r?\\n");
246+
if (result.exitValue() == 0 && stdoutlines.length > 0) {
247+
for (String stdoutline : stdoutlines) {
248+
if (stdoutline.contains(service) && stdoutline.contains(port + "/" + protocol)) {
249+
return true;
250+
}
251+
}
252+
}
253+
return false;
254+
}
255+
223256
/**
224257
* First, kill the mgd server process in the container three times to cause the node manager to
225258
* mark the server 'failed not restartable'. This in turn is detected by the liveness probe, which

integration-tests/src/test/resources/domain-home-on-pv/create-domain.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,15 @@ def getEnvVar(var):
100100
cd('/ServerTemplates/%s' % templateName)
101101
cmo.setListenPort(server_port)
102102
cmo.setCluster(cl)
103-
print('Done setting attributes for Server Template: %s' % templateName);
104103

104+
templateChannelName = cluster_name + "-NAP"
105+
print('Creating Server Template NAP: %s' % cluster_name + "-NAP")
106+
create(templateChannelName, 'NetworkAccessPoint')
107+
cd('NetworkAccessPoints/%s' % templateChannelName)
108+
set('PublicPort', server_port + 10)
109+
set('ListenPort', server_port + 10)
110+
print('Done creating Server Template NAP: %s' % cluster_name + "-NAP")
111+
print('Done setting attributes for Server Template: %s' % templateName);
105112

106113
cd('/Clusters/%s' % cluster_name)
107114
create(cluster_name, 'DynamicServers')

0 commit comments

Comments
 (0)