Search in sources :

Example 76 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class ServiceTestUtils method createStack.

public static Stack createStack(String owner, String account, Template template, Credential credential, Cluster cluster, Set<Resource> resources) {
    Template template1 = createTemplate(AWS);
    Template template2 = createTemplate(AWS);
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    InstanceGroup instanceGroup1 = new InstanceGroup();
    instanceGroup1.setNodeCount(2);
    instanceGroup1.setGroupName("master");
    instanceGroup1.setTemplate(template1);
    instanceGroups.add(instanceGroup1);
    InstanceGroup instanceGroup2 = new InstanceGroup();
    instanceGroup2.setNodeCount(2);
    instanceGroup2.setGroupName("slave_1");
    instanceGroup2.setTemplate(template2);
    instanceGroups.add(instanceGroup2);
    Stack stack = new Stack();
    stack.setCredential(credential);
    stack.setRegion("EU_WEST_1");
    stack.setOwner(owner);
    stack.setAccount(account);
    stack.setStackStatus(new StackStatus(stack, Status.REQUESTED, "", DetailedStackStatus.PROVISION_REQUESTED));
    stack.setInstanceGroups(instanceGroups);
    stack.setCluster(cluster);
    stack.setPublicInAccount(true);
    stack.setResources(resources);
    return stack;
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Template(com.sequenceiq.cloudbreak.domain.Template) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 77 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class AmbariClusterSetupServiceTest method testApiAvailableWhenPollerReturnTrueThenApiShouldBeAvailable.

@Test
public void testApiAvailableWhenPollerReturnTrueThenApiShouldBeAvailable() throws CloudbreakSecuritySetupException {
    Stack stack = TestUtil.stack();
    Cluster cluster = TestUtil.cluster();
    stack.setCluster(cluster);
    AmbariClient ambariClient = ambariClient();
    when(ambariPollingServiceProvider.isAmbariAvailable(stack, ambariClient)).thenReturn(true);
    when(clientFactory.getAmbariClient(stack, stack.getCluster())).thenReturn(ambariClient);
    boolean available = underTest.available(stack);
    verify(ambariPollingServiceProvider, times(1)).isAmbariAvailable(stack, ambariClient);
    verify(clientFactory, times(1)).getAmbariClient(stack, stack.getCluster());
    Assert.assertTrue(available);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Stack(com.sequenceiq.cloudbreak.domain.Stack) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 78 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class AmbariUserHandlerTest method testCreateAmbariUserWhenNoExceptionOccuredThenEverythingShouldWorksFine.

@Test
public void testCreateAmbariUserWhenNoExceptionOccuredThenEverythingShouldWorksFine() throws CloudbreakException {
    String newUserName = "newUserName";
    String newPassword = "newPassword";
    Stack stack = TestUtil.stack();
    AmbariClient ambariClient = mock(AmbariClient.class);
    when(ambariClient.createUser(newUserName, newPassword, true)).thenReturn(ambariClient);
    AmbariClient ambariClientResult = underTest.createAmbariUser(newUserName, newPassword, stack, ambariClient);
    Assert.assertEquals(ambariClient, ambariClientResult);
    verify(ambariClient, times(1)).createUser(newUserName, newPassword, true);
    verify(ambariClientFactory, times(0)).getAmbariClient(stack, newUserName, newPassword);
    verify(ambariClient, times(0)).ambariServerVersion();
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.Stack) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 79 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class InstanceGroupMetadataCollectorTest method testCollectFqdnsWhenMetadataAvailable.

@Test
public void testCollectFqdnsWhenMetadataAvailable() {
    Stack stack = TestUtil.stack();
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        when(instanceMetadataRepository.findAliveInstancesInInstanceGroup(instanceGroup.getId())).thenReturn(Lists.newArrayList(instanceGroup.getInstanceMetaData().iterator()));
    }
    Map<String, List<InstanceMetaData>> stringListMap = underTest.collectMetadata(stack);
    Assert.assertEquals(3, stringListMap.size());
    Assert.assertTrue(stringListMap.keySet().containsAll(Sets.newHashSet("is1", "is2", "is3")));
    verify(instanceMetadataRepository, times(3)).findAliveInstancesInInstanceGroup(anyLong());
}
Also used : List(java.util.List) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 80 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class AmbariDecommissionerTest method testVerifyNodeCountWithoutReplicationFactory.

@Test
public void testVerifyNodeCountWithoutReplicationFactory() throws CloudbreakSecuritySetupException {
    String hostGroupName = "hostGroupName";
    String hostname = "hostname";
    String ipAddress = "192.18.256.1";
    int gatewayPort = 1234;
    String ambariName = "ambari-name";
    Map<String, List<String>> blueprintMap = new HashMap<>();
    blueprintMap.put(hostGroupName, Collections.singletonList("NODEMANAGER"));
    Blueprint blueprint = new Blueprint();
    blueprint.setName(ambariName);
    blueprint.setAmbariName(ambariName);
    Cluster cluster = new Cluster();
    cluster.setAmbariIp(ipAddress);
    cluster.setBlueprint(blueprint);
    Stack stack = new Stack();
    stack.setGatewayPort(gatewayPort);
    stack.setId(100L);
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(hostGroupName);
    hostGroup.setHostMetadata(Collections.singleton(getHostMetadata(0L)));
    AmbariClient ambariClient = mock(AmbariClient.class);
    HttpClientConfig config = new HttpClientConfig(ipAddress);
    when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp())).thenReturn(config);
    when(ambariClientProvider.getAmbariClient(config, stack.getGatewayPort(), cluster)).thenReturn(ambariClient);
    when(hostGroupService.getByClusterAndHostName(cluster, hostname)).thenReturn(hostGroup);
    when(ambariClient.getBlueprintMap(ambariName)).thenReturn(blueprintMap);
    underTest.verifyNodeCount(stack, cluster, hostname);
    verify(configurationService, times(0)).getConfiguration(ambariClient, hostGroupName);
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) List(java.util.List) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Stack(com.sequenceiq.cloudbreak.domain.Stack) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14