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));
}
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());
}
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());
}
}
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;
}
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"));
}
Aggregations