use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaInstanceUtil method getInstanceIds.
public List<String> getInstanceIds(FreeIpaTestDto freeIpaTestDto, FreeIpaClient freeIpaClient, String hostGroupName) {
DescribeFreeIpaResponse describeFreeIpaResponse = freeIpaClient.getDefaultClient().getFreeIpaV1Endpoint().describe(freeIpaTestDto.getRequest().getEnvironmentCrn());
List<InstanceGroupResponse> instanceGroupResponses = describeFreeIpaResponse.getInstanceGroups();
InstanceGroupResponse instanceGroupResponse = instanceGroupResponses.stream().filter(instanceGroup -> instanceGroup.getName().equals(hostGroupName)).findFirst().orElse(null);
return Objects.requireNonNull(instanceGroupResponse).getMetaData().stream().map(InstanceMetaDataResponse::getInstanceId).collect(Collectors.toList());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method shouldAttachFreeIpaInCaseOfChildEnvironment.
@Test
public void shouldAttachFreeIpaInCaseOfChildEnvironment() throws Exception {
DescribeFreeIpaResponse describeFreeIpaResponse = mock(DescribeFreeIpaResponse.class);
EnvironmentDto environmentDto = aYarnEnvironmentDtoWithParentEnvironment();
Environment environment = anEnvironmentWithParent();
ArgumentCaptor<AddDnsZoneForSubnetsRequest> addDnsZoneForSubnetsRequestArgumentCaptor = ArgumentCaptor.forClass(AddDnsZoneForSubnetsRequest.class);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
when(freeIpaService.describe(PARENT_ENVIRONMENT_CRN)).thenReturn(Optional.of(describeFreeIpaResponse));
victim.accept(new Event<>(environmentDto));
ArgumentCaptor<AttachChildEnvironmentRequest> attachChildEnvironmentRequestArgumentCaptor = ArgumentCaptor.forClass(AttachChildEnvironmentRequest.class);
verify(dnsV1Endpoint).addDnsZoneForSubnets(addDnsZoneForSubnetsRequestArgumentCaptor.capture());
verify(freeIpaService).attachChildEnvironment(attachChildEnvironmentRequestArgumentCaptor.capture());
verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Headers.class));
assertEquals(PARENT_ENVIRONMENT_CRN, addDnsZoneForSubnetsRequestArgumentCaptor.getValue().getEnvironmentCrn());
assertEquals(Collections.singletonList(YARN_NETWORK_CIDR), addDnsZoneForSubnetsRequestArgumentCaptor.getValue().getSubnets());
assertEquals(ENVIRONMENT_CRN, attachChildEnvironmentRequestArgumentCaptor.getValue().getChildEnvironmentCrn());
assertEquals(PARENT_ENVIRONMENT_CRN, attachChildEnvironmentRequestArgumentCaptor.getValue().getParentEnvironmentCrn());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaCreationRetrievalTaskTest method testCheckStatusWithFailedState.
@Test
void testCheckStatusWithFailedState() {
FreeIpaPollerObject freeIpaPollerObject = new FreeIpaPollerObject(ENV_ID, ENV_CRN);
DescribeFreeIpaResponse freeIpa = new DescribeFreeIpaResponse();
freeIpa.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
freeIpa.setStatus(DELETE_IN_PROGRESS);
freeIpa.setName(FREE_IPA_NAME);
freeIpa.setCrn(FREE_IPA_CRN);
when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeIpa));
assertThrows(FreeIpaOperationFailedException.class, () -> underTest.checkStatus(freeIpaPollerObject));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class FreeIpaCreationRetrievalTaskTest method testCheckStatusWithDeleteInProgressState.
@Test
void testCheckStatusWithDeleteInProgressState() {
FreeIpaPollerObject freeIpaPollerObject = new FreeIpaPollerObject(ENV_ID, ENV_CRN);
DescribeFreeIpaResponse freeIpa = new DescribeFreeIpaResponse();
freeIpa.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
freeIpa.setStatus(DELETE_IN_PROGRESS);
freeIpa.setName(FREE_IPA_NAME);
freeIpa.setCrn(FREE_IPA_CRN);
when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeIpa));
assertThrows(FreeIpaOperationFailedException.class, () -> underTest.checkStatus(freeIpaPollerObject));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.
the class UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaAcceptedStatuses.
@ParameterizedTest
@EnumSource(value = Status.class, names = { "AVAILABLE", "UPGRADE_CCM_FAILED" }, mode = EnumSource.Mode.INCLUDE)
void testFreeIpaAcceptedStatuses(Status status) {
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setStatus(status);
freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
Optional<DescribeFreeIpaResponse> freeipaOpt = Optional.of(freeipa);
when(freeIpaService.describe(any())).thenReturn(freeipaOpt);
underTest.accept(mockEnvironmentDtoEvent);
verify(freeIpaPollerService).waitForCcmUpgrade(TEST_ENV_ID, TEST_ENV_CRN);
UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_TUNNEL_UPDATE_EVENT");
}
Aggregations