Search in sources :

Example 16 with Blueprint

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

the class ServiceTestUtils method createBlueprint.

public static Blueprint createBlueprint(BlueprintRequest blueprintRequest) {
    Blueprint blueprint = new Blueprint();
    blueprint.setName(blueprintRequest.getName());
    blueprint.setBlueprintText(blueprintRequest.getAmbariBlueprint());
    return blueprint;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 17 with Blueprint

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

the class BlueprintLoaderServiceTest method testLoadBlueprintsForTheSpecifiedUserWhenOneNewDefaultExistThenRepositoryShouldUpdateOnlyOneBlueprint.

@Test
public void testLoadBlueprintsForTheSpecifiedUserWhenOneNewDefaultExistThenRepositoryShouldUpdateOnlyOneBlueprint() {
    Map<String, Blueprint> stringBlueprintMap = generateCacheData(3, 1);
    Set<Blueprint> blueprints = generateDatabaseData(3);
    ArgumentCaptor<Set> argumentCaptor = ArgumentCaptor.forClass(Set.class);
    Blueprint blueprint = stringBlueprintMap.get("multi-node-hdfs-yarn3");
    Set<Blueprint> resultList = new HashSet<>();
    resultList.add(blueprint);
    when(blueprintRepository.save(resultList)).thenReturn(resultList);
    Collection<Blueprint> resultSet = underTest.loadBlueprintsForTheSpecifiedUser(identityUser(), blueprints);
    verify(blueprintRepository).save(argumentCaptor.capture());
    Assert.assertEquals(1, argumentCaptor.getAllValues().size());
    Assert.assertEquals(4, resultSet.size());
}
Also used : Set(java.util.Set) Matchers.anySet(org.mockito.Matchers.anySet) HashSet(java.util.HashSet) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with Blueprint

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

the class BlueprintLoaderServiceTest method generateCacheData.

private Map<String, Blueprint> generateCacheData(int cacheSize, int startIndex) {
    Map<String, Blueprint> cacheData = new HashMap<>();
    for (int i = startIndex; i < cacheSize + startIndex; i++) {
        Blueprint blueprint = createBlueprint(DEFAULT, i);
        cacheData.put(blueprint.getName(), blueprint);
    }
    when(blueprintCache.defaultBlueprints()).thenReturn(cacheData);
    return cacheData;
}
Also used : HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 19 with Blueprint

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

the class ComponentLocatorServiceTest method setUp.

@Before
public void setUp() {
    cluster = new Cluster();
    cluster.setBlueprint(new Blueprint());
    HostGroup hg1 = createHostGroup("hg1", "myhost1");
    HostGroup hg2 = createHostGroup("hg2", "myhost2");
    Set<String> hg1Components = set("RESOURCEMANAGER", "Service1", "HIVE_SERVER");
    Set<String> hg2Components = set("NAMENODE", "Service2", "Service3");
    when(hostGroupService.getByCluster(anyLong())).thenReturn(ImmutableSet.of(hg1, hg2));
    when(blueprintProcessor.getComponentsInHostGroup(eq("hg1"))).thenReturn(hg1Components);
    when(blueprintProcessor.getComponentsInHostGroup(eq("hg2"))).thenReturn(hg2Components);
    when(blueprintProcessorFactory.get(anyString())).thenReturn(blueprintProcessor);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Matchers.anyString(org.mockito.Matchers.anyString) Before(org.junit.Before)

Example 20 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint 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

Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)71 Test (org.junit.Test)29 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)22 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)22 Stack (com.sequenceiq.cloudbreak.domain.Stack)16 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)7 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)6 List (java.util.List)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)4 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)4 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)4