Search in sources :

Example 1 with ReactorNotifier

use of com.sequenceiq.cloudbreak.core.flow2.service.ReactorNotifier in project cloudbreak by hortonworks.

the class ReactorFlowManagerTest method testTriggerUpscaleWithoutClusterEvent.

@Test
public void testTriggerUpscaleWithoutClusterEvent() {
    InstanceGroupAdjustmentV4Request instanceGroupAdjustment = new InstanceGroupAdjustmentV4Request();
    instanceGroupAdjustment.setInstanceGroup("ig");
    instanceGroupAdjustment.setScalingAdjustment(3);
    when(stackService.getPlatformVariantByStackId(STACK_ID)).thenReturn(cloudPlatformVariant);
    when(cloudPlatformVariant.getVariant()).thenReturn(Variant.variant("AWS"));
    underTest.triggerStackUpscale(stack.getId(), instanceGroupAdjustment, false);
    ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
    verify(reactorNotifier, times(1)).notify(eq(stack.getId()), eq(FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT), captor.capture());
    StackAndClusterUpscaleTriggerEvent event = (StackAndClusterUpscaleTriggerEvent) captor.getValue();
    assertEquals(FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT, event.selector());
    assertEquals(stack.getId(), event.getResourceId());
    assertEquals(instanceGroupAdjustment.getInstanceGroup(), event.getHostGroupsWithAdjustment().keySet().stream().findFirst().get());
    assertEquals(instanceGroupAdjustment.getScalingAdjustment(), event.getHostGroupsWithAdjustment().values().stream().findFirst().get());
    assertEquals(ScalingType.UPSCALE_ONLY_STACK, event.getScalingType());
}
Also used : StackAndClusterUpscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.common.event.Acceptable) InstanceGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request) Test(org.junit.Test)

Example 2 with ReactorNotifier

use of com.sequenceiq.cloudbreak.core.flow2.service.ReactorNotifier in project cloudbreak by hortonworks.

the class ReactorFlowManagerTest method testTriggerDatabaseBackupFlowchain.

@Test
public void testTriggerDatabaseBackupFlowchain() {
    long stackId = 1L;
    String backupId = UUID.randomUUID().toString();
    underTest.triggerDatalakeDatabaseBackup(stackId, BACKUP_LOCATION, backupId, true);
    ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
    verify(reactorNotifier).notify(eq(stackId), eq(FlowChainTriggers.DATALAKE_DATABASE_BACKUP_CHAIN_TRIGGER_EVENT), captor.capture());
    DatabaseBackupTriggerEvent event = (DatabaseBackupTriggerEvent) captor.getValue();
    assertEquals(stack.getId(), event.getResourceId());
    assertEquals(backupId, event.getBackupId());
    assertEquals(BACKUP_LOCATION, event.getBackupLocation());
    assertEquals(FlowChainTriggers.DATALAKE_DATABASE_BACKUP_CHAIN_TRIGGER_EVENT, event.selector());
}
Also used : Acceptable(com.sequenceiq.cloudbreak.common.event.Acceptable) DatabaseBackupTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.DatabaseBackupTriggerEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with ReactorNotifier

use of com.sequenceiq.cloudbreak.core.flow2.service.ReactorNotifier in project cloudbreak by hortonworks.

the class ReactorFlowManagerTest method testTriggerMaintenanceModeValidationFlow.

@Test
public void testTriggerMaintenanceModeValidationFlow() {
    long stackId = 1L;
    underTest.triggerMaintenanceModeValidationFlow(stackId);
    ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
    verify(reactorNotifier).notify(eq(stackId), eq(FlowChainTriggers.CLUSTER_MAINTENANCE_MODE_VALIDATION_TRIGGER_EVENT), captor.capture());
    MaintenanceModeValidationTriggerEvent event = (MaintenanceModeValidationTriggerEvent) captor.getValue();
    assertEquals(stack.getId(), event.getResourceId());
    assertEquals(FlowChainTriggers.CLUSTER_MAINTENANCE_MODE_VALIDATION_TRIGGER_EVENT, event.selector());
}
Also used : MaintenanceModeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.MaintenanceModeValidationTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.common.event.Acceptable) Test(org.junit.Test)

