Search in sources :

Example 1 with FreeIpaOperationPollerObject

use of com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject in project cloudbreak by hortonworks.

the class PollBindUserCreationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<PollBindUserCreationEvent> event) {
    PollBindUserCreationEvent data = event.getData();
    FreeIpaOperationPollerObject operationPollerObject = new FreeIpaOperationPollerObject(data.getOperationId(), OperationType.BIND_USER_CREATE.name(), operationV1Endpoint, data.getAccountId(), regionAwareInternalCrnGeneratorFactory);
    ExtendedPollingResult result = freeIpaOperationChecker.pollWithAbsoluteTimeout(new FreeIpaOperationCheckerTask<>(), operationPollerObject, pollIntervalMilliSec, pollWaitTimeSec, pollMaxError);
    if (result.isSuccess()) {
        return new ValidateKerberosConfigEvent(VALIDATE_KERBEROS_CONFIG_EXISTS_EVENT.event(), data.getResourceId(), true);
    } else {
        StringBuilder errorMessage = new StringBuilder("Bind user creation failed");
        if (result.getException() != null) {
            errorMessage.append(" with: ");
            errorMessage.append(result.getException().getMessage());
        }
        return new StackFailureEvent(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), data.getResourceId(), new Exception(errorMessage.toString()));
    }
}
Also used : FreeIpaOperationPollerObject(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent)

Example 2 with FreeIpaOperationPollerObject

use of com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject in project cloudbreak by hortonworks.

the class PollBindUserCreationHandlerTest method testPollingSuccessful.

@Test
public void testPollingSuccessful() {
    Event<PollBindUserCreationEvent> event = new Event<>(new PollBindUserCreationEvent(1L, "opId", "acc"));
    ArgumentCaptor<FreeIpaOperationPollerObject> captor = ArgumentCaptor.forClass(FreeIpaOperationPollerObject.class);
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build();
    when(freeIpaOperationChecker.pollWithAbsoluteTimeout(any(FreeIpaOperationCheckerTask.class), captor.capture(), anyLong(), anyLong(), anyInt())).thenReturn(extendedPollingResult);
    ValidateKerberosConfigEvent result = (ValidateKerberosConfigEvent) underTest.doAccept(new HandlerEvent<>(event));
    assertEquals(VALIDATE_KERBEROS_CONFIG_EXISTS_EVENT.event(), result.selector());
    assertEquals(1L, result.getResourceId());
    assertTrue(result.doesFreeipaExistsForEnv());
    FreeIpaOperationPollerObject pollerObject = captor.getValue();
    assertEquals(BIND_USER_CREATE.name(), pollerObject.getOperationType());
    assertEquals("opId", pollerObject.getOperationId());
    assertEquals(operationV1Endpoint, pollerObject.getOperationV1Endpoint());
}
Also used : FreeIpaOperationPollerObject(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Event(reactor.bus.Event) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) FreeIpaOperationCheckerTask(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationCheckerTask) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) Test(org.junit.jupiter.api.Test)

Example 3 with FreeIpaOperationPollerObject

use of com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject in project cloudbreak by hortonworks.

the class PollBindUserCreationHandlerTest method testPollingFailed.

@Test
public void testPollingFailed() {
    Event<PollBindUserCreationEvent> event = new Event<>(new PollBindUserCreationEvent(1L, "opId", "acc"));
    ArgumentCaptor<FreeIpaOperationPollerObject> captor = ArgumentCaptor.forClass(FreeIpaOperationPollerObject.class);
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().failure().withException(new Exception("error")).build();
    when(freeIpaOperationChecker.pollWithAbsoluteTimeout(any(FreeIpaOperationCheckerTask.class), captor.capture(), anyLong(), anyLong(), anyInt())).thenReturn(extendedPollingResult);
    StackFailureEvent result = (StackFailureEvent) underTest.doAccept(new HandlerEvent<>(event));
    assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
    assertEquals(1L, result.getResourceId());
    assertEquals("Bind user creation failed with: error", result.getException().getMessage());
    FreeIpaOperationPollerObject pollerObject = captor.getValue();
    assertEquals(BIND_USER_CREATE.name(), pollerObject.getOperationType());
    assertEquals("opId", pollerObject.getOperationId());
    assertEquals(operationV1Endpoint, pollerObject.getOperationV1Endpoint());
}
Also used : FreeIpaOperationPollerObject(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Event(reactor.bus.Event) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) FreeIpaOperationCheckerTask(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationCheckerTask) Test(org.junit.jupiter.api.Test)

Aggregations

PollBindUserCreationEvent (com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent)3 ValidateKerberosConfigEvent (com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent)3 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)3 StackFailureEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent)3 FreeIpaOperationPollerObject (com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationPollerObject)3 FreeIpaOperationCheckerTask (com.sequenceiq.cloudbreak.service.freeipa.FreeIpaOperationCheckerTask)2 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)2 Test (org.junit.jupiter.api.Test)2 Event (reactor.bus.Event)2