Search in sources :

Example 6 with CloudbreakTestDto

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

the class TestContext method awaitForInstance.

public <T extends CloudbreakTestDto, E extends Enum<E>> T awaitForInstance(T entity, Map<List<String>, E> desiredStatuses, RunningParameter runningParameter) {
    checkShutdown();
    if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
        Log.await(LOGGER, String.format("Cloudbreak await for instance should be skipped because of previous error. awaitforinstance [%s]", desiredStatuses));
        return entity;
    }
    String key = getKeyForAwait(entity, entity.getClass(), runningParameter);
    CloudbreakTestDto awaitEntity = get(key);
    instanceAwait.await(awaitEntity, desiredStatuses, getTestContext(), runningParameter, flowUtilSingleStatus.getPollingDurationOrTheDefault(runningParameter), maxRetry);
    return entity;
}
Also used : CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)

Example 7 with CloudbreakTestDto

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

the class TagsUtilTest method addTestNameTagShouldNotFailWhenTestDtoIsNotAbstractTestDto.

@Test
void addTestNameTagShouldNotFailWhenTestDtoIsNotAbstractTestDto() {
    CloudbreakTestDto testDto = mock(CloudbreakTestDto.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 8 with CloudbreakTestDto

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

the class TagsUtilTest method verifyTagsShouldNotFailWhenTestDtoIsNotAbstractTestDto.

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

Example 9 with CloudbreakTestDto

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

the class TestContext method thenException.

public <E extends Exception, T extends CloudbreakTestDto> T thenException(T entity, Class<? extends MicroserviceClient> clientClass, Assertion<T, ? extends MicroserviceClient> assertion, Class<E> expectedException, RunningParameter runningParameter) {
    checkShutdown();
    String key = getKey(assertion.getClass(), runningParameter);
    if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
        LOGGER.info("Should be skipped because of previous error. when [{}]", key);
        return entity;
    }
    CloudbreakUser who = setActingUser(runningParameter);
    LOGGER.info("then exception {} action on {} by {}, name: {}", key, entity, who, entity.getName());
    Log.thenException(LOGGER, assertion.getClass().getSimpleName() + " exception assertion on " + entity + " by " + who);
    try {
        String message = String.format("Expected exception with message (%s) has not been thrown!", runningParameter.getExpectedMessage());
        CloudbreakTestDto cloudbreakTestDto = resourceNames.get(key);
        if (cloudbreakTestDto != null) {
            assertion.doAssertion(this, (T) cloudbreakTestDto, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
        } else {
            assertion.doAssertion(this, entity, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
        }
        getExceptionMap().put("thenException", new TestFailException(message));
        LOGGER.error(message);
        htmlLoggerForExceptionValidation(message, "thenException");
    } catch (Exception e) {
        exceptionValidation(expectedException, e, key, runningParameter, "thenException");
    }
    return entity;
}
Also used : CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) CloudbreakUser(com.sequenceiq.it.cloudbreak.actor.CloudbreakUser) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) BeansException(org.springframework.beans.BeansException)

Example 10 with CloudbreakTestDto

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

the class TestContext method then.

public <T extends CloudbreakTestDto> T then(T entity, Class<? extends MicroserviceClient> clientClass, Assertion<T, ? extends MicroserviceClient> assertion, RunningParameter runningParameter) {
    checkShutdown();
    String key = getKey(assertion.getClass(), runningParameter);
    if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
        LOGGER.info("Should be skipped because of previous error. when [{}]", key);
        return entity;
    }
    CloudbreakUser who = setActingUser(runningParameter);
    Log.then(LOGGER, assertion.getClass().getSimpleName() + " assertion on " + entity + " by " + who);
    try {
        CloudbreakTestDto cloudbreakTestDto = resourceNames.get(key);
        if (cloudbreakTestDto != null) {
            return assertion.doAssertion(this, (T) cloudbreakTestDto, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
        } else {
            assertion.doAssertion(this, entity, getMicroserviceClient(entity.getClass(), who.getAccessKey()));
        }
    } catch (Exception e) {
        if (runningParameter.isLogError()) {
            LOGGER.error("then [{}] assertion is failed: {}, name: {}", key, ResponseUtil.getErrorMessage(e), entity.getName(), e);
            Log.then(null, assertion.getClass().getSimpleName() + " assertion is failed: " + ResponseUtil.getErrorMessage(e));
        }
        getExceptionMap().put(key, e);
    } catch (Error e) {
        getExceptionMap().put(key, new TestFailException(e.getMessage(), e));
    }
    return entity;
}
Also used : CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) CloudbreakUser(com.sequenceiq.it.cloudbreak.actor.CloudbreakUser) 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