Search in sources :

Example 46 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class AwsCloudProvider method getPreviousPreWarmedImageID.

@Override
public String getPreviousPreWarmedImageID(TestContext testContext, ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient) {
    if (awsProperties.getBaseimage().getImageId() == null || awsProperties.getBaseimage().getImageId().isEmpty()) {
        try {
            List<ImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, CloudPlatform.AWS.name(), null, null, false).getCdhImages();
            ImageV4Response olderImage = images.get(images.size() - 2);
            Log.log(LOGGER, format(" Image Catalog Name: %s ", imageCatalogTestDto.getRequest().getName()));
            Log.log(LOGGER, format(" Image Catalog URL: %s ", imageCatalogTestDto.getRequest().getUrl()));
            Log.log(LOGGER, format(" Selected Pre-warmed Image Date: %s | ID: %s | Description: %s | Stack Version: %s ", olderImage.getDate(), olderImage.getUuid(), olderImage.getStackDetails().getVersion(), olderImage.getDescription()));
            awsProperties.getBaseimage().setImageId(olderImage.getUuid());
            return olderImage.getUuid();
        } catch (Exception e) {
            LOGGER.error("Cannot fetch pre-warmed images of {} image catalog!", imageCatalogTestDto.getRequest().getName());
            throw new TestFailException(" Cannot fetch pre-warmed images of " + imageCatalogTestDto.getRequest().getName() + " image catalog!", e);
        }
    } else {
        Log.log(LOGGER, format(" Image Catalog Name: %s ", commonCloudProperties().getImageCatalogName()));
        Log.log(LOGGER, format(" Image Catalog URL: %s ", commonCloudProperties().getImageCatalogUrl()));
        Log.log(LOGGER, format(" Image ID for SDX create: %s ", awsProperties.getBaseimage().getImageId()));
        return awsProperties.getBaseimage().getImageId();
    }
}
Also used : ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 47 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class AwsCloudProviderAssertion method assertServiceEndpoint.

@Override
public void assertServiceEndpoint(EnvironmentTestDto environmentTestDto) {
    ServiceEndpointCreation serviceEndpointCreationRequest = Optional.ofNullable(environmentTestDto.getRequest().getNetwork().getServiceEndpointCreation()).orElse(ServiceEndpointCreation.DISABLED);
    ServiceEndpointCreation serviceEndpointCreationResponse = environmentTestDto.getResponse().getNetwork().getServiceEndpointCreation();
    if (serviceEndpointCreationResponse != serviceEndpointCreationRequest) {
        String message = String.format("Service endpoint creation is expected to be %s, but is %s", serviceEndpointCreationRequest, serviceEndpointCreationResponse);
        LOGGER.error(message);
        throw new TestFailException(message);
    }
}
Also used : ServiceEndpointCreation(com.sequenceiq.common.api.type.ServiceEndpointCreation) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 48 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class AbstractCloudProvider method getLatestBaseImage.

public String getLatestBaseImage(ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient, String platform, boolean govCloud) {
    try {
        List<BaseImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, platform, null, null, govCloud).getBaseImages();
        if (images.size() == 0) {
            throw new IllegalStateException("Images are empty, there is not any base image on provider " + platform);
        }
        BaseImageV4Response baseImage = images.get(images.size() - 1);
        Log.log(LOGGER, format(" Image Catalog Name: %s ", imageCatalogTestDto.getRequest().getName()));
        Log.log(LOGGER, format(" Image Catalog URL: %s ", imageCatalogTestDto.getRequest().getUrl()));
        Log.log(LOGGER, format(" Selected Base Image Date: %s | ID: %s | Description: %s ", baseImage.getDate(), baseImage.getUuid(), baseImage.getDescription()));
        return baseImage.getUuid();
    } catch (Exception e) {
        LOGGER.error("Cannot fetch base images of {} image catalog, because of {}", imageCatalogTestDto.getRequest().getName(), e);
        throw new TestFailException(" Cannot fetch base images of " + imageCatalogTestDto.getRequest().getName() + " image catalog", e);
    }
}
Also used : BaseImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.BaseImageV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 49 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class ClouderaManagerClientActions method checkCmHdfsNamenodeRoleConfigGroups.

