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