use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorNotifierTest method testAccepted.
@Test
public void testAccepted() throws InterruptedException {
Stack stack = TestUtil.stack();
stack.setCluster(TestUtil.cluster());
stack.setStackStatus(new StackStatus(stack, AVAILABLE));
when(stackService.getByIdWithTransaction(1L)).thenReturn(stack);
Acceptable data = mock(Acceptable.class);
Promise<AcceptResult> accepted = (Promise<AcceptResult>) mock(Promise.class);
when(data.accepted()).thenReturn(accepted);
when(data.getResourceId()).thenReturn(1L);
Event<Acceptable> event = new Event<>(data);
when(eventFactory.createEventWithErrHandler(anyMap(), any(Acceptable.class))).thenReturn(event);
FlowAcceptResult acceptResult = FlowAcceptResult.runningInFlow("flowid");
when(accepted.await(10L, TimeUnit.SECONDS)).thenReturn(acceptResult);
underTest.notify(1L, "RANDOM", data, stackService::getByIdWithTransaction);
verify(reactorReporter, times(1)).logInfoReport();
verify(reactor, times(1)).notify(eq("RANDOM"), eq(event));
verify(accepted, times(1)).await(10L, TimeUnit.SECONDS);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class FlowPayloadConstructorTest method constructorAccessible.
@Test
void constructorAccessible() {
Reflections reflections = new Reflections("com.sequenceiq", new SubTypesScanner(true));
Set<Class<? extends Acceptable>> eventClasses = reflections.getSubTypesOf(Acceptable.class);
eventClasses.stream().filter(c -> !c.isInterface() && !isAbstract(c) && !c.isAnonymousClass() && !c.isLocalClass() && !c.isMemberClass()).filter(c -> !c.getName().endsWith("Test")).forEach(this::checkForConstructor);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class FlowPayloadConstructorTest method constructorAccessible.
@Test
void constructorAccessible() {
Reflections reflections = new Reflections("com.sequenceiq", new SubTypesScanner(true));
Set<Class<? extends Acceptable>> eventClasses = reflections.getSubTypesOf(Acceptable.class);
eventClasses.stream().filter(c -> !c.isInterface() && !isAbstract(c) && !c.isAnonymousClass() && !c.isLocalClass() && !c.isMemberClass()).filter(c -> !c.getName().endsWith("Test")).forEach(this::checkForConstructor);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class FlowPayloadConstructorTest method constructorAccessible.
@Test
void constructorAccessible() {
Reflections reflections = new Reflections("com.sequenceiq", new SubTypesScanner(true));
Set<Class<? extends Acceptable>> eventClasses = reflections.getSubTypesOf(Acceptable.class);
eventClasses.stream().filter(c -> !c.isInterface() && !isAbstract(c) && !c.isAnonymousClass() && !c.isLocalClass() && !c.isMemberClass()).filter(c -> !c.getName().endsWith("Test")).forEach(this::checkForConstructor);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class UpgradeServiceTest method testImageSettingsCreatedIfMissingAndUpgradeTriggered.
@Test
public void testImageSettingsCreatedIfMissingAndUpgradeTriggered() {
FreeIpaUpgradeRequest request = new FreeIpaUpgradeRequest();
request.setEnvironmentCrn(ENVIRONMENT_CRN);
Stack stack = mock(Stack.class);
when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
Set<InstanceMetaData> allInstances = createValidImSet();
when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
ImageInfoResponse selectedImage = new ImageInfoResponse();
when(imageService.selectImage(eq(stack), any(ImageSettingsRequest.class))).thenReturn(selectedImage);
ImageInfoResponse currentImage = mockCurrentImage(stack);
Operation operation = mockOperation(OperationState.RUNNING);
ArgumentCaptor<Acceptable> eventCaptor = ArgumentCaptor.forClass(Acceptable.class);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW_CHAIN, "flowId");
when(flowManager.notify(eq(FlowChainTriggers.UPGRADE_TRIGGER_EVENT), eventCaptor.capture())).thenReturn(flowIdentifier);
when(instanceMetaDataService.getPrimaryGwInstance(allInstances)).thenReturn(createPgwIm());
when(instanceMetaDataService.getNonPrimaryGwInstances(allInstances)).thenReturn(createGwImSet());
FreeIpaUpgradeResponse response = underTest.upgradeFreeIpa(ACCOUNT_ID, request);
assertEquals(flowIdentifier, response.getFlowIdentifier());
assertEquals(operation.getOperationId(), response.getOperationId());
assertEquals(currentImage, response.getOriginalImage());
assertEquals(selectedImage, response.getTargetImage());
UpgradeEvent upgradeEvent = (UpgradeEvent) eventCaptor.getValue();
assertNotNull(upgradeEvent.getImageSettingsRequest());
assertEquals(operation.getOperationId(), upgradeEvent.getOperationId());
assertEquals("pgw", upgradeEvent.getPrimareGwInstanceId());
assertEquals(2, upgradeEvent.getInstanceIds().size());
assertTrue(Set.of("im2", "im3").containsAll(upgradeEvent.getInstanceIds()));
verify(validationService).validateEntitlement(ACCOUNT_ID);
verify(validationService).validateStackForUpgrade(allInstances, stack);
verify(validationService).validateSelectedImageDifferentFromCurrent(currentImage, selectedImage);
}
Aggregations