use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCDHVersion.
@Test
@DisplayName("Test if the runtime cannot be updated when there is no CDP version specified")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCDHVersion() {
when(sdxService.getById(1L)).thenReturn(sdxCluster);
StackV4Response stackV4Response = getStackV4Response();
ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
cdp.setName("CDH");
stackV4Response.getCluster().getCm().setProducts(List.of(cdp));
when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
underTest.updateRuntimeVersionFromCloudbreak(1L);
verify(sdxService, times(0)).save(any());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCDH.
@Test
@DisplayName("Test if the runtime cannot be updated when there is no CDH product installed")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCDH() {
when(sdxService.getById(1L)).thenReturn(sdxCluster);
StackV4Response stackV4Response = getStackV4Response();
ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
spark3.setName("SPARK3");
spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
stackV4Response.getCluster().getCm().setProducts(List.of(spark3));
when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
underTest.updateRuntimeVersionFromCloudbreak(1L);
verify(sdxService, times(0)).save(any());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.
the class SdxServiceTest method testUpdateRuntimeVersionFromStackResponse.
@Test
public void testUpdateRuntimeVersionFromStackResponse() {
SdxCluster sdxCluster = getSdxCluster();
StackV4Response stackV4Response = new StackV4Response();
ClusterV4Response clusterV4Response = new ClusterV4Response();
ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
ClouderaManagerProductV4Response cdpResponse = new ClouderaManagerProductV4Response();
cdpResponse.setName("CDH");
cdpResponse.setVersion("7.2.1-1.32.123-123");
cm.setProducts(Collections.singletonList(cdpResponse));
clusterV4Response.setCm(cm);
stackV4Response.setCluster(clusterV4Response);
underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
ArgumentCaptor<SdxCluster> sdxClusterArgumentCaptor = ArgumentCaptor.forClass(SdxCluster.class);
verify(sdxClusterRepository, times(1)).save(sdxClusterArgumentCaptor.capture());
assertEquals("7.2.1", sdxClusterArgumentCaptor.getValue().getRuntime());
cdpResponse.setVersion("7.1.0");
underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
verify(sdxClusterRepository, times(2)).save(sdxClusterArgumentCaptor.capture());
assertEquals("7.1.0", sdxClusterArgumentCaptor.getValue().getRuntime());
cdpResponse.setVersion("7.0.2-valami");
underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
verify(sdxClusterRepository, times(3)).save(sdxClusterArgumentCaptor.capture());
assertEquals("7.0.2", sdxClusterArgumentCaptor.getValue().getRuntime());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method getStackV4Response.
private StackV4Response getStackV4Response() {
ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
cdp.setName("CDH");
cdp.setVersion("7.2.1-1.cdh7.2.0.p0.3758356");
ClouderaManagerProductV4Response cfm = new ClouderaManagerProductV4Response();
cfm.setName("CFM");
cfm.setVersion("2.0.0.0");
ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
spark3.setName("SPARK3");
spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
cm.setProducts(List.of(cdp, cfm, spark3));
ClusterV4Response clusterV4Response = new ClusterV4Response();
clusterV4Response.setCm(cm);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setName("test-sdx-cluster");
stackV4Response.setCluster(clusterV4Response);
return stackV4Response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.
the class SdxService method getCdpVersion.
private Optional<String> getCdpVersion(StackV4Response stack) {
String stackName = stack.getName();
ClusterV4Response cluster = stack.getCluster();
if (cluster != null) {
ClouderaManagerV4Response cm = cluster.getCm();
if (cm != null) {
LOGGER.info("Repository details are available for cluster: {}: {}", stackName, cm);
List<ClouderaManagerProductV4Response> products = cm.getProducts();
if (products != null && !products.isEmpty()) {
Optional<ClouderaManagerProductV4Response> cdpOpt = products.stream().filter(p -> "CDH".equals(p.getName())).findFirst();
if (cdpOpt.isPresent()) {
return getRuntimeVersionFromCdpVersion(cdpOpt.get().getVersion());
}
}
}
}
return Optional.empty();
}
Aggregations