Search in sources :

Example 71 with Cluster

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);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 72 with Cluster

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;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 73 with Cluster

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;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)

Example 74 with Cluster

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());
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ClusterTemplateView(com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 75 with Cluster

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());
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ClusterTemplateView(com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)407 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)248 Test (org.junit.jupiter.api.Test)125 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)60 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)58 Optional (java.util.Optional)51 Test (org.junit.Test)50 List (java.util.List)49 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)47 Set (java.util.Set)43 Json (com.sequenceiq.cloudbreak.common.json.Json)39 Map (java.util.Map)39 Collectors (java.util.stream.Collectors)39 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)37 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)36 Inject (javax.inject.Inject)36 Logger (org.slf4j.Logger)36 LoggerFactory (org.slf4j.LoggerFactory)36 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)35