use of com.sequenceiq.cloudbreak.api.model.StackResponse in project cloudbreak by hortonworks.
the class ClusterSecurityService method tryResolve.
public AmbariStack tryResolve(Ambari ambari) {
try {
String host = ambari.getHost();
String user = ambari.getUser();
String pass = ambari.getPass();
AmbariAddressJson ambariAddressJson = new AmbariAddressJson();
ambariAddressJson.setAmbariAddress(host);
StackResponse stack = cloudbreakClient.stackV1Endpoint().getStackForAmbari(ambariAddressJson);
Long id = stack.getId();
SecurityConfig securityConfig = tlsSecurityService.prepareSecurityConfig(id);
if (user == null || pass == null) {
AutoscaleClusterResponse clusterResponse = cloudbreakClient.clusterEndpoint().getForAutoscale(id);
return new AmbariStack(new Ambari(host, ambari.getPort(), clusterResponse.getUserName(), clusterResponse.getPassword()), id, securityConfig);
} else {
return new AmbariStack(ambari, id, securityConfig);
}
} catch (RuntimeException ignored) {
return new AmbariStack(ambari);
}
}
use of com.sequenceiq.cloudbreak.api.model.StackResponse in project cloudbreak by hortonworks.
the class StackToStackResponseConverterTest method testConvertWithoutNetwork.
@Test
public void testConvertWithoutNetwork() {
// GIVEN
getSource().setNetwork(null);
given(conversionService.convert(any(Object.class), any(Class.class))).willReturn(new ImageJson()).willReturn(new StackAuthenticationResponse()).willReturn(new CredentialResponse()).willReturn(new ClusterResponse()).willReturn(new FailurePolicyResponse()).willReturn(new OrchestratorResponse()).willReturn(new CloudbreakDetailsJson());
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<InstanceGroupRequest>());
// WHEN
StackResponse result = underTest.convert(getSource());
// THEN
assertAllFieldsNotNull(result, Arrays.asList("networkId", "platformVariant", "ambariVersion", "hdpVersion", "network", "flexSubscription"));
}
use of com.sequenceiq.cloudbreak.api.model.StackResponse in project cloudbreak by hortonworks.
the class StackToStackResponseConverterTest method testConvertWithoutCredential.
@Test
public void testConvertWithoutCredential() {
// GIVEN
given(conversionService.convert(any(Object.class), any(Class.class))).willReturn(new ImageJson()).willReturn(new StackAuthenticationResponse()).willReturn(new CredentialResponse()).willReturn(new ClusterResponse()).willReturn(new FailurePolicyResponse()).willReturn(new NetworkResponse()).willReturn(new OrchestratorResponse()).willReturn(new CloudbreakDetailsJson());
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<InstanceGroupRequest>());
// WHEN
StackResponse result = underTest.convert(getSource());
// THEN
assertAllFieldsNotNull(result, Arrays.asList("credentialId", "cloudPlatform", "platformVariant", "ambariVersion", "hdpVersion", "stackTemplate", "cloudbreakDetails", "flexSubscription"));
}
use of com.sequenceiq.cloudbreak.api.model.StackResponse in project cloudbreak by hortonworks.
the class MockInstanceTerminationReplicationErrorTest method testInstanceTermination.
@Test
public void testInstanceTermination() throws Exception {
// GIVEN
// WHEN
Long stackId = Long.parseLong(getItContext().getContextParam(CloudbreakITContextConstants.STACK_ID));
StackResponse stackResponse = getStackResponse(stackId);
// THEN
String hostGroupName = "worker";
String instanceId = getInstanceId(stackResponse, hostGroupName);
getCloudbreakClient().stackV2Endpoint().deleteInstance(stackResponse.getId(), instanceId);
Map<String, String> desiredStatuses = new HashMap<>();
desiredStatuses.put("status", "AVAILABLE");
desiredStatuses.put("clusterStatus", "AVAILABLE");
String reason = CloudbreakUtil.getFailedStatusReason(getCloudbreakClient(), stackId.toString(), desiredStatuses, singleton(WaitResult.SUCCESSFUL));
Assert.assertEquals(reason, "Node(s) could not be removed from the cluster: There is not enough node to downscale. " + "Check the replication factor and the ApplicationMaster occupation.");
}
use of com.sequenceiq.cloudbreak.api.model.StackResponse in project cloudbreak by hortonworks.
the class MockInstanceTerminationTest method testInstanceTermination.
@Test
public void testInstanceTermination() {
// GIVEN
// WHEN
Long stackId = Long.parseLong(getItContext().getContextParam(CloudbreakITContextConstants.STACK_ID));
StackResponse stackResponse = getStackResponse(stackId);
// THEN
String hostGroupName = "compute";
int before = getInstanceMetaData(stackResponse, hostGroupName).size();
String instanceId = getInstanceId(stackResponse, hostGroupName);
getCloudbreakClient().stackV2Endpoint().deleteInstance(stackResponse.getId(), instanceId);
Map<String, String> desiredStatuses = new HashMap<>();
desiredStatuses.put("status", "AVAILABLE");
desiredStatuses.put("clusterStatus", "AVAILABLE");
CloudbreakUtil.waitAndCheckStatuses(getCloudbreakClient(), stackId.toString(), desiredStatuses);
int after = getInstanceMetaData(getStackResponse(stackId), hostGroupName).size();
Assert.assertEquals(after, before - 1);
stackResponse = getStackResponse(stackId);
Assert.assertTrue(getInstanceMetaData(stackResponse, hostGroupName).stream().noneMatch(a -> a.getDiscoveryFQDN().equals(instanceId)));
}
Aggregations