Example 4 with ReactorNotifier

use of com.sequenceiq.cloudbreak.core.flow2.service.ReactorNotifier in project cloudbreak by hortonworks.

the class ReactorFlowManagerTest method testTriggerStackImageUpdate.

@Test
public void testTriggerStackImageUpdate() {
    long stackId = 1L;
    String imageID = "imageID";
    String imageCatalogName = "imageCatalogName";
    String imageCatalogUrl = "imageCatalogUrl";
    underTest.triggerStackImageUpdate(new ImageChangeDto(stackId, imageID, imageCatalogName, imageCatalogUrl));
    ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
    verify(reactorNotifier).notify(eq(stackId), eq(FlowChainTriggers.STACK_IMAGE_UPDATE_TRIGGER_EVENT), captor.capture());
    StackImageUpdateTriggerEvent event = (StackImageUpdateTriggerEvent) captor.getValue();
    assertEquals(FlowChainTriggers.STACK_IMAGE_UPDATE_TRIGGER_EVENT, event.selector());
    assertEquals(stack.getId(), event.getResourceId());
    assertEquals(imageCatalogName, event.getImageCatalogName());
    assertEquals(imageID, event.getNewImageId());
    assertEquals(imageCatalogUrl, event.getImageCatalogUrl());
}
Also used : ImageChangeDto(com.sequenceiq.cloudbreak.service.image.ImageChangeDto) Acceptable(com.sequenceiq.cloudbreak.common.event.Acceptable) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StackImageUpdateTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent) Test(org.junit.Test)

Example 5 with ReactorNotifier

use of com.sequenceiq.cloudbreak.core.flow2.service.ReactorNotifier in project cloudbreak by hortonworks.

the class ReactorFlowManagerTest method testTriggerUpscaleWithClusterEvent.

@Test
public void testTriggerUpscaleWithClusterEvent() {
    InstanceGroupAdjustmentV4Request instanceGroupAdjustment = new InstanceGroupAdjustmentV4Request();
    instanceGroupAdjustment.setInstanceGroup("ig");
    instanceGroupAdjustment.setScalingAdjustment(3);
    when(stackService.getPlatformVariantByStackId(STACK_ID)).thenReturn(cloudPlatformVariant);
    when(cloudPlatformVariant.getVariant()).thenReturn(Variant.variant("AWS"));
    underTest.triggerStackUpscale(stack.getId(), instanceGroupAdjustment, true);
    ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
    verify(reactorNotifier, times(1)).notify(eq(stack.getId()), eq(FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT), captor.capture());
    StackAndClusterUpscaleTriggerEvent event = (StackAndClusterUpscaleTriggerEvent) captor.getValue();
    assertEquals(FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT, event.selector());
    assertEquals(stack.getId(), event.getResourceId());
    assertEquals(instanceGroupAdjustment.getInstanceGroup(), event.getHostGroupsWithAdjustment().keySet().stream().findFirst().get());
    assertEquals(instanceGroupAdjustment.getScalingAdjustment(), event.getHostGroupsWithAdjustment().values().stream().findFirst().get());
    assertEquals(ScalingType.UPSCALE_TOGETHER, event.getScalingType());
}
Also used : StackAndClusterUpscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.common.event.Acceptable) InstanceGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request) Test(org.junit.Test)

Aggregations

Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)5 Test (org.junit.Test)5 InstanceGroupAdjustmentV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request)2 StackAndClusterUpscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 DatabaseBackupTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.DatabaseBackupTriggerEvent)1 MaintenanceModeValidationTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.MaintenanceModeValidationTriggerEvent)1 StackImageUpdateTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)1 ImageChangeDto (com.sequenceiq.cloudbreak.service.image.ImageChangeDto)1