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;
}
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);
}
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();
}
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());
}
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);
}
Aggregations