Search in sources :

Example 41 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayServiceTest method testGetNewPrimaryGatewayInstanceIdWhenExistingPrimaryGwAndMasterIsOnListToAvoid.

@Test
void testGetNewPrimaryGatewayInstanceIdWhenExistingPrimaryGwAndMasterIsOnListToAvoid() throws Exception {
    Stack stack = mock(Stack.class);
    GatewayConfig gatewayConfig = mock(GatewayConfig.class);
    InstanceMetaData im1 = mock(InstanceMetaData.class);
    InstanceMetaData im2 = mock(InstanceMetaData.class);
    InstanceMetaData im3 = mock(InstanceMetaData.class);
    Node node = mock(Node.class);
    Set<Node> allNodes = Set.of(node);
    when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
    when(gatewayConfig.getInstanceId()).thenReturn(INSTANCE_ID_2);
    when(freeIpaNodeUtilService.mapInstancesToNodes(any())).thenReturn(allNodes);
    when(hostOrchestrator.getFreeIpaMasterHostname(any(), any())).thenReturn(Optional.of(HOSTNAME_1));
    when(stack.getNotDeletedInstanceMetaDataList()).thenReturn(List.of(im1, im2, im3));
    when(im1.getDiscoveryFQDN()).thenReturn(HOSTNAME_1);
    lenient().when(im2.getDiscoveryFQDN()).thenReturn(HOSTNAME_2);
    lenient().when(im3.getDiscoveryFQDN()).thenReturn(HOSTNAME_3);
    when(im1.getInstanceId()).thenReturn(INSTANCE_ID_1);
    lenient().when(im2.getInstanceId()).thenReturn(INSTANCE_ID_2);
    when(im3.getInstanceId()).thenReturn(INSTANCE_ID_3);
    assertEquals(INSTANCE_ID_3, underTest.selectNewPrimaryGatewayInstanceId(stack, List.of(INSTANCE_ID_1, INSTANCE_ID_2)));
    verify(gatewayConfigService).getPrimaryGatewayConfig(eq(stack));
    verify(hostOrchestrator).getFreeIpaMasterHostname(eq(gatewayConfig), eq(allNodes));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.jupiter.api.Test)

Example 42 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class CreateFullBackupHandlerTest method testBackupSuccessful.

@Test
public void testBackupSuccessful() throws CloudbreakOrchestratorFailedException {
    Stack stack = mock(Stack.class);
    when(stackService.getByIdWithListsInTransaction(2L)).thenReturn(stack);
    Set<InstanceMetaData> metaDataSet = Set.of();
    when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(metaDataSet);
    Node node1 = createNode("node1");
    Node node2 = createNode("node2");
    Set<Node> nodes = Set.of(node1, node2);
    when(nodeService.mapInstancesToNodes(metaDataSet)).thenReturn(nodes);
    GatewayConfig gatewayConfig = mock(GatewayConfig.class);
    when(gatewayConfigService.getPrimaryGatewayConfig(stack)).thenReturn(gatewayConfig);
    StackEvent result = (StackEvent) underTest.doAccept(new HandlerEvent<>(new Event<>(new CreateFullBackupEvent(2L))));
    ArgumentCaptor<OrchestratorStateParams> captor = ArgumentCaptor.forClass(OrchestratorStateParams.class);
    verify(orchestrator, times(2)).runOrchestratorState(captor.capture());
    List<OrchestratorStateParams> stateParams = captor.getAllValues();
    assertThat(stateParams, everyItem(allOf(hasProperty("primaryGatewayConfig", is(gatewayConfig)), hasProperty("state", is("freeipa.backup-full")), hasProperty("allNodes", is(nodes)))));
    assertThat(stateParams, hasItem(hasProperty("targetHostNames", allOf(hasItem("node1"), iterableWithSize(1)))));
    assertThat(stateParams, hasItem(hasProperty("targetHostNames", allOf(hasItem("node2"), iterableWithSize(1)))));
    assertEquals(2L, result.getResourceId());
    assertEquals(FullBackupEvent.FULL_BACKUP_SUCCESSFUL_EVENT.event(), result.selector());
}
Also used : CreateFullBackupEvent(com.sequenceiq.freeipa.flow.freeipa.backup.full.event.CreateFullBackupEvent) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) OrchestratorStateParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateParams) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.jupiter.api.Test)

Example 43 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class TelemetryUpgradeService method upgradeTelemetrySaltPillars.

public void upgradeTelemetrySaltPillars(Long stackId, Set<TelemetryComponentType> components) throws CloudbreakOrchestratorFailedException {
    OrchestratorMetadata metadata = orchestratorMetadataProvider.getOrchestratorMetadata(stackId);
    Set<Node> availableNodes = collectAvailableNodes(metadata);
    if (CollectionUtils.isEmpty(availableNodes)) {
        String message = "Not found any available nodes for stack: " + stackId;
        LOGGER.info(message);
        throw new CloudbreakOrchestratorFailedException(message);
    } else {
        Map<String, SaltPillarProperties> pillarPropMap = telemetryConfigProvider.createTelemetryConfigs(stackId, components);
        SaltConfig saltConfig = new SaltConfig(pillarPropMap);
        hostOrchestrator.initSaltConfig(metadata.getStack(), metadata.getGatewayConfigs(), availableNodes, saltConfig, metadata.getExitCriteriaModel());
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorMetadata(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadata) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 44 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class DiagnosticsOperationsServiceTest method nodes.

private Set<Node> nodes() {
    Set<Node> nodes = new HashSet<>();
    nodes.add(new Node("host1", null, null, null, "host1", null, null));
    return nodes;
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) HashSet(java.util.HashSet)

Example 45 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class TelemetryUpgradeServiceTest method testUpgradeTelemetrySaltPillarsWithUnresponsiveNodes.

@Test
public void testUpgradeTelemetrySaltPillarsWithUnresponsiveNodes() throws Exception {
    // GIVEN
    Set<Node> nodes = nodes();
    Set<TelemetryComponentType> componentTypes = Set.of(TelemetryComponentType.CDP_TELEMETRY);
    given(orchestratorMetadataProvider.getOrchestratorMetadata(STACK_ID)).willReturn(metadata);
    given(metadata.getNodes()).willReturn(nodes);
    given(telemetryOrchestrator.collectUnresponsiveNodes(anyList(), anySet(), any())).willReturn(nodes);
    // WHEN
    CloudbreakOrchestratorFailedException result = assertThrows(CloudbreakOrchestratorFailedException.class, () -> underTest.upgradeTelemetrySaltPillars(STACK_ID, componentTypes));
    // THEN
    assertTrue(result.getMessage().contains("Not found any available nodes"));
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) TelemetryComponentType(com.sequenceiq.cloudbreak.telemetry.TelemetryComponentType) Test(org.junit.jupiter.api.Test)

Aggregations

Node (com.sequenceiq.cloudbreak.common.orchestration.Node)126 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)57 HashSet (java.util.HashSet)42 Map (java.util.Map)32 JsonNode (com.fasterxml.jackson.databind.JsonNode)30 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)29 Test (org.junit.Test)29 HashMap (java.util.HashMap)28 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)27 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)26 ArrayList (java.util.ArrayList)26 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)25 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)25 Set (java.util.Set)25 Test (org.junit.jupiter.api.Test)25 List (java.util.List)22 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)21 IOException (java.io.IOException)21 Collectors (java.util.stream.Collectors)21 BootstrapParams (com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams)19