Skip to content

Commit 3cc674c

Browse files
authored
Merge pull request #916 from oracle/owls-71987-debug
OWLS-71987 - Re-enable load balancing test and add logging of service and pods info if it fails
2 parents 0458d27 + ca0ab16 commit 3cc674c

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
315315
+ replicas);
316316
}
317317

318+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
319+
318320
replicas = 2;
319321
podName = domainUid + "-" + managedServerNameBase + (replicas + 1);
320322
logger.info("Scale down to " + replicas + " managed servers");
@@ -331,8 +333,9 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
331333
+ "/"
332334
+ replicas);
333335
}
334-
// commenting the load balance check, bug 29325139
335-
// domain.verifyWebAppLoadBalancing(TESTWEBAPP);
336+
337+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
338+
336339
logger.info("Done - testClusterScaling");
337340
}
338341

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,14 @@ private void callWebAppAndCheckForServerNameInResponse(
10741074
}
10751075
}
10761076
logger.info("ManagedServers " + managedServers);
1077+
10771078
// error if any managedserver value is false
10781079
if (verifyLoadBalancing) {
10791080
for (Map.Entry<String, Boolean> entry : managedServers.entrySet()) {
10801081
if (!entry.getValue().booleanValue()) {
1082+
// print service and pods info for debugging
1083+
TestUtils.describeService(domainNS, domainUid + "-cluster-" + clusterName);
1084+
TestUtils.getPods(domainNS);
10811085
throw new RuntimeException(
10821086
"FAILURE: Load balancer can not reach server " + entry.getKey());
10831087
}

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,52 @@ public static boolean checkHasServiceChannelPort(
253253
return false;
254254
}
255255

256+
/**
257+
* kubectl describe service serviceName -n namespace
258+
*
259+
* @param namespace namespace where the service is located
260+
* @param serviceName name of the service to be described
261+
* @return String containing output of the kubectl describe service command
262+
* @throws Exception
263+
*/
264+
public static String describeService(String namespace, String serviceName) throws Exception {
265+
StringBuffer cmd = new StringBuffer("kubectl describe service ");
266+
cmd.append(serviceName);
267+
cmd.append(" -n ").append(namespace);
268+
logger.info(
269+
" Describe service "
270+
+ serviceName
271+
+ " in namespage "
272+
+ namespace
273+
+ " with command: '"
274+
+ cmd
275+
+ "'");
276+
277+
ExecResult result = ExecCommand.exec(cmd.toString());
278+
String stdout = result.stdout();
279+
logger.info(" Service " + serviceName + " found: ");
280+
logger.info(stdout);
281+
return stdout;
282+
}
283+
284+
/**
285+
* kubectl get pods -o wide -n namespace
286+
*
287+
* @param namespace namespace in which the pods are to be listed
288+
* @return String containing output of the kubectl get pods command
289+
* @throws Exception
290+
*/
291+
public static String getPods(String namespace) throws Exception {
292+
StringBuffer cmd = new StringBuffer("kubectl get pods -o wide ");
293+
cmd.append(" -n ").append(namespace);
294+
logger.info(" Get pods in namespage " + namespace + " with command: '" + cmd + "'");
295+
296+
ExecResult result = ExecCommand.exec(cmd.toString());
297+
String stdout = result.stdout();
298+
logger.info(" Pods found: ");
299+
logger.info(stdout);
300+
return stdout;
301+
}
256302
/**
257303
* First, kill the mgd server process in the container three times to cause the node manager to
258304
* mark the server 'failed not restartable'. This in turn is detected by the liveness probe, which

0 commit comments

Comments
 (0)