Search in sources :

Example 1 with ImageCatalogTestDto

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

the class AbstractIntegrationTest method validateBaseImage.

protected void validateBaseImage(TestContext testContext, String imageUuid) {
    testContext.given(ImageCatalogTestDto.class).when(imageCatalogTestClient.getV4(true)).valid();
    ImageCatalogTestDto dto = testContext.get(ImageCatalogTestDto.class);
    dto.getResponse().getImages().getBaseImages().stream().filter(img -> img.getUuid().equalsIgnoreCase(imageUuid)).findFirst().orElseThrow(() -> new RuntimeException(imageUuid + " base image is missing from the '" + dto.getName() + "' catalog."));
}
Also used : ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto)

Example 2 with ImageCatalogTestDto

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

the class AbstractIntegrationTest method validatePrewarmedImage.

protected void validatePrewarmedImage(TestContext testContext, String imageUuid) {
    testContext.given(ImageCatalogTestDto.class).when(imageCatalogTestClient.getV4(true)).valid();
    ImageCatalogTestDto dto = testContext.get(ImageCatalogTestDto.class);
    dto.getResponse().getImages().getCdhImages().stream().filter(img -> img.getUuid().equalsIgnoreCase(imageUuid)).findFirst().orElseThrow(() -> new RuntimeException(imageUuid + " prewarmed image is missing from the '" + dto.getName() + "' catalog."));
}
Also used : ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto)

Example 3 with ImageCatalogTestDto

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

the class ChangeImageCatalogTest method testChangeDataLakeImageCatalogFails.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataLake created by ENV_CREATOR_A and image catalogs created by ENV_CREATOR_A and ENV_CREATOR_B", when = "a change image catalog request is sent", then = "ENV_CREATOR_B should get forbidden excepion by using any image catalog")
public void testChangeDataLakeImageCatalogFails(MockedTestContext testContext) {
    useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
    createDefaultImageCatalog(testContext);
    testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).validate();
    ImageCatalogTestDto imageCatalogA = resourceCreator.createNewImageCatalog(testContext);
    useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
    ImageCatalogTestDto imageCatalogB = resourceCreator.createNewImageCatalog(testContext);
    // ENV_CREATOR_B can't change DL image catalog in case of DL is created by ENV_CREATOR_A
    testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogB.getName()).whenException(sdxTestClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'datalake/changeImageCatalog' right on any of the environment[(]s[)] " + environmentDatalakePattern(testContext) + " or on .*")).validate();
    // ENV_CREATOR_B can't change ENV_CREATOR_A's DH image catalog in case of having environment admin right but the catalog is created by ENV_CREATOR_A
    testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogA.getName()).whenException(sdxTestClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on imageCatalog .*")).validate();
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) ForbiddenException(javax.ws.rs.ForbiddenException) CredentialTestDto(com.sequenceiq.it.cloudbreak.dto.credential.CredentialTestDto) FreeipaChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto) DistroXChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXChangeImageCatalogTestDto) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) UmsTestDto(com.sequenceiq.it.cloudbreak.dto.ums.UmsTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)

Example 4 with ImageCatalogTestDto

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

the class ChangeImageCatalogTest method testChangeDataHubImageCatalogFails.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataHub created by ENV_CREATOR_A and image catalogs created by ENV_CREATOR_A and ENV_CREATOR_B", when = "a change image catalog request is sent", then = "ENV_CREATOR_B should get forbidden excepion by using any image catalog")
public void testChangeDataHubImageCatalogFails(MockedTestContext testContext) {
    useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
    createDefaultImageCatalog(testContext);
    testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(Status.AVAILABLE).given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).given(DistroXTestDto.class).when(distroXClient.create()).await(STACK_AVAILABLE, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ACCOUNT_ADMIN))).validate();
    ImageCatalogTestDto imageCatalogA = resourceCreator.createNewImageCatalog(testContext);
    useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
    ImageCatalogTestDto imageCatalogB = resourceCreator.createNewImageCatalog(testContext);
    // ENV_CREATOR_B can't change DH image catalog in case of DH is created by ENV_CREATOR_A
    testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogB.getName()).whenException(distroXClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have " + "'datahub/changeImageCatalog' right on any of the environment[(]s[)] " + "[\\[]crn: crn:cdp:environments:us-west-1:.*:environment:.*[]] or on .*")).validate();
    // ENV_CREATOR_B can't change ENV_CREATOR_A's DH image catalog in case of having environment admin right but the catalog is created by ENV_CREATOR_A
    testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogA.getName()).whenException(distroXClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on imageCatalog .*")).validate();
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) ForbiddenException(javax.ws.rs.ForbiddenException) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) CredentialTestDto(com.sequenceiq.it.cloudbreak.dto.credential.CredentialTestDto) FreeipaChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto) DistroXChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXChangeImageCatalogTestDto) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) UmsTestDto(com.sequenceiq.it.cloudbreak.dto.ums.UmsTestDto) DistroXChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXChangeImageCatalogTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)

Example 5 with ImageCatalogTestDto

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

the class DistroXUpgradeTests method getUuid.

protected String getUuid(TestContext testContext, String prodCatalogName, String currentRuntimeVersion3rdParty) {
    testContext.given(ImageCatalogTestDto.class).withName(prodCatalogName).when(imageCatalogTest.getV4(true));
    ImageCatalogTestDto dto = testContext.get(ImageCatalogTestDto.class);
    return dto.getResponse().getImages().getCdhImages().stream().filter(img -> img.getVersion().equals(currentRuntimeVersion3rdParty) && img.getImageSetsByProvider().keySet().stream().iterator().next().equals(testContext.commonCloudProperties().getCloudProvider().toLowerCase())).iterator().next().getUuid();
}
Also used : SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) DistroXImageTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXImageTestDto) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) AtomicReference(java.util.concurrent.atomic.AtomicReference) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) CommonClusterManagerProperties(com.sequenceiq.it.cloudbreak.cloud.v4.CommonClusterManagerProperties) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) DistroXUpgradeTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.cluster.DistroXUpgradeTestDto) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) AwsAvailabilityZoneAssertion(com.sequenceiq.it.cloudbreak.assertion.distrox.AwsAvailabilityZoneAssertion) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto)

Aggregations

ImageCatalogTestDto (com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto)16 Description (com.sequenceiq.it.cloudbreak.context.Description)8 Test (org.testng.annotations.Test)8 AbstractIntegrationTest (com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)5 DistroXChangeImageCatalogTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXChangeImageCatalogTestDto)4 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)4 FreeipaChangeImageCatalogTestDto (com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto)4 SdxChangeImageCatalogTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto)4 UmsTestDto (com.sequenceiq.it.cloudbreak.dto.ums.UmsTestDto)4 ImageCatalogTestClient (com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient)3 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)3 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)3 Inject (javax.inject.Inject)3 ImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.ImageCatalogV4Request)2 UpdateImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.requests.UpdateImageCatalogV4Request)2 ImageCatalogV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response)2 ImageCatalogV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Responses)2 ImagesV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)2 ImageCatalogGetImagesByNameAction (com.sequenceiq.it.cloudbreak.action.v4.imagecatalog.ImageCatalogGetImagesByNameAction)2