Search in sources :

Example 41 with TestFailException

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

the class SdxRecoveryTests method validateImageId.

private SdxTestDto validateImageId(AtomicReference<String> originalImageId, SdxTestDto dto) {
    StackImageV4Response image = dto.getResponse().getStackV4Response().getImage();
    Log.log(LOGGER, format(" Image Catalog Name: %s ", image.getCatalogName()));
    Log.log(LOGGER, format(" Image Catalog URL: %s ", image.getCatalogUrl()));
    Log.log(LOGGER, format(" Image ID: %s ", image.getId()));
    if (!image.getId().equals(originalImageId.get())) {
        throw new TestFailException(" The selected image ID is: " + image.getId() + " instead of: " + originalImageId.get());
    }
    return dto;
}
Also used : TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response)

Example 42 with TestFailException

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

the class ClusterTemplateTest method validateDefaultCount.

private ClusterTemplateTestDto validateDefaultCount(TestContext tc, ClusterTemplateTestDto entity, CloudbreakClient cc) {
    try {
        assertNotNull(entity);
        assertNotNull(entity.getResponses());
        long defaultCount = entity.getResponses().stream().filter(template -> ResourceStatus.DEFAULT.equals(template.getStatus())).count();
        long expectedCount = 602;
        assertEquals("Should have " + expectedCount + " of default cluster templates.", expectedCount, defaultCount);
    } catch (Exception e) {
        throw new TestFailException(String.format("Failed to validate default count of cluster templates: %s", e.getMessage()), e);
    }
    return entity;
}
Also used : ClusterTestDto(com.sequenceiq.it.cloudbreak.dto.ClusterTestDto) DistroXTemplateTestDto(com.sequenceiq.it.cloudbreak.dto.clustertemplate.DistroXTemplateTestDto) ResourceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus) DistroXImageTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXImageTestDto) ClusterTemplateTestDto(com.sequenceiq.it.cloudbreak.dto.clustertemplate.ClusterTemplateTestDto) Test(org.testng.annotations.Test) StringUtils(org.apache.commons.lang3.StringUtils) MockCloudProvider(com.sequenceiq.it.cloudbreak.cloud.v4.mock.MockCloudProvider) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) DistroXNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.instancegroup.DistroXNetworkTestDto) StackTemplateTestDto(com.sequenceiq.it.cloudbreak.dto.stack.StackTemplateTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) BadRequestException(javax.ws.rs.BadRequestException) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ClusterTemplateAuditGrpcServiceAssertion(com.sequenceiq.it.cloudbreak.assertion.audit.ClusterTemplateAuditGrpcServiceAssertion) Assert.assertNotNull(org.junit.Assert.assertNotNull) PlacementSettingsTestDto(com.sequenceiq.it.cloudbreak.dto.PlacementSettingsTestDto) DistroXClouderaManagerTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.cluster.clouderamanager.DistroXClouderaManagerTestDto) ClusterTemplateV4Type(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.ClusterTemplateV4Type) LdapTestClient(com.sequenceiq.it.cloudbreak.client.LdapTestClient) ClusterTemplateTestAssertion(com.sequenceiq.it.cloudbreak.assertion.clustertemplate.ClusterTemplateTestAssertion) NotFoundException(javax.ws.rs.NotFoundException) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) ClusterTemplateTestClient(com.sequenceiq.it.cloudbreak.client.ClusterTemplateTestClient) EnvironmentTestClient(com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) RunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) RecipeTestClient(com.sequenceiq.it.cloudbreak.client.RecipeTestClient) RunningParameter.expectedMessage(com.sequenceiq.it.cloudbreak.context.RunningParameter.expectedMessage) Assert.assertEquals(org.junit.Assert.assertEquals) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) BadRequestException(javax.ws.rs.BadRequestException) NotFoundException(javax.ws.rs.NotFoundException)

Example 43 with TestFailException

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

