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;
}
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();
}
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();
}
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;
}
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();
}
Aggregations