use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class CusterServicesRestartHandlerTest method setUp.
@BeforeEach
void setUp() {
underTest = new ClusterServicesRestartHandler();
MockitoAnnotations.openMocks(this);
mockTemplateComponents();
stack = new Stack();
stack.setId(1L);
stack.setCloudPlatform("AWS");
Cluster cluster = new Cluster();
cluster.setBlueprint(new Blueprint());
stack.setCluster(cluster);
when(datalakeService.getDatalakeStackByDatahubStack(any())).thenReturn(Optional.of(stack));
when(stackService.getByIdWithListsInTransaction(stack.getId())).thenReturn(stack);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class DeregisterServicesHandlerTest method getDatalakeStack.
private Stack getDatalakeStack() {
Cluster cluster = new Cluster();
cluster.setName(TEST_DATALAKE_NAME);
cluster.setCloudbreakAmbariUser(TEST_CM_USER);
cluster.setCloudbreakAmbariPassword(TEST_CM_PASSWORD);
cluster.setClusterManagerIp("test-cm-ip");
Stack stack = new Stack();
stack.setId(1L);
stack.setCloudPlatform("AWS");
stack.setGatewayPort(TEST_GATEWAY_PORT);
stack.setName(TEST_DATALAKE_NAME);
stack.setCluster(cluster);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class BlueprintServiceTest method getCluster.
private Cluster getCluster(String name, Long id, Blueprint blueprint, DetailedStackStatus detailedStackStatus) {
Cluster cluster1 = new Cluster();
cluster1.setName(name);
cluster1.setId(id);
cluster1.setBlueprint(blueprint);
patchWithStackStatus(cluster1, detailedStackStatus);
return cluster1;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testDeletionWithTerminatedClustersNonTerminatedStacks.
@Test
public void testDeletionWithTerminatedClustersNonTerminatedStacks() {
Blueprint blueprint = getBlueprint("name", USER_MANAGED);
Set<Cluster> clusters = new HashSet<>();
clusters.add(getCluster("c1", 1L, blueprint, DetailedStackStatus.PRE_DELETE_IN_PROGRESS));
clusters.add(getCluster("c2", 1L, blueprint, DetailedStackStatus.DELETE_IN_PROGRESS));
clusters.add(getCluster("c3", 1L, blueprint, DetailedStackStatus.DELETE_COMPLETED));
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition");
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView));
when(clusterService.findByBlueprint(any())).thenReturn(clusters);
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 testDeletionWithTerminatedAndNonTerminatedClusters.
@Test
public void testDeletionWithTerminatedAndNonTerminatedClusters() {
Blueprint blueprint = getBlueprint("name", USER_MANAGED);
Set<Cluster> clusters = new HashSet<>();
clusters.add(getCluster("c1", 1L, blueprint, DetailedStackStatus.PRE_DELETE_IN_PROGRESS));
clusters.add(getCluster("c2", 1L, blueprint, DetailedStackStatus.DELETE_COMPLETED));
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition1");
ClusterTemplateView clusterTemplateView2 = new ClusterTemplateView();
clusterTemplateView2.setName("ClusterDefinition2");
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView, clusterTemplateView2));
when(clusterService.findByBlueprint(any())).thenReturn(clusters);
try {
underTest.delete(blueprint);
} catch (BadRequestException e) {
assertTrue(e.getMessage().contains("ClusterDefinition1"));
assertFalse(e.getMessage().contains("ClusterDefinition2"));
}
verify(clusterService, times(1)).saveAll(anyCollection());
}
Aggregations