Search in sources :

Example 56 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class StopStartUpscaleCommissionViaCMHandlerTest method testErrorFromCmHostCollection.

@Test
void testErrorFromCmHostCollection() throws ClusterClientInitException {
    int commissionInstanceCount = 5;
    List<InstanceMetaData> instancesToCommission = createInstancesToCommission(commissionInstanceCount);
    HostGroup hostGroup = createHostGroup(instancesToCommission);
    Set<String> hostNames = instancesToCommission.stream().map(i -> i.getDiscoveryFQDN()).collect(Collectors.toSet());
    Map<String, InstanceMetaData> cmAvailableHosts = instancesToCommission.stream().collect(Collectors.toMap(i -> i.getDiscoveryFQDN(), i -> i));
    Set<String> recommissionedFqdns = cmAvailableHosts.keySet().stream().collect(Collectors.toUnmodifiableSet());
    setupPerTestMocks(hostGroup, hostNames, cmAvailableHosts, recommissionedFqdns);
    when(clusterCommissionService.collectHostsToCommission(eq(hostGroup), eq(hostNames))).thenThrow(new RuntimeException("collectHostsToCommissionError"));
    StopStartUpscaleCommissionViaCMRequest request = new StopStartUpscaleCommissionViaCMRequest(1L, INSTANCE_GROUP_NAME, instancesToCommission, Collections.emptyList());
    HandlerEvent handlerEvent = new HandlerEvent(Event.wrap(request));
    Selectable selectable = underTest.doAccept(handlerEvent);
    assertThat(selectable).isInstanceOf(StopStartUpscaleCommissionViaCMResult.class);
    StopStartUpscaleCommissionViaCMResult result = (StopStartUpscaleCommissionViaCMResult) selectable;
    assertThat(result.getSuccessfullyCommissionedFqdns()).hasSize(0);
    assertThat(result.getNotRecommissionedFqdns()).hasSize(0);
    assertThat(result.getErrorDetails().getMessage()).isEqualTo("collectHostsToCommissionError");
    assertThat(result.getStatus()).isEqualTo(EventStatus.FAILED);
    assertThat(result.selector()).isEqualTo("STOPSTARTUPSCALECOMMISSIONVIACMRESULT_ERROR");
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anySet(org.mockito.ArgumentMatchers.anySet) BeforeEach(org.junit.jupiter.api.BeforeEach) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) Mockito.lenient(org.mockito.Mockito.lenient) ArrayList(java.util.ArrayList) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) StopStartUpscaleCommissionViaCMResult(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StopStartUpscaleCommissionViaCMResult) HashSet(java.util.HashSet) Mockito.doThrow(org.mockito.Mockito.doThrow) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Event(reactor.bus.Event) CloudbreakFlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService) Map(java.util.Map) ClusterSetupService(com.sequenceiq.cloudbreak.cluster.api.ClusterSetupService) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) Mockito.when(org.mockito.Mockito.when) EventStatus(com.sequenceiq.cloudbreak.cloud.event.model.EventStatus) StopStartUpscaleCommissionViaCMRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.StopStartUpscaleCommissionViaCMRequest) Collectors(java.util.stream.Collectors) ClusterCommissionService(com.sequenceiq.cloudbreak.cluster.api.ClusterCommissionService) Test(org.junit.jupiter.api.Test) List(java.util.List) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) Optional(java.util.Optional) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Collections(java.util.Collections) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) StopStartUpscaleCommissionViaCMResult(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StopStartUpscaleCommissionViaCMResult) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StopStartUpscaleCommissionViaCMRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.StopStartUpscaleCommissionViaCMRequest) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) Test(org.junit.jupiter.api.Test)

Example 57 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class HealthCheckHandlerTest method doAccept.

@Test
void doAccept() {
    UpgradeCcmHealthCheckRequest request = new UpgradeCcmHealthCheckRequest(STACK_ID, CLUSTER_ID, Tunnel.CCM);
    when(event.getData()).thenReturn(request);
    Selectable result = underTest.doAccept(event);
    verify(upgradeCcmService).healthCheck(STACK_ID);
    assertThat(result.selector()).isEqualTo("UPGRADECCMHEALTHCHECKRESULT");
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmHealthCheckRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ccm.UpgradeCcmHealthCheckRequest) Test(org.junit.jupiter.api.Test)

Example 58 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class PushSaltStateHandlerTest method doAccept.

@Test
void doAccept() {
    UpgradeCcmPushSaltStatesRequest request = new UpgradeCcmPushSaltStatesRequest(STACK_ID, CLUSTER_ID, Tunnel.CCM);
    when(event.getData()).thenReturn(request);
    Selectable result = underTest.doAccept(event);
    verify(upgradeCcmService).pushSaltState(STACK_ID, CLUSTER_ID);
    assertThat(result.selector()).isEqualTo("UPGRADECCMPUSHSALTSTATESRESULT");
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmPushSaltStatesRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ccm.UpgradeCcmPushSaltStatesRequest) Test(org.junit.jupiter.api.Test)

Example 59 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ReconfigureNginxHandlerTest method orchestrationException.

@Test
void orchestrationException() throws CloudbreakOrchestratorException {
    UpgradeCcmReconfigureNginxRequest request = new UpgradeCcmReconfigureNginxRequest(STACK_ID, CLUSTER_ID, Tunnel.CCM);
    when(event.getData()).thenReturn(request);
    doThrow(new CloudbreakOrchestratorFailedException("salt error")).when(upgradeCcmService).reconfigureNginx(any());
    Selectable result = underTest.doAccept(event);
    verify(upgradeCcmService).reconfigureNginx(STACK_ID);
    assertThat(result.selector()).isEqualTo("UPGRADECCMFAILEDEVENT");
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) UpgradeCcmReconfigureNginxRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ccm.UpgradeCcmReconfigureNginxRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.jupiter.api.Test)

Example 60 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class RegisterClusterProxyHandlerTest method doAccept.

@Test
void doAccept() {
    UpgradeCcmRegisterClusterProxyRequest request = new UpgradeCcmRegisterClusterProxyRequest(STACK_ID, CLUSTER_ID, Tunnel.CCM);
    when(event.getData()).thenReturn(request);
    Selectable result = underTest.doAccept(event);
    verify(upgradeCcmService).registerClusterProxy(STACK_ID);
    assertThat(result.selector()).isEqualTo("UPGRADECCMREGISTERCLUSTERPROXYRESULT");
}
Also used : UpgradeCcmRegisterClusterProxyRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ccm.UpgradeCcmRegisterClusterProxyRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.jupiter.api.Test)

Aggregations

Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)283 Test (org.junit.jupiter.api.Test)93 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)48 Map (java.util.Map)47 List (java.util.List)36 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)35 Collectors (java.util.stream.Collectors)35 PollerException (com.dyngr.exception.PollerException)32 PollerStoppedException (com.dyngr.exception.PollerStoppedException)32 UserBreakException (com.dyngr.exception.UserBreakException)32 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)30 Optional (java.util.Optional)30 Set (java.util.Set)30 Bean (org.springframework.context.annotation.Bean)28 Event (reactor.bus.Event)28 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)27 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)27 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)27 Inject (javax.inject.Inject)24 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)23