Skip to content

Commit

Permalink
add check if oc command exists before executing
Browse files Browse the repository at this point in the history
  • Loading branch information
rhmkrutov committed Jan 31, 2025
1 parent ecc311d commit 65fd6be
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ protected void collectTestData() {
}

private void collectResourceStats(String namespace, String dirName) {
LOGGER.debug("[{}] Gathering node/pod resources into files.", namespace);
String topNode = TestUtils.executeLocalCommand("oc adm top node");
String namespacePod = TestUtils.executeLocalCommand("oc adm top pod -n " + namespace);
String nodeFileName = dirName + Constants.FILE_SEPARATOR + "stats_node.log";
String podFileName = dirName + Constants.FILE_SEPARATOR + "stats_pod.log";
TestUtils.createFile(nodeFileName, topNode);
TestUtils.createFile(podFileName, namespacePod);
try {
LOGGER.debug("[{}] Gathering node/pod resources into files.", namespace);
String topNode = TestUtils.executeLocalCommand("oc adm top node");
String namespacePod = TestUtils.executeLocalCommand("oc adm top pod -n " + namespace);
String nodeFileName = dirName + Constants.FILE_SEPARATOR + "stats_node.log";
String podFileName = dirName + Constants.FILE_SEPARATOR + "stats_pod.log";
TestUtils.createFile(nodeFileName, topNode);
TestUtils.createFile(podFileName, namespacePod);
} catch (Exception e) {
LOGGER.warn("[{}] Not gathering node/pod resources into files: oc command returned error", namespace);
e.printStackTrace();
}
}

private void collectBrokerPodFiles(List<Pod> pods, String archiveLocation) {
Expand Down

0 comments on commit 65fd6be

Please sign in to comment.