Search in sources :

Example 1 with StackResponse

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);
    }
}
Also used : AmbariStack(com.sequenceiq.periscope.model.AmbariStack) AutoscaleClusterResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleClusterResponse) AmbariAddressJson(com.sequenceiq.cloudbreak.api.model.AmbariAddressJson) SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) Ambari(com.sequenceiq.periscope.domain.Ambari) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse)

Example 2 with StackResponse

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"));
}
Also used : InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) ClusterResponse(com.sequenceiq.cloudbreak.api.model.ClusterResponse) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse) OrchestratorResponse(com.sequenceiq.cloudbreak.api.model.OrchestratorResponse) FailurePolicyResponse(com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) ImageJson(com.sequenceiq.cloudbreak.api.model.ImageJson) StackAuthenticationResponse(com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Test(org.junit.Test)

Example 3 with StackResponse

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"));
}
Also used : InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) ClusterResponse(com.sequenceiq.cloudbreak.api.model.ClusterResponse) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse) OrchestratorResponse(com.sequenceiq.cloudbreak.api.model.OrchestratorResponse) FailurePolicyResponse(com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) ImageJson(com.sequenceiq.cloudbreak.api.model.ImageJson) NetworkResponse(com.sequenceiq.cloudbreak.api.model.NetworkResponse) StackAuthenticationResponse(com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Test(org.junit.Test)

Example 4 with StackResponse

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.");
}
Also used : HashMap(java.util.HashMap) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 5 with StackResponse

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)));
}
Also used : AfterClass(org.testng.annotations.AfterClass) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakITContextConstants(com.sequenceiq.it.cloudbreak.CloudbreakITContextConstants) MockServer(com.sequenceiq.it.cloudbreak.v2.mock.MockServer) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) Optional(org.testng.annotations.Optional) Assert(org.testng.Assert) Map(java.util.Map) Parameters(org.testng.annotations.Parameters) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) InstanceMetaDataJson(com.sequenceiq.cloudbreak.api.model.InstanceMetaDataJson) CloudbreakUtil(com.sequenceiq.it.cloudbreak.CloudbreakUtil) CloudbreakV2Constants(com.sequenceiq.it.cloudbreak.v2.CloudbreakV2Constants) Collections(java.util.Collections) HashMap(java.util.HashMap) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)32 Test (org.testng.annotations.Test)10 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)9 Parameters (org.testng.annotations.Parameters)9 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)8 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)7 Map (java.util.Map)7 CredentialResponse (com.sequenceiq.cloudbreak.api.model.CredentialResponse)6 ImageJson (com.sequenceiq.cloudbreak.api.model.ImageJson)6 OrchestratorResponse (com.sequenceiq.cloudbreak.api.model.OrchestratorResponse)6 StackAuthenticationResponse (com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse)6 HashMap (java.util.HashMap)6 CloudbreakDetailsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson)5 ClusterResponse (com.sequenceiq.cloudbreak.api.model.ClusterResponse)5 FailurePolicyResponse (com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse)5 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)5 InstanceMetaDataJson (com.sequenceiq.cloudbreak.api.model.InstanceMetaDataJson)5 NetworkResponse (com.sequenceiq.cloudbreak.api.model.NetworkResponse)5 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)5 Test (org.junit.Test)5