use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method testRepairInstancesWithNoneSpecified.
@Test
void testRepairInstancesWithNoneSpecified() {
Stack stack = createStack(Status.UNHEALTHY, List.of(InstanceStatus.CREATED, InstanceStatus.UNREACHABLE));
List<String> instanceIds = List.of("i-2");
OperationStatus operationStatus = new OperationStatus();
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(stack);
when(healthDetailsService.getHealthDetails(ENVIRONMENT_ID1, ACCOUNT_ID)).thenReturn(createHealthDetails(InstanceStatus.CREATED, InstanceStatus.UNREACHABLE));
when(operationService.startOperation(any(), any(), any(), any())).thenReturn(createOperation());
when(operationToOperationStatusConverter.convert(any())).thenReturn(operationStatus);
when(entitlementService.freeIpaHaRepairEnabled(any())).thenReturn(Boolean.TRUE);
when(stackUpdater.updateStackStatus(anyLong(), any(), any())).thenReturn(stack);
RepairInstancesRequest request = new RepairInstancesRequest();
request.setEnvironmentCrn(ENVIRONMENT_ID1);
assertEquals(operationStatus, underTest.repairInstances(ACCOUNT_ID, request));
ArgumentCaptor acAcceptable = ArgumentCaptor.forClass(Acceptable.class);
verify(flowManager).notify(eq("REPAIR_TRIGGER_EVENT"), (Acceptable) acAcceptable.capture());
assertTrue(acAcceptable.getValue() instanceof RepairEvent);
RepairEvent repairEvent = (RepairEvent) acAcceptable.getValue();
assertEquals(instanceIds, repairEvent.getRepairInstanceIds());
verify(stackUpdater).updateStackStatus(eq(STACK_ID), eq(DetailedStackStatus.REPAIR_REQUESTED), any());
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class ChildEnvironmentServiceTest method findMultipleParentStackByChildEnvironmentCrnWithListsEvenIfTerminatedWithLIst.
@Test
void findMultipleParentStackByChildEnvironmentCrnWithListsEvenIfTerminatedWithLIst() {
List<Stack> stackList = List.of(new Stack());
when(repository.findMultipleParentByEnvironmentCrnEvenIfTerminatedWithList(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stackList);
List<Stack> result = underTest.findMultipleParentStackByChildEnvironmentCrnEvenIfTerminatedWithList(ENVIRONMENT_CRN, ACCOUNT_ID);
assertEquals(stackList, result);
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class ChildEnvironmentServiceTest method findParentStackByChildEnvironmentCrnAndCrnWithListsEvenIfTerminated.
@Test
void findParentStackByChildEnvironmentCrnAndCrnWithListsEvenIfTerminated() {
Optional<Stack> stack = Optional.of(new Stack());
when(repository.findParentByEnvironmentCrnAndCrnWthListsEvenIfTerminated(ENVIRONMENT_CRN, ACCOUNT_ID, FREEIPA_CRN)).thenReturn(stack);
Optional<Stack> result = underTest.findParentStackByChildEnvironmentCrnAndCrnWithListsEvenIfTerminated(ENVIRONMENT_CRN, ACCOUNT_ID, FREEIPA_CRN);
assertEquals(stack, result);
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testGetPathWithStackWithServiceNameRegistered.
@Test
public void testGetPathWithStackWithServiceNameRegistered() {
when(clusterProxyConfiguration.getClusterProxyBasePath()).thenReturn("basePath");
Stack stack = getAStack();
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("ipadom");
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
ReadConfigResponse readConfigResponse = new ReadConfigResponse();
ReadConfigService service = new ReadConfigService();
service.setName("registered");
readConfigResponse.setServices(List.of(service));
when(clusterProxyRegistrationClient.readConfig(STACK_RESOURCE_CRN)).thenReturn(readConfigResponse);
String result = underTest.getProxyPath(stack, Optional.of("registered"));
assertEquals("basePath/proxy/resourceCrn/registered", result);
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method getAStack.
private Stack getAStack() {
Stack stack = new Stack();
stack.setAccountId(TEST_ACCOUNT_ID);
stack.setResourceCrn(STACK_RESOURCE_CRN);
SecurityConfig securityConfig = new SecurityConfig();
stack.setSecurityConfig(securityConfig);
return stack;
}
Aggregations