use of io.strimzi.test.executor.Exec in project strimzi-kafka-operator by strimzi.
the class OlmResource method parseExamplesFromCsv.
private static Map<String, JsonObject> parseExamplesFromCsv(String csvName, String namespace) {
String csvString = ResourceManager.cmdKubeClient().exec(true, Level.DEBUG, "get", "csv", csvName, "-o", "json", "-n", namespace).out();
JsonObject csv = new JsonObject(csvString);
String almExamples = csv.getJsonObject("metadata").getJsonObject("annotations").getString("alm-examples");
JsonArray examples = new JsonArray(almExamples);
return examples.stream().map(o -> (JsonObject) o).collect(Collectors.toMap(object -> object.getString("kind"), object -> object));
}
use of io.strimzi.test.executor.Exec in project strimzi-kafka-operator by strimzi.
the class MetricsCollector method collectMetrics.
/**
* Collect metrics from specific pod
* @return collected metrics
*/
private String collectMetrics(String metricsPodIp) throws InterruptedException, ExecutionException, IOException {
List<String> executableCommand = Arrays.asList(cmdKubeClient(namespaceName).toString(), "exec", scraperPodName, "-n", namespaceName, "--", "curl", metricsPodIp + ":" + metricsPort + metricsPath);
Exec exec = new Exec();
// 20 seconds should be enough for collect data from the pod
int ret = exec.execute(null, executableCommand, 20_000);
LOGGER.info("Metrics collection for PodIp {} from Pod {} finished with return code: {}", metricsPodIp, scraperPodName, ret);
return exec.out();
}
use of io.strimzi.test.executor.Exec in project strimzi by strimzi.
the class VerifiableClient method runClient.
/**
* Run clients
*
* @param timeoutMs kill timeout in ms
* @return true if command end with exit code 0
*/
private boolean runClient(long timeoutMs, boolean logToOutput) {
messages.clear();
try {
executor = new Exec();
ArrayList<String> command = prepareCommand();
LOGGER.info("Client command: {}", String.join(" ", command));
int ret = executor.execute(null, command, timeoutMs);
synchronized (lock) {
if (logToOutput) {
if (ret == 0) {
parseToList(executor.out());
} else {
LOGGER.info("{} RETURN code: {}", clientType, ret);
if (!executor.out().isEmpty()) {
LOGGER.info("======STDOUT START=======");
LOGGER.info("{}", Exec.cutExecutorLog(executor.out()));
LOGGER.info("======STDOUT END======");
}
if (!executor.err().isEmpty()) {
LOGGER.info("======STDERR START=======");
LOGGER.info("{}", Exec.cutExecutorLog(executor.err()));
LOGGER.info("======STDERR END======");
}
}
}
}
return ret == 0;
} catch (InterruptedException | ExecutionException | IOException e) {
e.printStackTrace();
return false;
}
}
Aggregations