Search in sources :

Example 86 with TestFailException

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

the class SdxBackupRestoreTest method validateDatalakeRestoreStatus.

private SdxInternalTestDto validateDatalakeRestoreStatus(TestContext testContext, SdxInternalTestDto testDto, SdxClient client) {
    String sdxName = testDto.getName();
    String status;
    String statusReason;
    try {
        restoreId = client.getDefaultClient().sdxRestoreEndpoint().getDatalakeRestoreId(sdxName, null);
        SdxRestoreStatusResponse sdxRestoreStatusResponse = client.getDefaultClient().sdxRestoreEndpoint().getRestoreDatalakeStatus(sdxName, restoreId, null);
        status = sdxRestoreStatusResponse.getStatus();
        statusReason = sdxRestoreStatusResponse.getReason();
        LOGGER.info(format(" SDX '%s' restore '%s' status '%s', because of %s ", sdxName, restoreId, status, statusReason));
    } catch (Exception e) {
        if (e.getMessage().contains("not found")) {
            throw new TestFailException(String.format(" NOT FOUND :: Cannot get status information for restore '%s' on datalake '%s'." + " Please check the selected backup was successful and the related backup ID is correct. ", restoreId, testDto.getName()), e.getCause());
        }
        throw e;
    }
    if (StringUtils.isBlank(status)) {
        LOGGER.error(String.format(" Sdx '%s' restore status is not available ", testDto.getName()));
        throw new TestFailException(String.format(" Sdx '%s' restore status is not available  ", testDto.getName()));
    } else if (status.contains("FAILED")) {
        LOGGER.error(String.format(" Sdx '%s' restore has been failed: '%s' ", testDto.getName(), statusReason));
        throw new TestFailException(String.format(" Sdx '%s' restore has been failed: '%s' ", testDto.getName(), statusReason));
    } else {
        LOGGER.info(String.format(" Sdx '%s' restore has been done with '%s'. ", testDto.getName(), statusReason));
        Log.then(LOGGER, format(" Sdx '%s' restore has been done with '%s'. ", testDto.getName(), statusReason));
    }
    return testDto;
}
Also used : SdxRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 87 with TestFailException

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

the class MockSdxTests method validateSdxStatusReason.

private SdxTestDto validateSdxStatusReason(TestContext testContext, SdxTestDto testDto, SdxClient client) {
    SdxClusterStatusResponse sdxStatus = testDto.getResponse().getStatus();
    if (!SdxClusterStatusResponse.PROVISIONING_FAILED.equals(sdxStatus)) {
        throw new TestFailException("Sdx status is not PROVISIONING_FAILED, current status: " + sdxStatus);
    }
    String statusReason = testDto.getResponse().getStatusReason();
    if (!"Datalake creation failed. Invalid custom instance type for instance group: master - small".equals(statusReason)) {
        throw new TestFailException("Sdx status reason is invalid: " + statusReason);
    }
    return testDto;
}
Also used : TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse)

Example 88 with TestFailException

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

the class SdxRangerRazEnabledTests method testCreateSdxWithRangerRaz.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak", when = "enableRangerRaz is called when Raz is installed", then = "rangerRazEnabled is set for Sdx")
public void testCreateSdxWithRangerRaz(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
    testContext.given(SdxTestDto.class).withExternalDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).withRangerRazEnabled(Boolean.TRUE).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().when(sdxTestClient.enableRangerRaz()).then((tc, testDto, client) -> {
        final boolean rangerRazEnabled = testDto.getResponse().getRangerRazEnabled();
        if (!rangerRazEnabled) {
            throw new TestFailException("Ranger raz was not enabled!");
        }
        return testDto;
    }).validate();
}
Also used : Inject(javax.inject.Inject) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) BadRequestException(javax.ws.rs.BadRequestException) Test(org.testng.annotations.Test) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 89 with TestFailException

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

the class SdxResizeTests method validateShape.

private SdxInternalTestDto validateShape(SdxInternalTestDto dto) {
    SdxClusterShape newShape = dto.getResponse().getClusterShape();
    Log.log(LOGGER, format(" New shape: %s ", newShape.name()));
    if (!SdxClusterShape.MEDIUM_DUTY_HA.equals(newShape)) {
        throw new TestFailException(" The datalake shape is : " + newShape + " instead of: " + SdxClusterShape.MEDIUM_DUTY_HA.name());
    }
    return dto;
}
Also used : TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape)

Example 90 with TestFailException

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

the class EnvironmentEditTest method authenticationEditWhenSetManagedKeyAndNotDeleteExisted.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running cloudbreak with existed ssh key", when = "change existing ssh key to managed one", then = "delete managed ssh key but not create new one")
public void authenticationEditWhenSetManagedKeyAndNotDeleteExisted(MockedTestContext testContext) {
    String randomPublicKeyId = UUID.randomUUID().toString();
    testContext.given(EnvironmentAuthenticationTestDto.class).withPublicKeyId(randomPublicKeyId).withPublicKey(null).given(EnvironmentTestDto.class).withCreateFreeIpa(false).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(EnvironmentAuthenticationTestDto.class).withPublicKey(PUBLIC_KEY).withPublicKeyId(null).given(EnvironmentTestDto.class).when(environmentTestClient.changeAuthentication()).when(environmentTestClient.describe()).then((tc, t, c) -> {
        String publicKeyId = t.getResponse().getAuthentication().getPublicKeyId();
        String publicKey = t.getResponse().getAuthentication().getPublicKey();
        if (randomPublicKeyId.equals(publicKeyId)) {
            throw new TestFailException("The auth public key id was not changed, but it should be changed");
        }
        if (publicKey == null) {
            throw new TestFailException("The auth public key should not be null");
        }
        return t;
    }).validate();
}
Also used : MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) Test(org.testng.annotations.Test) HttpMock(com.sequenceiq.it.cloudbreak.dto.mock.HttpMock) UUID(java.util.UUID) EnvironmentSecurityAccessTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentSecurityAccessTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) EnvironmentAuthenticationTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentAuthenticationTestDto) EnvironmentTestClient(com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Map(java.util.Map) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) BadRequestException(javax.ws.rs.BadRequestException) RunningParameter.expectedMessage(com.sequenceiq.it.cloudbreak.context.RunningParameter.expectedMessage) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) EnvironmentAuthenticationTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentAuthenticationTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

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