use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class FreeIpaClientFactoryTest method setup.
@BeforeAll
static void setup() {
InstanceMetaData metaData = new InstanceMetaData();
METADATAS.add(metaData);
metaData.setPrivateIp("127.0.0.1");
metaData.setDiscoveryFQDN(FREEIPP_FQDN);
metaData.setInstanceStatus(InstanceStatus.CREATED);
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class ValidateInstancesHealthHandlerTest method testExceptionDuringHealthCheck.
@Test
public void testExceptionDuringHealthCheck() throws FreeIpaClientException {
Stack stack = new Stack();
stack.setId(1L);
when(stackService.getStackById(1L)).thenReturn(stack);
List<String> instanceIds = List.of("im1", "im2");
InstanceMetaData im1 = new InstanceMetaData();
im1.setInstanceId("im1");
im1.setDiscoveryFQDN("im1Fqdn");
InstanceMetaData im2 = new InstanceMetaData();
im2.setInstanceId("im2");
im2.setDiscoveryFQDN("im2Fqdn");
when(instanceMetaDataService.getNotTerminatedByInstanceIds(1L, instanceIds)).thenReturn(Set.of(im1, im2));
when(healthService.getInstanceHealthDetails(stack, im1)).thenReturn(createHealthyNodeDetail(im1));
when(healthService.getInstanceHealthDetails(stack, im2)).thenThrow(new FreeIpaClientException("nono"));
ValidateInstancesHealthEvent validateInstancesHealthEvent = new ValidateInstancesHealthEvent(1L, instanceIds);
UpscaleFailureEvent result = (UpscaleFailureEvent) underTest.doAccept(new HandlerEvent<>(new Event<>(validateInstancesHealthEvent)));
assertEquals(1L, result.getResourceId());
assertEquals(PHASE, result.getFailedPhase());
assertTrue(result.getSuccess().contains("im1"));
assertEquals(1, result.getFailureDetails().size());
assertEquals("nono", result.getFailureDetails().get("im2"));
assertEquals("Unhealthy instances found: [im2]", result.getException().getMessage());
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class OneFreeIpaReachableAttemptTest method setup.
@BeforeEach
public void setup() {
stack = new Stack();
stack.setId(ID);
InMemoryStateStore.putStack(ID, PollGroup.POLLABLE);
InstanceMetaData instance1 = new InstanceMetaData();
InstanceMetaData instance2 = new InstanceMetaData();
instanceSet = Set.of(instance1, instance2);
oneFreeIpaReachableAttemptUnderTest = new OneFreeIpaReachableAttempt(freeIpaInstanceHealthDetailsService, stack, instanceSet);
response = new RPCResponse<>();
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class TerminationServiceTest method testRequestDeletionForInstances.
@Test
void testRequestDeletionForInstances() {
Stack stack = mock(Stack.class);
InstanceMetaData im1 = mock(InstanceMetaData.class);
InstanceMetaData im2 = mock(InstanceMetaData.class);
InstanceMetaData im3 = mock(InstanceMetaData.class);
InstanceMetaData im4 = mock(InstanceMetaData.class);
when(stack.getAllInstanceMetaDataList()).thenReturn(List.of(im1, im2, im3, im4));
when(im1.isTerminated()).thenReturn(true);
when(im2.isTerminated()).thenReturn(false);
when(im3.isTerminated()).thenReturn(false);
when(im4.isTerminated()).thenReturn(false);
when(im2.getInstanceId()).thenReturn("i-2");
when(im3.getInstanceId()).thenReturn("i-3");
when(im4.getInstanceId()).thenReturn("i-4");
underTest.requestDeletionForInstances(stack, List.of("i-3"));
verify(im1, never()).setInstanceStatus(any());
verify(im2, never()).setInstanceStatus(any());
verify(im3).setInstanceStatus(eq(InstanceStatus.DELETE_REQUESTED));
verify(im4, never()).setInstanceStatus(any());
verify(instanceMetaDataService).saveAll(any());
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class TerminationServiceTest method testFinalizeTerminationFroInstancesWithoutInstanceIds.
@Test
void testFinalizeTerminationFroInstancesWithoutInstanceIds() {
Stack stack = mock(Stack.class);
InstanceMetaData im1 = mock(InstanceMetaData.class);
InstanceMetaData im2 = mock(InstanceMetaData.class);
InstanceMetaData im3 = mock(InstanceMetaData.class);
InstanceMetaData im4 = mock(InstanceMetaData.class);
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
when(stack.getAllInstanceMetaDataList()).thenReturn(List.of(im1, im2, im3, im4));
when(im1.isTerminated()).thenReturn(true);
when(im2.isTerminated()).thenReturn(false);
when(im3.isTerminated()).thenReturn(false);
when(im4.isTerminated()).thenReturn(false);
when(im2.getInstanceId()).thenReturn(null);
when(im3.getInstanceId()).thenReturn("i-3");
when(im4.getInstanceId()).thenReturn(null);
when(clock.getCurrentTimeMillis()).thenReturn(1L);
underTest.finalizeTerminationForInstancesWithoutInstanceIds(1L);
verify(im2).setTerminationDate(any());
verify(im2).setInstanceStatus(eq(InstanceStatus.TERMINATED));
verify(im4).setTerminationDate(any());
verify(im4).setInstanceStatus(eq(InstanceStatus.TERMINATED));
verify(instanceMetaDataService).saveAll(any());
}
Aggregations