public DistroXTestDto checkCmHdfsNamenodeRoleConfigGroups(DistroXTestDto testDto, String user, String password, Set<String> mountPoints) {
    String serverIp = testDto.getResponse().getCluster().getServerIp();
    ApiClient apiClient = getCmApiClientWithTimeoutDisabled(serverIp, testDto.getName(), V_43, user, password);
    // CHECKSTYLE:OFF
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = new RoleConfigGroupsResourceApi(apiClient);
    // CHECKSTYLE:ON
    try {
        ApiConfigList hdfsConfigs = roleConfigGroupsResourceApi.readConfig(testDto.getName(), "hdfs-NAMENODE-BASE", "hdfs", "summary");
        hdfsConfigs.getItems().forEach(config -> {
            String hdfsConfigName = config.getName();
            String mappingsFromHdfsConfig = config.getValue();
            if ("dfs_name_dir_list".equalsIgnoreCase(hdfsConfigName)) {
                if (mountPoints.stream().anyMatch(mappingsFromHdfsConfig::startsWith)) {
                    LOGGER.error("{} contains ephemeral volume mapping '{}'!", hdfsConfigName, mappingsFromHdfsConfig);
                    throw new TestFailException(String.format("%s contains ephemeral volume mapping '%s'!", hdfsConfigName, mappingsFromHdfsConfig));
                } else {
                    Log.log(LOGGER, format(" '%s' does not contain the ephemeral mapping '%s', as expected. ", hdfsConfigName, mappingsFromHdfsConfig));
                }
            }
        });
        if (hdfsConfigs.getItems().isEmpty()) {
            LOGGER.error("Namenode mappings are NOT exist!");
            throw new TestFailException("Namenode 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 read config at: '{}'!", apiClient.getBasePath());
        throw new TestFailException("Can't read config at: " + apiClient.getBasePath(), e);
    }
    return testDto;
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 50 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class ClouderaManagerClientActions method checkCmYarnNodemanagerRoleConfigGroups.

private DistroXTestDto checkCmYarnNodemanagerRoleConfigGroups(ApiClient apiClient, DistroXTestDto testDto, String user, String password) {
    // CHECKSTYLE:OFF
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = new RoleConfigGroupsResourceApi(apiClient);
    // CHECKSTYLE:ON
    try {
        ApiConfigList knoxConfigs = roleConfigGroupsResourceApi.readConfig(testDto.getName(), "yarn-NODEMANAGER-BASE", "yarn", "full");
        knoxConfigs.getItems().stream().forEach(knoxConfig -> {
            String knoxConfigName = knoxConfig.getName();
            String mappingsFromKnoxConfig = knoxConfig.getValue();
            if ("yarn_nodemanager_local_dirs".equalsIgnoreCase(knoxConfigName)) {
                if (!mappingsFromKnoxConfig.startsWith("/hadoopfs/ephfs")) {
                    LOGGER.error("{} does not contains the expected '/hadoopfs/ephfs...' mapping!", knoxConfigName);
                    throw new TestFailException(String.format("%s does not contains the expected '/hadoopfs/ephfs...' mapping!", knoxConfigName));
                } else {
                    Log.log(LOGGER, format(" '%s' contains the expected '%s' mapping. ", knoxConfigName, mappingsFromKnoxConfig));
                }
            }
        });
        if (knoxConfigs.getItems().isEmpty()) {
            LOGGER.error("Nodemanager mappings are NOT exist!");
            throw new TestFailException("Nodemanager 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 role configs at: '{}'!", apiClient.getBasePath());
        throw new TestFailException("Can't get role configs at: " + apiClient.getBasePath(), e);
    }
    return testDto;
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiException(com.cloudera.api.swagger.client.ApiException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiException(com.cloudera.api.swagger.client.ApiException)

Aggregations

TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)101 List (java.util.List)15 Inject (javax.inject.Inject)14 Map (java.util.Map)13 Description (com.sequenceiq.it.cloudbreak.context.Description)12 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Test (org.testng.annotations.Test)12 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 Log (com.sequenceiq.it.cloudbreak.log.Log)9 String.format (java.lang.String.format)9 Collectors (java.util.stream.Collectors)9 FreeIpaTestDto (com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto)8 SdxTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto)8 IOException (java.io.IOException)8 URISyntaxException (java.net.URISyntaxException)8 ArrayList (java.util.ArrayList)8 Set (java.util.Set)8