the class ImageCatalogChangeTest method testFreeipaImageCatalogChange.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a running Freeipa/Datalake/Datahub", when = "calling change image catalog", then = "it should have new image catalog")
public void testFreeipaImageCatalogChange(MockedTestContext testContext) {
    // Freeipa
    final String newImageCatalog = testContext.given(FreeIpaTestDto.class).getResponse().getImage().getCatalog() + "&changed=true";
    testContext.given(FreeipaChangeImageCatalogTestDto.class).withImageCatalog(newImageCatalog).when(freeIpaTestClient.changeImageCatalog()).given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).then((testContext1, testDto, client) -> {
        final String actualCatalog = testDto.getResponse().getImage().getCatalog();
        if (!newImageCatalog.equals(actualCatalog)) {
            throw new TestFailException(String.format("Image catalog of Freeipa was not changed. Catalog : %s", actualCatalog));
        }
        return testDto;
    });
    // Datalake
    testContext.given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING);
    final StackImageV4Response sdxImage = testContext.given(SdxInternalTestDto.class).getResponse().getStackV4Response().getImage();
    final String sdxNewImageCatalogName = createNewImageCatalog(testContext, sdxImage);
    testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(sdxNewImageCatalogName).when(sdxTestClient.changeImageCatalog()).given(SdxInternalTestDto.class).when(sdxTestClient.describeInternal()).then((testContext1, testDto, client) -> {
        final String actualCatalog = testDto.getResponse().getStackV4Response().getImage().getCatalogName();
        if (!sdxNewImageCatalogName.equals(actualCatalog)) {
            throw new TestFailException(String.format("Image catalog of Datalake was not changed. Catalog : %s", actualCatalog));
        }
        return testDto;
    });
    // Datahub
    testContext.given(DistroXTestDto.class).when(distroXClient.create()).await(STACK_AVAILABLE);
    final StackImageV4Response distroXImage = testContext.given(DistroXTestDto.class).getResponse().getImage();
    final String distroXNewImageCatalogName = createNewImageCatalog(testContext, distroXImage);
    testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(distroXNewImageCatalogName).when(distroXClient.changeImageCatalog()).given(DistroXTestDto.class).when(distroXClient.get()).then((testContext1, testDto, client) -> {
        final String actualCatalog = testDto.getResponse().getImage().getCatalogName();
        if (!distroXNewImageCatalogName.equals(actualCatalog)) {
            throw new TestFailException(String.format("Image catalog of Datahub was not changed. Catalog : %s", actualCatalog));
        }
        return testDto;
    }).validate();
}
Also used : ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) FreeipaChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) Test(org.testng.annotations.Test) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) DistroXChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXChangeImageCatalogTestDto) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) NotNull(org.jetbrains.annotations.NotNull) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) FreeipaChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 44 with TestFailException

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

the class UsedImagesTest method verifyImagesAreUsed.

private <T extends CloudbreakTestDto> T verifyImagesAreUsed(TestContext testContext, T testDto) {
    testContext.given(UsedImagesTestDto.class).when(utilTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
        List<UsedImageStacksV4Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
        UsedImageStacksV4Response usedImageStacksV4Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(sdxImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("SDX image is NOT in use with ID:: %s", sdxImageUuid)));
        LOGGER.info("Used SDX image ID:: {}", usedImageStacksV4Response.getImage().getImageId());
        return usedImagesTestDto;
    }).given(FreeipaUsedImagesTestDto.class).when(freeIpaTestClient.usedImages()).then((tc, usedImagesTestDto, client) -> {
        List<UsedImageStacksV1Response> usedImages = usedImagesTestDto.getResponse().getUsedImages();
        UsedImageStacksV1Response usedImageStacksV1Response = usedImages.stream().filter(usedImage -> usedImage.getImage().getImageId().contains(freeipaImageUuid)).findFirst().orElseThrow(() -> new TestFailException(String.format("FreeIpa image is NOT in use with ID:: %s", freeipaImageUuid)));
        LOGGER.info("Used FreeIpa image ID:: {}", usedImageStacksV1Response.getImage().getImageId());
        return usedImagesTestDto;
    }).validate();
    return testDto;
}
Also used : ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) Description(com.sequenceiq.it.cloudbreak.context.Description) EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) FreeipaUsedImagesTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaUsedImagesTestDto) UsedImagesTestDto(com.sequenceiq.it.cloudbreak.dto.util.UsedImagesTestDto) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UUID(java.util.UUID) UsedImageStacksV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImageStacksV4Response) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) List(java.util.List) EnvironmentTestClient(com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) UtilTestClient(com.sequenceiq.it.cloudbreak.client.UtilTestClient) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) UsedImageStacksV1Response(com.sequenceiq.freeipa.api.v1.util.model.UsedImageStacksV1Response) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) UsedImageStacksV1Response(com.sequenceiq.freeipa.api.v1.util.model.UsedImageStacksV1Response) FreeipaUsedImagesTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaUsedImagesTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) List(java.util.List) UsedImageStacksV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImageStacksV4Response)

Example 45 with TestFailException

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

the class EnvironmentEditTest method authenticationEditWhenSetExistingKeyAndDeleteManagedSuccessfully.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running cloudbreak managed ssh key", when = "change managed ssh key to existing one", then = "delete managed ssh key but not create new one")
public void authenticationEditWhenSetExistingKeyAndDeleteManagedSuccessfully(MockedTestContext testContext) {
    String randomPublicKeyId = UUID.randomUUID().toString();
    testContext.given(HttpMock.class).mockSpi().getPublicKey().get().pathVariable("publicKeyId", randomPublicKeyId).thenReturn(Map.of("publicKeyId", randomPublicKeyId, "publicKey", "asd")).given(EnvironmentTestDto.class).withCreateFreeIpa(false).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(EnvironmentAuthenticationTestDto.class).withPublicKeyId(randomPublicKeyId).withPublicKey(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 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) HttpMock(com.sequenceiq.it.cloudbreak.dto.mock.HttpMock) 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