Search in sources :

Example 81 with InstanceMetaData

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

the class StackStatusIntegrationTest method createInstance.

private InstanceMetaData createInstance(String instanceName) {
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    instanceMetaData.setInstanceId(instanceName);
    instanceMetaData.setDiscoveryFQDN(instanceName);
    return instanceMetaData;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)

Example 82 with InstanceMetaData

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

the class UnhealthyInstancesDetectionHandlerTest method shouldCreateResponseWithExactInstances.

@Test
public void shouldCreateResponseWithExactInstances() {
    long stackId = 1L;
    UnhealthyInstancesDetectionRequest unhealthyInstancesDetectionRequest = new UnhealthyInstancesDetectionRequest(stackId);
    Event<UnhealthyInstancesDetectionRequest> event = mock(Event.class);
    when(event.getData()).thenReturn(unhealthyInstancesDetectionRequest);
    Stack stack = mock(Stack.class);
    when(stackService.getByIdWithTransaction(stackId)).thenReturn(stack);
    Set<InstanceMetaData> unhealthyInstances = new HashSet<>();
    InstanceMetaData imd1 = mock(InstanceMetaData.class);
    InstanceMetaData imd2 = mock(InstanceMetaData.class);
    InstanceMetaData imd3 = mock(InstanceMetaData.class);
    unhealthyInstances.add(imd1);
    unhealthyInstances.add(imd2);
    unhealthyInstances.add(imd3);
    when(candidateUnhealthyInstanceSelector.selectCandidateUnhealthyInstances(stack.getId())).thenReturn(unhealthyInstances);
    Set<String> unhealthyInstanceIds = new HashSet<>();
    unhealthyInstanceIds.add("i-0f1e0605506aaaaaa");
    unhealthyInstanceIds.add("i-0f1e0605506cccccc");
    when(unhealthyInstancesFinalizer.finalizeUnhealthyInstances(stack, unhealthyInstances)).thenReturn(unhealthyInstanceIds);
    unhealthyInstancesDetectionHandler.accept(event);
    verify(eventBus).notify(eq(EventSelectorUtil.selector(UnhealthyInstancesDetectionResult.class)), argThat(new UnhealthyInstancesResultMatcher(unhealthyInstanceIds)));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) UnhealthyInstancesDetectionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 83 with InstanceMetaData

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

the class ClusterHostServiceRunnerTest method createInstanceMetadata.

private InstanceMetaData createInstanceMetadata(String fqdn, InstanceGroup instanceGroup, String privateIp) {
    InstanceMetaData imd1 = new InstanceMetaData();
    imd1.setDiscoveryFQDN(fqdn);
    imd1.setInstanceGroup(instanceGroup);
    imd1.setPrivateIp(privateIp);
    return imd1;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)

Example 84 with InstanceMetaData

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

the class GrainPropertiesServiceTest method testAllInOne.

@Test
public void testAllInOne() {
    when(componentLocator.getComponentLocationByHostname(eq(cluster), argThat(namenodeMatcher))).thenReturn(Map.of("NAMENODE", List.of("NMHOST")));
    when(componentLocator.getComponentLocationByHostname(eq(cluster), argThat(knoxGatewayMatcher))).thenReturn(Map.of("KNOX_GATEWAY", List.of("KWGHOST")));
    GatewayConfig gwconfig = mock(GatewayConfig.class);
    when(gwconfig.getPublicAddress()).thenReturn("GWPUBADDR");
    when(gwconfig.getHostname()).thenReturn("GWHOSTNAME");
    Node node1 = new Node("", "", "", "", "node1fqdn", "");
    InstanceMetaData im1 = new InstanceMetaData();
    im1.setDiscoveryFQDN(node1.getHostname());
    InstanceGroup logIg = new InstanceGroup();
    logIg.setAttributes(new Json("{}"));
    logIg.setCloudIdentityType(CloudIdentityType.LOG);
    im1.setInstanceGroup(logIg);
    when(instanceMetaDataService.getAllInstanceMetadataByStackId(1L)).thenReturn(Set.of(im1));
    List<GrainProperties> result = underTest.createGrainProperties(List.of(gwconfig), cluster, Set.of(node1));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("GWHOSTNAME", Map.of("gateway-address", "GWPUBADDR")))))));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("NMHOST", Map.of("roles", "namenode")))))));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("KWGHOST", Map.of("roles", "knox")))))));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("node1fqdn", Map.of("roles", "LOG_CLOUD_IDENTITY_ROLE")))))));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainProperties(com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties) Json(com.sequenceiq.cloudbreak.common.json.Json) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 85 with InstanceMetaData

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

the class ClusterUpscaleServiceTest method newInstance.

private InstanceMetaData newInstance(InstanceStatus status) {
    InstanceMetaData instance = new InstanceMetaData();
    instance.setInstanceStatus(status);
    return instance;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)

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