Search in sources :

Example 1 with StackImageV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response 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;
}
Also used : TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response)

Example 2 with StackImageV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response 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();
}
Also used : ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) FreeipaChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) Test(org.testng.annotations.Test) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) DistroXChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.image.DistroXChangeImageCatalogTestDto) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) NotNull(org.jetbrains.annotations.NotNull) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) FreeipaChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeipaChangeImageCatalogTestDto) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) SdxChangeImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxChangeImageCatalogTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 3 with StackImageV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverterTest method testConvert.

@Test
public void testConvert() throws CloudbreakImageNotFoundException {
    Stack source = getSource();
    // GIVEN
    given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
    given(imageToStackImageV4ResponseConverter.convert(any(Image.class))).willReturn(new StackImageV4Response());
    given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any(StackAuthentication.class))).willReturn(new StackAuthenticationV4Response());
    given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
    given(clusterToClusterV4ResponseConverter.convert(any())).willReturn(new ClusterV4Response());
    given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
    given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
    given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
    given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
    given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
    given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
    given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
    // WHEN
    StackV4Response result = underTest.convert(source);
    // THEN
    assertAllFieldsNotNull(result, Arrays.asList("gcp", "mock", "openstack", "aws", "yarn", "azure", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
    verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) DatabaseResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse) CustomDomainSettingsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.customdomain.CustomDomainSettingsV4Response) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) WorkspaceResourceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.workspace.responses.WorkspaceResourceV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackAuthenticationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.authentication.StackAuthenticationV4Response) NetworkV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.network.NetworkV4Response) CloudbreakDetailsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CloudbreakDetailsV4Response) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) PlacementSettingsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.PlacementSettingsV4Response) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 4 with StackImageV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverterTest method testConvertWithoutCluster.

@Test
public void testConvertWithoutCluster() throws CloudbreakImageNotFoundException {
    Stack source = getSource();
    // GIVEN
    getSource().setCluster(null);
    given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
    given(imageToStackImageV4ResponseConverter.convert(any())).willReturn(new StackImageV4Response());
    given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
    given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any())).willReturn(new StackAuthenticationV4Response());
    given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
    given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
    given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
    given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
    given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
    given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
    given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
    // WHEN
    StackV4Response result = underTest.convert(source);
    // THEN
    assertAllFieldsNotNull(result, Arrays.asList("cluster", "gcp", "mock", "openstack", "aws", "yarn", "azure", "telemetry", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
    assertNull(result.getCluster());
    verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) DatabaseResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse) CustomDomainSettingsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.customdomain.CustomDomainSettingsV4Response) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) WorkspaceResourceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.workspace.responses.WorkspaceResourceV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackAuthenticationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.authentication.StackAuthenticationV4Response) NetworkV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.network.NetworkV4Response) CloudbreakDetailsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CloudbreakDetailsV4Response) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) PlacementSettingsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.PlacementSettingsV4Response) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 5 with StackImageV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverterTest method testConvertWithLoadBalancers.

@Test
public void testConvertWithLoadBalancers() throws CloudbreakImageNotFoundException {
    Set<LoadBalancer> loadBalancers = Set.of(new LoadBalancer());
    Stack source = getSource();
    // GIVEN
    given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
    given(imageToStackImageV4ResponseConverter.convert(any())).willReturn(new StackImageV4Response());
    given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
    given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any())).willReturn(new StackAuthenticationV4Response());
    given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
    given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
    given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
    given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
    given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
    given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
    given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
    given(loadBalancerService.findByStackId(any())).willReturn(loadBalancers);
    // WHEN
    source.setLoadBalancers(loadBalancers);
    StackV4Response result = underTest.convert(source);
    // THEN
    assertNotNull(result.getLoadBalancers());
    assertTrue(result.isEnableLoadBalancer());
    verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) DatabaseResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) CustomDomainSettingsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.customdomain.CustomDomainSettingsV4Response) StackImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) WorkspaceResourceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.workspace.responses.WorkspaceResourceV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackAuthenticationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.authentication.StackAuthenticationV4Response) NetworkV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.network.NetworkV4Response) CloudbreakDetailsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CloudbreakDetailsV4Response) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) PlacementSettingsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.PlacementSettingsV4Response) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Aggregations

StackImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.StackImageV4Response)7 Image (com.sequenceiq.cloudbreak.cloud.model.Image)4 CloudbreakDetailsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CloudbreakDetailsV4Response)3 PlacementSettingsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.PlacementSettingsV4Response)3 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)3 StackAuthenticationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.authentication.StackAuthenticationV4Response)3 CustomDomainSettingsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.customdomain.CustomDomainSettingsV4Response)3 DatabaseResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse)3 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)3 NetworkV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.network.NetworkV4Response)3 WorkspaceResourceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.workspace.responses.WorkspaceResourceV4Response)3 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)3 Test (org.junit.Test)3 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)2 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)1 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)1 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)1 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)1