Skip to content

Commit d00e454

Browse files
committed
more debugging - print pods info as well
1 parent d90f618 commit d00e454

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

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

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

318-
// print services (TODO- only if failed)
319-
TestUtils.getServices(domainNS);
318+
// print service (TODO- only if failed)
319+
TestUtils.describeService(domainNS, domainUid + "-cluster-" + clusterName);
320+
TestUtils.getPods(domainNS);
320321

321322
// commenting the load balance check, bug 29325139
322323
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
@@ -338,7 +339,7 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
338339
+ replicas);
339340
}
340341
// print services (TODO- only if failed)
341-
TestUtils.getServices(domainNS);
342+
TestUtils.describeService(domainNS, domainUid + "-cluster-" + clusterName);
342343

343344
// commenting the load balance check, bug 29325139
344345
domain.verifyWebAppLoadBalancing(TESTWEBAPP);

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

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ public static boolean checkHasServiceChannelPort(
239239
logger.info(" Find services in namespage " + namespace + " with command: '" + cmd + "'");
240240

241241
ExecResult result = ExecCommand.exec(cmd.toString());
242-
String stdout = getServices(namespace);
242+
String stdout = result.stdout();
243+
logger.info(" Services found: ");
244+
logger.info(stdout);
243245
String stdoutlines[] = stdout.split("\\r?\\n");
244246
if (result.exitValue() == 0 && stdoutlines.length > 0) {
245247
for (String stdoutline : stdoutlines) {
@@ -251,18 +253,52 @@ public static boolean checkHasServiceChannelPort(
251253
return false;
252254
}
253255

254-
public static String getServices(String namespace) throws Exception {
255-
StringBuffer cmd = new StringBuffer("kubectl get services ");
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);
256267
cmd.append(" -n ").append(namespace);
257-
logger.info(" Find services in namespage " + namespace + " with command: '" + cmd + "'");
268+
logger.info(
269+
" Describe service "
270+
+ serviceName
271+
+ " in namespage "
272+
+ namespace
273+
+ " with command: '"
274+
+ cmd
275+
+ "'");
258276

259277
ExecResult result = ExecCommand.exec(cmd.toString());
260278
String stdout = result.stdout();
261-
logger.info(" Services found: ");
279+
logger.info(" Service " + serviceName + " found: ");
262280
logger.info(stdout);
263281
return stdout;
264282
}
265283

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+
}
266302
/**
267303
* First, kill the mgd server process in the container three times to cause the node manager to
268304
* mark the server 'failed not restartable'. This in turn is detected by the liveness probe, which

0 commit comments

Comments
 (0)