use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testDeletionWithNonTerminatedClusterAndStack.
@Test
public void testDeletionWithNonTerminatedClusterAndStack() {
Blueprint blueprint = getBlueprint("name", USER_MANAGED);
Cluster cluster = getCluster("c1", 1L, blueprint, DetailedStackStatus.AVAILABLE);
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition");
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView));
when(clusterService.findByBlueprint(any())).thenReturn(Set.of(cluster));
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.delete(blueprint));
assertEquals("There is a cluster ['ClusterDefinition'] which uses cluster template 'name'. " + "Please remove this cluster before deleting the cluster template.", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testPrepareDeletionWhenHasOneCluster.
@Test
public void testPrepareDeletionWhenHasOneCluster() {
Blueprint blueprint = new Blueprint();
blueprint.setName("TemplateName");
Cluster templateCluster = getCluster("Cluster Name", 0L, blueprint, DetailedStackStatus.AVAILABLE);
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition");
when(clusterService.findByBlueprint(blueprint)).thenReturn(Set.of(templateCluster));
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView));
BadRequestException actual = Assertions.assertThrows(BadRequestException.class, () -> underTest.prepareDeletion(blueprint));
Assertions.assertEquals("There is a cluster ['ClusterDefinition'] which uses cluster template 'TemplateName'. " + "Please remove this cluster before deleting the cluster template.", actual.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster 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.cluster.Cluster in project cloudbreak by hortonworks.
the class CmVersionQueryServiceTest method createStack.
private Stack createStack() {
Stack stack = new Stack();
stack.setId(1L);
stack.setCluster(new Cluster());
Orchestrator orchestrator = new Orchestrator();
orchestrator.setType("salt");
stack.setOrchestrator(orchestrator);
Set<InstanceGroup> instanceGroups = new HashSet<>();
stack.setInstanceGroups(instanceGroups);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class StackUtilTest method testGetUptimeForCluster.
@Test
void testGetUptimeForCluster() {
Cluster cluster = new Cluster();
int minutes = 10;
cluster.setUptime(Duration.ofMinutes(minutes).toString());
cluster.setUpSince(new Date().getTime());
long uptime = stackUtil.getUptimeForCluster(cluster, true);
assertTrue(uptime >= Duration.ofMinutes(minutes).toMillis());
}
Aggregations