use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClientActions method checkAzureTemporalDisksMounted.
public void checkAzureTemporalDisksMounted(List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames, String mountDir) {
Map<String, Pair<Integer, String>> deviceMountPointMappingsByIp = getDeviceMountPointMappingsByIp(instanceGroups, hostGroupNames, mountDir);
deviceMountPointMappingsByIp.forEach((ip, outPair) -> {
if (StringUtils.isBlank(outPair.getValue()) || outPair.getKey() != 0) {
LOGGER.error("No mount point found '{}' on node with IP {}!", mountDir, ip);
throw new TestFailException(format("No mount point found '%s' on node with IP %s!", mountDir, ip));
} else if (!StringUtils.containsIgnoreCase(outPair.getValue(), mountDir)) {
LOGGER.error("Device incorrectly mounted to '{}' on node with IP {}!", mountDir, ip);
throw new TestFailException(format("Device incorrectly mounted to '%s' on node with IP %s!", mountDir, ip));
}
});
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClientActions method checkAwsEphemeralDisksMounted.
public void checkAwsEphemeralDisksMounted(List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames, String mountDirPrefix) {
Map<String, Pair<Integer, String>> deviceMountPointMappingsByIp = getDeviceMountPointMappingsByIp(instanceGroups, hostGroupNames, "hadoopfs");
Map<String, Pair<Integer, String>> deviceDiskTypeMappingsByIp = getDeviceDiskTypeMappingsByIp(instanceGroups, hostGroupNames);
for (Entry<String, Pair<Integer, String>> node : deviceDiskTypeMappingsByIp.entrySet()) {
Map<String, String> ephemeralDisks = new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("Amazon EC2 NVMe Instance Storage")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
if (ephemeralDisks.isEmpty()) {
LOGGER.error("Instance store volume missing from node with IP {}!", node.getKey());
throw new TestFailException(format("Instance store volume missing from node with IP %s!", node.getKey()));
}
if (deviceMountPointMappingsByIp.get(node.getKey()) == null) {
LOGGER.error("No device mount point mappings found for node with IP {}!", node.getKey());
throw new TestFailException(format("No device mount point mappings found for node with IP %s!", node.getKey()));
}
Map<String, String> mountPoints = new Json(deviceMountPointMappingsByIp.get(node.getKey()).getValue()).getMap().entrySet().stream().collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
for (String device : ephemeralDisks.keySet()) {
String mountPoint = mountPoints.get(device);
if (mountPoint == null) {
LOGGER.error("No mount point found for ephemeral device {} on node with IP {}!", device, node.getKey());
throw new TestFailException(format("No mount point found for device %s on node with IP %s!", device, node.getKey()));
} else if (!mountPoint.contains(mountDirPrefix)) {
LOGGER.error("Ephemeral device {} incorrectly mounted to {} on node with IP {}!", device, mountPoint, node.getKey());
throw new TestFailException(format("Ephemeral device %s incorrectly mounted to %s on node with IP %s!", device, mountPoint, node.getKey()));
}
}
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClient method createSshClient.
protected SSHClient createSshClient(String host, String user, String password, String privateKeyFilePath) throws IOException {
SSHClient client = new SSHClient();
client.addHostKeyVerifier(new PromiscuousVerifier());
client.connect(host, 22);
client.setConnectTimeout(120000);
if (StringUtils.isBlank(user) && StringUtils.isBlank(privateKeyFilePath)) {
LOGGER.info("Creating SSH client on '{}' host with 'cloudbreak' user and defaultPrivateKeyFile from application.yml.", host);
client.authPublickey("cloudbreak", defaultPrivateKeyFilePath);
Log.log(LOGGER, format(" SSH client has been authenticated with 'cloudbreak' user and key file: [%s] at [%s] host. ", client.isAuthenticated(), client.getRemoteHostname()));
} else if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(privateKeyFilePath)) {
LOGGER.info("Creating SSH client on '{}' host with user: '{}' and key file: '{}'.", host, user, privateKeyFilePath);
client.authPublickey(user, privateKeyFilePath);
Log.log(LOGGER, format(" SSH client has been authenticated with user (%s) and key file: [%s] at [%s] host. ", user, client.isAuthenticated(), client.getRemoteHostname()));
} else if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(password)) {
LOGGER.info("Creating SSH client on '{}' host with user: '{}' and password: '{}'.", host, user, password);
client.authPassword(user, password);
Log.log(LOGGER, format(" SSH client has been authenticated with user (%s) and password: [%s] at [%s] host. ", user, client.isAuthenticated(), client.getRemoteHostname()));
} else {
LOGGER.error("Creating SSH client is not possible, because of host: '{}', user: '{}', password: '{}' and privateKey: '{}' are missing!", host, user, password, privateKeyFilePath);
throw new TestFailException(String.format("Creating SSH client is not possible, because of host: '%s', user: '%s', password: '%s'" + " and privateKey: '%s' are missing!", host, user, password, privateKeyFilePath));
}
return client;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClient method executeCommand.
protected Pair<Integer, String> executeCommand(String instanceIP, String command) {
try (SSHClient sshClient = createSshClient(instanceIP, null, null, null)) {
Pair<Integer, String> cmdOut = execute(sshClient, command);
Log.log(LOGGER, format("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, e.getMessage());
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 ClouderaManagerClientActions method checkCmKnoxIDBrokerRoleConfigGroups.
public SdxInternalTestDto checkCmKnoxIDBrokerRoleConfigGroups(SdxInternalTestDto testDto, String user, String password) {
String serverFqdn = testDto.getResponse().getStackV4Response().getCluster().getServerFqdn();
ApiClient apiClient = getCmApiClient(serverFqdn, testDto.getName(), V_43, user, password);
// CHECKSTYLE:OFF
RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = new RoleConfigGroupsResourceApi(apiClient);
// CHECKSTYLE:ON
try {
ApiConfigList knoxConfigs = roleConfigGroupsResourceApi.readConfig(testDto.getName(), "knox-IDBROKER-BASE", "knox", "full");
knoxConfigs.getItems().stream().forEach(knoxConfig -> {
String knoxConfigName = knoxConfig.getName();
String mappingsFromKnoxConfig = knoxConfig.getValue();
if (String.join("_", "idbroker", cloudProvider, "group", "mapping").equalsIgnoreCase(knoxConfigName)) {
if (!mappingsFromKnoxConfig.contains("_c_cm_admins_")) {
LOGGER.error("{} does not contains the expected 'CM Admins' mapping!", knoxConfigName);
throw new TestFailException(String.format("%s does not contains the expected 'CM Admins' mapping!", knoxConfigName));
} else {
Log.log(LOGGER, format(" '%s' contains the expected '%s' mapping. ", knoxConfigName, mappingsFromKnoxConfig));
}
} else if (String.join("_", "idbroker", cloudProvider, "user", "mapping").equalsIgnoreCase(knoxConfigName)) {
if (!mappingsFromKnoxConfig.contains("hive")) {
LOGGER.error("{} does not contains the expected 'Hive' mapping!", knoxConfigName);
throw new TestFailException(String.format("%s does not contains the expected 'Hive' mapping!", knoxConfigName));
} else {
Log.log(LOGGER, format(" '%s' contains the expected ['%s'] mappings. ", knoxConfigName, mappingsFromKnoxConfig));
}
}
});
if (knoxConfigs.getItems().isEmpty()) {
LOGGER.error("IDBroker mappings are NOT exist!");
throw new TestFailException("IDBroker mappings are NOT exist!");
}
} catch (ApiException e) {
LOGGER.error("Exception when calling RoleConfigGroupsResourceApi#readConfig. Response: {}", e.getResponseBody(), e);
String message = format("Exception when calling RoleConfigGroupsResourceApi#readConfig at %s. Response: %s", apiClient.getBasePath(), e.getResponseBody());
throw new TestFailException(message, e);
} catch (Exception e) {
LOGGER.error("Can't get users' list at: '{}'!", apiClient.getBasePath());
throw new TestFailException("Can't get users' list at: " + apiClient.getBasePath(), e);
}
return testDto;
}
Aggregations