Search in sources :

Example 21 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class MockSparkServer method generateInstances.

private static Map<String, CloudVmMetaDataStatus> generateInstances() {
    Map<String, CloudVmMetaDataStatus> instanceMap = new HashMap<>();
    MockInstanceUtil mockInstanceUtil = new MockInstanceUtil(MOCK_SERVER_ADDRESS, SSH_PORT);
    mockInstanceUtil.addInstance(instanceMap, NUMBER_OF_INSTANCES);
    return instanceMap;
}
Also used : CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) HashMap(java.util.HashMap) MockInstanceUtil(com.sequenceiq.it.cloudbreak.mock.MockInstanceUtil)

Example 22 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class AmbariHostsResponse method handle.

@Override
public Object handle(Request request, Response response) {
    response.type("text/plain");
    List<Map<String, ?>> itemList = new ArrayList<>();
    for (Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
        CloudVmMetaDataStatus status = stringCloudVmMetaDataStatusEntry.getValue();
        if (InstanceStatus.STARTED == status.getCloudVmInstanceStatus().getStatus()) {
            Hosts hosts = new Hosts(Collections.singletonList(HostNameUtil.generateHostNameByIp(status.getMetaData().getPrivateIp())), "HEALTHY");
            itemList.add(Collections.singletonMap("Hosts", hosts));
        }
    }
    return Collections.singletonMap("items", itemList);
}
Also used : Hosts(com.sequenceiq.it.spark.ambari.model.Hosts) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 23 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltFailTest method testClusterCreation.

@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackId = Integer.valueOf(stackIdStr);
    Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
    List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
    Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
    // WHEN
    ClusterRequest clusterRequest = new ClusterRequest();
    clusterRequest.setName(clusterName);
    clusterRequest.setDescription("Cluster for integration test");
    clusterRequest.setEnableSecurity(enableSecurity);
    clusterRequest.setPassword(ambariPassword);
    clusterRequest.setUserName(ambariUser);
    clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
    clusterRequest.setHostGroups(hostGroupJsons1);
    KerberosRequest kerberosRequest = new KerberosRequest();
    kerberosRequest.setAdmin(kerberosAdmin);
    kerberosRequest.setPassword(kerberosPassword);
    kerberosRequest.setMasterKey(kerberosMasterKey);
    clusterRequest.setKerberos(kerberosRequest);
    initSpark();
    Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
    addSaltMappings(instanceMap);
    addAmbariMappings(instanceMap);
    ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
    Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
    // THEN
    Assert.assertNotNull(clusterId);
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
    String failMessage = "Source file salt://ambari/scripts/ambari-server-initttt.sh not found | " + "Service ambari-server is already enabled, and is dead | " + "Package haveged is already installed.";
    CloudbreakUtil.checkClusterFailed(getCloudbreakClient().stackV1Endpoint(), stackIdStr, failMessage);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ClusterV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) Parameters(org.testng.annotations.Parameters) AbstractMockIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractMockIntegrationTest) Test(org.testng.annotations.Test)

Example 24 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltSuccessTest method configMockServer.

@BeforeClass
@Parameters({ "clusterName", "mockPort", "sshPort" })
public void configMockServer(String clusterName, @Optional("9443") int mockPort, @Optional("2020") int sshPort) {
    IntegrationTestContext itContext = getItContext();
    Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
    if (instanceMap == null || instanceMap.isEmpty()) {
        throw new IllegalStateException("instance map should not be empty!");
    }
    StackCreationMock stackCreationMock = (StackCreationMock) applicationContext.getBean(StackCreationMock.NAME, mockPort, sshPort, instanceMap);
    stackCreationMock.addSaltMappings();
    stackCreationMock.addAmbariMappings(clusterName);
    itContext.putContextParam(CloudbreakV2Constants.MOCK_SERVER, stackCreationMock);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) BeforeClass(org.testng.annotations.BeforeClass) Parameters(org.testng.annotations.Parameters)

Example 25 with CloudVmMetaDataStatus

use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.

the class MockClusterScalingTest method configMockServer.

@BeforeClass
@Parameters({ "mockPort", "sshPort", "scalingAdjustment", "instanceGroup" })
public void configMockServer(@Optional("9443") int mockPort, @Optional("2020") int sshPort, @Optional("1") int scalingAdjustment, String instanceGroup) {
    IntegrationTestContext itContext = getItContext();
    Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
    ScalingMock scalingMock = (ScalingMock) applicationContext.getBean(ScalingMock.NAME, mockPort, sshPort, instanceMap);
    scalingMock.addSPIEndpoints();
    scalingMock.addMockEndpoints();
    scalingMock.addAmbariMappings(CLUSTER_NAME);
    if (scalingAdjustment > 0) {
        scalingMock.addInstance(scalingAdjustment);
    }
    itContext.putContextParam(CloudbreakV2Constants.MOCK_SERVER, scalingMock);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) ScalingMock(com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock) BeforeClass(org.testng.annotations.BeforeClass) Parameters(org.testng.annotations.Parameters)

Aggregations

CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)43 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)20 ArrayList (java.util.ArrayList)18 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)13 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)12 CloudInstanceMetaData (com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData)10 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)9 Service (spark.Service)8 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)7 Map (java.util.Map)7 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)6 AmazonCloudFormationClient (com.amazonaws.services.cloudformation.AmazonCloudFormationClient)6 Instance (com.amazonaws.services.ec2.model.Instance)6 Reservation (com.amazonaws.services.ec2.model.Reservation)6 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)6 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)6 AmbariClusterResponse (com.sequenceiq.it.spark.ambari.AmbariClusterResponse)6 EmptyAmbariResponse (com.sequenceiq.it.spark.ambari.EmptyAmbariResponse)6 CreateTagsRequest (com.amazonaws.services.ec2.model.CreateTagsRequest)5 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)5