Search in sources :

Example 1 with CloudbreakTestDto

use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto 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 2 with CloudbreakTestDto

use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.

the class TagsUtilTest method verifyTagsShouldNotFailWhenTestDtoDoesNotHaveTaggedResponse.

@Test
void verifyTagsShouldNotFailWhenTestDtoDoesNotHaveTaggedResponse() {
    CloudbreakTestDto testDto = mock(AbstractTestDto.class);
    assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
Also used : CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) Test(org.testng.annotations.Test)

Example 3 with CloudbreakTestDto

use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.

the class TagsUtilTest method addTestNameTagShouldNotFailWhenTestDtoDoesNotHaveTaggedRequest.

@Test
void addTestNameTagShouldNotFailWhenTestDtoDoesNotHaveTaggedRequest() {
    CloudbreakTestDto testDto = mock(AbstractTestDto.class);
    when(testDto.getCloudPlatform()).thenReturn(CloudPlatform.MOCK);
    assertThatCode(() -> underTest.addTestNameTag(testDto.getCloudPlatform(), testDto, TEST_NAME)).doesNotThrowAnyException();
}
Also used : CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) Test(org.testng.annotations.Test)

Example 4 with CloudbreakTestDto

use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.

the class TestContext method awaitForFlow.

public <T extends CloudbreakTestDto> T awaitForFlow(T entity, RunningParameter runningParameter) {
    checkShutdown();
    String key = getKeyForAwait(entity, entity.getClass(), runningParameter);
    if (StringUtils.isBlank(key)) {
        key = entity.getClass().getSimpleName();
    }
    CloudbreakTestDto awaitEntity = get(key);
    if (awaitEntity == null) {
        awaitEntity = entity;
    }
    if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
        Log.await(LOGGER, "Cloudbreak await for flow should be skipped because of previous error.");
    } else {
        LOGGER.info(String.format(" Cloudbreak await for flow on resource: %s at account: %s - for entity: %s ", awaitEntity.getCrn(), Objects.requireNonNull(Crn.fromString(awaitEntity.getCrn())).getAccountId(), awaitEntity));
        Log.await(LOGGER, String.format(" Cloudbreak await for flow on resource: %s at account: %s - for entity: %s ", awaitEntity.getCrn(), Objects.requireNonNull(Crn.fromString(awaitEntity.getCrn())).getAccountId(), awaitEntity));
        MicroserviceClient msClient = getAdminMicroserviceClient(awaitEntity.getClass(), Objects.requireNonNull(Crn.fromString(awaitEntity.getCrn())).getAccountId());
        flowUtilSingleStatus.waitBasedOnLastKnownFlow(awaitEntity, msClient, getTestContext(), runningParameter);
    }
    entity.setLastKnownFlowId(null);
    return entity;
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)

Example 5 with CloudbreakTestDto

use of com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto in project cloudbreak by hortonworks.

the class TestContext method cleanupTestContext.

public void cleanupTestContext() {
    if (!cleanUp) {
        LOGGER.info("Clean up is skipped due to cleanUp paramater");
        return;
    }
    if (!validated && initialized) {
        throw new IllegalStateException("Test context should be validated! Maybe you forgot to call .validate() at the end of the test? See other tests as an example.");
    }
    checkShutdown();
    handleExceptionsDuringTest(TestErrorLog.IGNORE);
    if (!cleanUpOnFailure && !getExceptionMap().isEmpty()) {
        LOGGER.info("Cleanup skipped beacuse cleanupOnFail is false");
        return;
    }
    List<CloudbreakTestDto> testDtos = new ArrayList<>(getResourceNames().values());
    List<CloudbreakTestDto> orderedTestDtos = testDtos.stream().sorted(new CompareByOrder()).collect(Collectors.toList());
    for (CloudbreakTestDto testDto : orderedTestDtos) {
        try {
            LOGGER.info("Starting to clean up {} {}", testDto.getClass().getSimpleName(), testDto.getName());
            testDto.cleanUp();
        } catch (Exception e) {
            LOGGER.info("Cleaning up of tests context with {} resource is failing, because of: {}", testDto.getName(), e.getMessage());
        }
    }
    shutdown();
}
Also used : CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) ArrayList(java.util.ArrayList) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) BeansException(org.springframework.beans.BeansException)

Aggregations

CloudbreakTestDto (com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)12 Test (org.testng.annotations.Test)5 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)4 BeansException (org.springframework.beans.BeansException)3 CloudbreakUser (com.sequenceiq.it.cloudbreak.actor.CloudbreakUser)2 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)2 ArrayList (java.util.ArrayList)2 UsedImageStacksV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImageStacksV4Response)1 EnvironmentStatus (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus)1 Status (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status)1 UsedImageStacksV1Response (com.sequenceiq.freeipa.api.v1.util.model.UsedImageStacksV1Response)1 MicroserviceClient (com.sequenceiq.it.cloudbreak.MicroserviceClient)1 EnvironmentTestClient (com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient)1 FreeIpaTestClient (com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient)1 ImageCatalogTestClient (com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient)1 SdxTestClient (com.sequenceiq.it.cloudbreak.client.SdxTestClient)1 UtilTestClient (com.sequenceiq.it.cloudbreak.client.UtilTestClient)1 CompareByOrder (com.sequenceiq.it.cloudbreak.context.CompareByOrder)1 Description (com.sequenceiq.it.cloudbreak.context.Description)1 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)1