use of com.sequenceiq.environment.environment.dto.EnvironmentStartDto in project cloudbreak by hortonworks.
the class StartFreeIpaHandlerTest method shouldStopFreeipaButStatusIsNull.
@Test
public void shouldStopFreeipaButStatusIsNull() {
String envCrn = "someCrnValue";
EnvironmentDto environmentDto = createEnvironmentDto();
environmentDto.setResourceCrn(envCrn);
Event<EnvironmentStartDto> environmentDtoEvent = Event.wrap(mockEnvironmentDto);
when(mockFreeIpaService.describe(envCrn)).thenReturn(Optional.of(mockDescribeFreeIpaResponse));
underTest.accept(environmentDtoEvent);
verifyEnvStartFailedEvent(environmentDtoEvent, "FreeIPA status is unpredictable, env start will be interrupted.");
}
use of com.sequenceiq.environment.environment.dto.EnvironmentStartDto in project cloudbreak by hortonworks.
the class StartFreeIpaHandlerTest method shouldThrowErrorWhenUnstartable.
@ParameterizedTest
@EnumSource(value = DetailedStackStatus.class, names = { "STOPPED", "STOP_FAILED", "START_FAILED", "START_IN_PROGRESS" }, mode = EnumSource.Mode.EXCLUDE)
public void shouldThrowErrorWhenUnstartable(DetailedStackStatus detailedStackStatus) {
if (!detailedStackStatus.getAvailabilityStatus().isAvailable()) {
String envCrn = "someCrnValue";
EnvironmentDto environmentDto = createEnvironmentDto();
environmentDto.setResourceCrn(envCrn);
Event<EnvironmentStartDto> environmentDtoEvent = Event.wrap(mockEnvironmentDto);
when(mockDescribeFreeIpaResponse.getAvailabilityStatus()).thenReturn(detailedStackStatus.getAvailabilityStatus());
when(mockDescribeFreeIpaResponse.getStatus()).thenReturn(detailedStackStatus.getStatus());
when(mockFreeIpaService.describe(envCrn)).thenReturn(Optional.of(mockDescribeFreeIpaResponse));
underTest.accept(environmentDtoEvent);
verifyEnvStartFailedEvent(environmentDtoEvent, "FreeIPA is not in a valid state to start! Current state is: " + detailedStackStatus.getStatus());
}
}
use of com.sequenceiq.environment.environment.dto.EnvironmentStartDto in project cloudbreak by hortonworks.
the class EnvStartActions method startFreeipa.
@Bean(name = "START_FREEIPA_STATE")
public Action<?, ?> startFreeipa() {
return new AbstractEnvStartAction<>(EnvStartEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.START_FREEIPA_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_FREEIPA_STARTED;
EnvStartState envStartState = EnvStartState.START_FREEIPA_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStartState);
EnvironmentStartDto environmentStartDto = EnvironmentStartDto.builder().withDataHubStart(payload.getDataHubStartAction()).withEnvironmentDto(envDto).withId(envDto.getId()).build();
sendEvent(context, EnvStartHandlerSelectors.START_FREEIPA_HANDLER_EVENT.selector(), environmentStartDto);
}
};
}
use of com.sequenceiq.environment.environment.dto.EnvironmentStartDto in project cloudbreak by hortonworks.
the class StartFreeIpaHandlerTest method shouldSkipStartFreeipaInstanceWhenStatusAvaialbleOrStartInProgress.
@ParameterizedTest
@EnumSource(value = DetailedStackStatus.class, names = { "PROVISIONED", "START_IN_PROGRESS" })
public void shouldSkipStartFreeipaInstanceWhenStatusAvaialbleOrStartInProgress(DetailedStackStatus detailedStackStatus) {
String envCrn = "someCrnValue";
EnvironmentDto environmentDto = createEnvironmentDto();
environmentDto.setResourceCrn(envCrn);
Event<EnvironmentStartDto> environmentDtoEvent = Event.wrap(mockEnvironmentDto);
when(mockDescribeFreeIpaResponse.getAvailabilityStatus()).thenReturn(detailedStackStatus.getAvailabilityStatus());
when(mockDescribeFreeIpaResponse.getStatus()).thenReturn(detailedStackStatus.getStatus());
when(mockFreeIpaService.describe(envCrn)).thenReturn(Optional.of(mockDescribeFreeIpaResponse));
underTest.accept(environmentDtoEvent);
verify(mockFreeIpaPollerService, never()).stopAttachedFreeipaInstances(environmentDto.getId(), envCrn);
verifyEnvStartEvent(environmentDtoEvent);
}
use of com.sequenceiq.environment.environment.dto.EnvironmentStartDto in project cloudbreak by hortonworks.
the class EnvStartActions method synchronizeUsers.
@Bean(name = "SYNCHRONIZE_USERS_STATE")
public Action<?, ?> synchronizeUsers() {
return new AbstractEnvStartAction<>(EnvStartEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.START_SYNCHRONIZE_USERS_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_SYNCHRONIZE_USERS_STARTED;
EnvStartState envStartState = EnvStartState.SYNCHRONIZE_USERS_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStartState);
EnvironmentStartDto environmentStartDto = EnvironmentStartDto.builder().withDataHubStart(payload.getDataHubStartAction()).withEnvironmentDto(envDto).withId(envDto.getId()).build();
sendEvent(context, EnvStartHandlerSelectors.SYNCHRONIZE_USERS_HANDLER_EVENT.selector(), environmentStartDto);
}
};
}
Aggregations