use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupServiceTest method testPrewarmedClouderaManagerClusterComponentsWhenTheStackTypeIsDataLake.
@Test
public void testPrewarmedClouderaManagerClusterComponentsWhenTheStackTypeIsDataLake() throws IOException, CloudbreakImageCatalogException {
Component cmRepoComponent = spy(new Component(ComponentType.CM_REPO_DETAILS, ComponentType.CM_REPO_DETAILS.name(), new Json(getClouderaManagerRepo(false)), stack));
Component productComponent = spy(new Component(ComponentType.CDH_PRODUCT_DETAILS, ComponentType.CDH_PRODUCT_DETAILS.name(), new Json(getClouderaManagerProductRepo()), stack));
List<Component> productComponentList = List.of(productComponent);
ClouderaManagerProduct cdhProduct = clouderaManagerProduct("CDH", "1.5.0");
stack.setType(StackType.DATALAKE);
when(blueprintUtils.getCDHStackVersion(any())).thenReturn(SOME_CDH_VERSION);
when(clouderaManagerProductsProvider.getCdhProducts(anySet())).thenReturn(cdhProduct);
List<ClusterComponent> clusterComponents = underTest.prepareClouderaManagerCluster(clusterRequest, cluster, Optional.of(cmRepoComponent), productComponentList, Optional.of(imageComponent));
assertVersionsMatch(clusterComponents, CM_VERSION, SOME_CDH_VERSION);
verify(clouderaManagerProductsProvider).getCdhProducts(anySet());
verifyNoInteractions(parcelFilterService);
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupServiceTest method testPrewarmedClouderaManagerClusterComponents.
@Test
public void testPrewarmedClouderaManagerClusterComponents() throws IOException, CloudbreakImageCatalogException {
Component cmRepoComponent = spy(new Component(ComponentType.CM_REPO_DETAILS, ComponentType.CM_REPO_DETAILS.name(), new Json(getClouderaManagerRepo(false)), stack));
Component productComponent = spy(new Component(ComponentType.CDH_PRODUCT_DETAILS, ComponentType.CDH_PRODUCT_DETAILS.name(), new Json(getClouderaManagerProductRepo()), stack));
List<Component> productComponentList = List.of(productComponent);
Set<ClouderaManagerProduct> clouderaManagerProductSet = new HashSet<>();
clouderaManagerProductSet.add(clouderaManagerProduct("CDH", "1.5.0"));
when(blueprintUtils.getCDHStackVersion(any())).thenReturn(SOME_CDH_VERSION);
when(parcelFilterService.filterParcelsByBlueprint(eq(STACK_ID), anySet(), any(Blueprint.class))).thenReturn(clouderaManagerProductSet);
List<ClusterComponent> clusterComponents = underTest.prepareClouderaManagerCluster(clusterRequest, cluster, Optional.of(cmRepoComponent), productComponentList, Optional.of(imageComponent));
assertVersionsMatch(clusterComponents, CM_VERSION, SOME_CDH_VERSION);
verify(parcelFilterService, times(1)).filterParcelsByBlueprint(eq(STACK_ID), anySet(), any(Blueprint.class));
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClusterCreationSetupServiceTest method init.
@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
MockitoAnnotations.initMocks(this);
workspace = new Workspace();
clusterRequest = new ClusterV4Request();
stack = new Stack();
stack.setId(1L);
stack.setWorkspace(workspace);
stack.setEnvironmentCrn("env");
stack.setName("name");
blueprint = new Blueprint();
blueprint.setBlueprintText("{}");
user = new User();
Map<InstanceGroupType, String> userData = new HashMap<>();
userData.put(InstanceGroupType.CORE, "userdata");
Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
cluster = new Cluster();
stack.setCluster(cluster);
when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ComponentConfigProviderServiceTest method replaceImageComponentWithNew.
@Test
public void replaceImageComponentWithNew() {
Stack stack = new Stack();
stack.setId(1L);
Component original = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json("asdf"), stack);
Component modified = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json("fdas"), stack);
when(componentRepository.findComponentByStackIdComponentTypeName(eq(stack.getId()), eq(original.getComponentType()), eq(original.getName()))).thenReturn(Optional.of(original));
componentConfigProviderService.replaceImageComponentWithNew(modified);
ArgumentCaptor<Component> argument = ArgumentCaptor.forClass(Component.class);
verify(componentRepository).save(argument.capture());
assertEquals(modified.getAttributes(), argument.getValue().getAttributes());
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class CmSyncResultMergerServiceTest method testMergeNoClouderaManagerRepo.
@Test
void testMergeNoClouderaManagerRepo() {
Stack stack = new Stack();
CmRepoSyncOperationResult cmRepoSyncOperationResult = new CmRepoSyncOperationResult(null, null);
Set<ClouderaManagerProduct> clouderaManagerProducts = Set.of(new ClouderaManagerProduct());
CmParcelSyncOperationResult cmParcelSyncOperationResult = new CmParcelSyncOperationResult(Set.of(), clouderaManagerProducts);
when(componentConverter.fromClouderaManagerProductList(clouderaManagerProducts, stack)).thenReturn(Set.of(componentWithName(CM_PARCEL_COMPONENT_NAME)));
CmSyncOperationResult cmSyncOperationResult = new CmSyncOperationResult(cmRepoSyncOperationResult, cmParcelSyncOperationResult);
Set<Component> mergedComponents = underTest.merge(stack, cmSyncOperationResult);
assertThat(mergedComponents, hasSize(1));
assertThat(mergedComponents, contains(hasProperty("name", is(CM_PARCEL_COMPONENT_NAME))));
verify(componentConverter, never()).fromClouderaManagerRepo(any(), any());
verify(componentConverter).fromClouderaManagerProductList(clouderaManagerProducts, stack);
}
Aggregations