Search in sources :

Example 71 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class VmStatusCheckerConclusionStep method check.

@Override
public Conclusion check(Long resourceId) {
    Stack stack = stackService.getById(resourceId);
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    Set<InstanceMetaData> runningInstances = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
    if (isClusterManagerRunning(stack, connector)) {
        return checkCMForInstanceStatuses(connector, runningInstances, stack.getCluster().getId());
    } else {
        return checkProviderForInstanceStatuses(stack, runningInstances);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 72 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class LoadBalancerToLoadBalancerResponseConverterTest method ceateInstanceMetadata.

private List<InstanceMetaData> ceateInstanceMetadata() {
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setInstanceId(INSTANCE_ID);
    return List.of(instanceMetaData);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)

Example 73 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class VmStatusCheckerConclusionStepTest method checkShouldHandleMissingFqdns.

@Test
public void checkShouldHandleMissingFqdns() {
    when(clusterStatusService.isClusterManagerRunningQuickCheck()).thenReturn(Boolean.FALSE);
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setInstanceId("1");
    when(instanceMetaDataService.findNotTerminatedAndNotZombieForStack(anyLong())).thenReturn(Set.of(instanceMetaData));
    when(stackInstanceStatusChecker.queryInstanceStatuses(any(), anyList())).thenReturn(List.of(createCloudVmInstanceStatus("1", false)));
    Conclusion conclusion = underTest.check(1L);
    assertFalse(conclusion.isFailureFound());
    assertNull(conclusion.getConclusion());
    assertNull(conclusion.getDetails());
    assertEquals(VmStatusCheckerConclusionStep.class, conclusion.getConclusionStepClass());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Test(org.junit.jupiter.api.Test)

Example 74 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class InstanceMetaDataToCloudInstanceConverterTest method testConvertWhenParamsFromInstanceMetaDataOnly.

@Test
public void testConvertWhenParamsFromInstanceMetaDataOnly() {
    InstanceMetaData source = getSource();
    addParamsToInstanceMetaData(source);
    initStackToCloudStackConverter(false);
    CloudInstance cloudInstance = underTest.convert(source, environment, new StackAuthentication());
    verifyParams(cloudInstance, SUBNET_ID_2, INSTANCE_NAME_2, AVAILABILITY_ZONE_2);
    assertEquals(source.getInstanceId(), cloudInstance.getInstanceId());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Test(org.junit.jupiter.api.Test) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)

Example 75 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class InstanceMetaDataToCloudInstanceConverterTest method testConvertWhenParamsFromInstanceMetaDataAreOverriddenByCloudInstance.

@Test
public void testConvertWhenParamsFromInstanceMetaDataAreOverriddenByCloudInstance() {
    InstanceMetaData source = getSource();
    addParamsToInstanceMetaData(source);
    initStackToCloudStackConverter(true);
    CloudInstance cloudInstance = underTest.convert(source, environment, new StackAuthentication());
    verifyParams(cloudInstance, SUBNET_ID, INSTANCE_NAME, AVAILABILITY_ZONE);
    assertEquals(source.getInstanceId(), cloudInstance.getInstanceId());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Test(org.junit.jupiter.api.Test) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)

Aggregations

InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)415 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)165 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)152 Test (org.junit.jupiter.api.Test)143 Map (java.util.Map)92 HashSet (java.util.HashSet)90 Set (java.util.Set)86 List (java.util.List)84 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)77 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)73 Collectors (java.util.stream.Collectors)71 ArrayList (java.util.ArrayList)62 Test (org.junit.Test)60 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)57 Optional (java.util.Optional)52 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)48 Inject (javax.inject.Inject)47 Logger (org.slf4j.Logger)47 LoggerFactory (org.slf4j.LoggerFactory)47 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)45