use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class CloudbreakInstanceWaitObject method fetchData.
@Override
public void fetchData() {
try {
instanceGroups = testContext.getMicroserviceClient(CloudbreakClient.class).getDefaultClient().distroXV1Endpoint().getByName(name, Set.of()).getInstanceGroups();
instanceResourceType = "Data Hub";
} catch (NotFoundException e) {
LOGGER.info("SDX '{}' instance groups are present for validation.", name);
instanceGroups = testContext.getSdxClient().getDefaultClient().sdxEndpoint().getDetail(name, Set.of()).getStackV4Response().getInstanceGroups();
} catch (Exception e) {
LOGGER.error("Instance groups cannot be determined, because of: {}", e.getMessage(), e);
throw new TestFailException("Instance groups cannot be determined", e);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshEnaDriverCheckActions method getInstanceMetadata.
private InstanceMetaDataV4Response getInstanceMetadata(String name, CloudbreakClient cloudbreakClient, String group) {
InstanceMetaDataV4Response instanceMetaDataResponse = cloudbreakClient.getDefaultClient().distroXV1Endpoint().getByName(name, Collections.emptySet()).getInstanceGroups().stream().filter(ig -> group.equals(ig.getName())).findFirst().orElseThrow(() -> new TestFailException("Cannot find " + group + " for " + name)).getMetadata().stream().findFirst().orElseThrow(() -> new TestFailException("Cannot find metadata in " + group + " for " + name));
LOGGER.info("The selected Instance Group [{}] and the available Private IP [{}] and Public IP [{}]]", group, instanceMetaDataResponse.getPrivateIp(), instanceMetaDataResponse.getPublicIp());
return instanceMetaDataResponse;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClientActions method checkMeteringStatus.
public DistroXTestDto checkMeteringStatus(DistroXTestDto testDto, List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames) {
String meteringStatusCommand = "sudo cdp-doctor metering status --format json";
Map<String, Pair<Integer, String>> meteringStatusReportByIp = getInstanceGroupIps(instanceGroups, hostGroupNames, false).stream().collect(Collectors.toMap(ip -> ip, ip -> executeSshCommand(ip, meteringStatusCommand)));
for (Entry<String, Pair<Integer, String>> meteringStatusReport : meteringStatusReportByIp.entrySet()) {
List<Integer> heartbeatEventCounts = new Json(meteringStatusReport.getValue().getValue()).getMap().entrySet().stream().filter(status -> String.valueOf(status.getKey()).contains("heartbeatEventCount")).map(Entry::getValue).collect(Collectors.toList()).stream().map(countObject -> (Integer) countObject).collect(Collectors.toList());
LOGGER.info(format("heartbeatEventCounts: %s", heartbeatEventCounts));
Log.log(LOGGER, format(" Found '%s' Metering Heartbeat Events at '%s' instance. ", heartbeatEventCounts, meteringStatusReport.getKey()));
if (CollectionUtils.isEmpty(heartbeatEventCounts) || heartbeatEventCounts.contains(0)) {
LOGGER.error("Metering Heartbeat Events does NOT generated on '{}' instance!", meteringStatusReport.getKey());
throw new TestFailException(format("Metering Heartbeat Events does NOT generated on '%s' instance!", meteringStatusReport.getKey()));
}
}
for (Entry<String, Pair<Integer, String>> meteringStatusReport : meteringStatusReportByIp.entrySet()) {
List<String> heartbeatStatusesNotOk = new Json(meteringStatusReport.getValue().getValue()).getMap().entrySet().stream().filter(status -> String.valueOf(status.getValue()).contains("NOK")).map(Entry::getKey).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(heartbeatStatusesNotOk)) {
heartbeatStatusesNotOk.forEach(event -> {
if (StringUtils.containsIgnoreCase(event, "databusReachable")) {
Log.log(LOGGER, format(" Found 'databusReachable' status is not OK at '%s' instance. However this is acceptable!", meteringStatusReport.getKey()));
LOGGER.warn("Found 'databusReachable' status is not OK at '{}' instance. However this is acceptable!", meteringStatusReport.getKey());
} else {
Log.log(LOGGER, format(" Found '%s' not OK at '%s' instance. ", event, meteringStatusReport.getKey()));
LOGGER.error("There is 'Not OK' Metering Heartbeat status {} is present on '{}' instance!", event, meteringStatusReport.getKey());
throw new TestFailException(format("There is 'Not OK' Metering Heartbeat status %s is present on '%s' instance!", event, meteringStatusReport.getKey()));
}
});
}
}
return testDto;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClientActions method executeSshCommand.
private Pair<Integer, String> executeSshCommand(String instanceIp, String user, String password, String privateKeyFilePath, String command) {
try (SSHClient sshClient = createSshClient(instanceIp, user, password, privateKeyFilePath)) {
Pair<Integer, String> cmdOut = execute(sshClient, command);
Log.log(LOGGER, " Command exit status '%s' and result '%s'. ", cmdOut.getKey(), cmdOut.getValue());
return cmdOut;
} catch (Exception e) {
LOGGER.error("SSH fail on [{}] while executing command [{}]", instanceIp, command);
throw new TestFailException(" SSH fail on [" + instanceIp + "] while executing command [" + command + "].", e);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClientActions method executefileListCommand.
private long executefileListCommand(String instanceIP, String user, String password, String fileListCommand) {
AtomicLong quantity = new AtomicLong(0);
try {
Pair<Integer, String> cmdOut = executeSshCommand(instanceIP, user, password, fileListCommand);
Log.log(LOGGER, " Command exit status '%s' and result '%s'. ", cmdOut.getKey(), cmdOut.getValue());
List<String> cmdOutputValues = Stream.of(cmdOut.getValue().split("[\\r\\n\\t]")).filter(Objects::nonNull).collect(Collectors.toList());
boolean fileFound = cmdOutputValues.stream().anyMatch(outputValue -> outputValue.strip().startsWith("/"));
String foundFilePath = cmdOutputValues.stream().filter(outputValue -> outputValue.strip().startsWith("/")).findFirst().orElse(null);
Log.log(LOGGER, format(" The file is present '%s' at '%s' path. ", fileFound, foundFilePath));
quantity.set(cmdOutputValues.stream().filter(outputValue -> outputValue.strip().startsWith("/")).count());
} catch (Exception e) {
LOGGER.error("SSH fail on '{}' host while running command: [{}]", instanceIP, fileListCommand);
throw new TestFailException(format(" SSH fail on '%s' host while running command: [%s]! ", instanceIP, fileListCommand), e);
}
return quantity.get();
}
Aggregations