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