Search in sources :

Example 6 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class UpgradePreconditionServiceTest method testCheckForRunningAttachedClustersShouldNotReturnErrorMessageWhenThereAreNoClustersInNotProperState.

@Test
public void testCheckForRunningAttachedClustersShouldNotReturnErrorMessageWhenThereAreNoClustersInNotProperState() {
    StackViewV4Response dataHubStack1 = createStackResponse(Status.STOPPED, "stack-1", "stack-crn-1");
    dataHubStack1.setCluster(createClusterResponse(Status.STOPPED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack2 = createStackResponse(Status.DELETE_COMPLETED, "stack-2", "stack-crn-2");
    dataHubStack2.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack3 = createStackResponse(Status.STOPPED, "stack-3", "stack-crn-3");
    dataHubStack3.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses(Set.of(dataHubStack1, dataHubStack2, dataHubStack3));
    String actualRunning = underTest.checkForRunningAttachedClusters(stackViewV4Responses, new Stack());
    String actualNonUpgradeable = underTest.checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
    assertEquals("", actualRunning);
    assertEquals("", actualNonUpgradeable);
    verifyNoInteractions(spotInstanceUsageCondition);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 7 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class UpgradePreconditionServiceTest method testCheckForRunningAttachedClustersShouldReturnErrorMessageWhenThereAreClustersInNotProperState.

@Test
public void testCheckForRunningAttachedClustersShouldReturnErrorMessageWhenThereAreClustersInNotProperState() {
    StackViewV4Response dataHubStack1 = createStackResponse(Status.AVAILABLE, "stack-1", "stack-crn-1");
    dataHubStack1.setCluster(createClusterResponse(Status.AVAILABLE, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack2 = createStackResponse(Status.DELETE_COMPLETED, "stack-2", "stack-crn-2");
    dataHubStack2.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Response dataHubStack3 = createStackResponse(Status.STOPPED, "stack-3", "stack-crn-2");
    dataHubStack3.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses(Set.of(dataHubStack1, dataHubStack2, dataHubStack3));
    Stack stack = new Stack();
    String actualRunning = underTest.checkForRunningAttachedClusters(stackViewV4Responses, stack);
    String actualNonUpgradeable = underTest.checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
    assertEquals("There are attached Data Hub clusters in incorrect state: stack-1. Please stop those to be able to perform the upgrade.", actualRunning);
    assertEquals("", actualNonUpgradeable);
    verify(spotInstanceUsageCondition).isStackRunsOnSpotInstances(stack);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 8 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class UpgradeServiceTest method upgradeAllowedWhenConnectedDataHubStackAndClusterStoppedOrDeleted.

@Test
public void upgradeAllowedWhenConnectedDataHubStackAndClusterStoppedOrDeleted() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    Stack stack = getStack();
    Image image = getImage("id-1");
    setUpMocks(stack, image, true, "id-1", "id-2");
    Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.success(new HashMap<>());
    when(clusterRepairService.repairWithDryRun(1L)).thenReturn(repairStartResult);
    StackViewV4Response datahubStack1 = new StackViewV4Response();
    datahubStack1.setStatus(Status.STOPPED);
    ClusterViewV4Response datahubCluster1 = new ClusterViewV4Response();
    datahubCluster1.setStatus(Status.STOPPED);
    datahubStack1.setCluster(datahubCluster1);
    StackViewV4Response datahubStack2 = new StackViewV4Response();
    datahubStack2.setStatus(Status.DELETE_COMPLETED);
    ClusterViewV4Response datahubCluster2 = new ClusterViewV4Response();
    datahubCluster2.setStatus(Status.DELETE_COMPLETED);
    datahubStack2.setCluster(datahubCluster2);
    StackViewV4Response datahubStack3 = new StackViewV4Response();
    datahubStack3.setStatus(Status.STOPPED);
    when(distroXV1Endpoint.list(any(), anyString())).thenReturn(new StackViewV4Responses(Set.of(datahubStack1, datahubStack2, datahubStack3)));
    when(stackService.getByNameOrCrnInWorkspace(eq(ofName), eq(WORKSPACE_ID))).thenReturn(stack);
    UpgradeOptionV4Response result = underTest.getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, ofName, user);
    verify(clusterRepairService).repairWithDryRun(eq(stack.getId()));
    verify(distroXV1Endpoint).list(eq(null), eq("env-crn"));
    verify(componentConfigProviderService).getImage(1L);
    verify(imageService).determineImageFromCatalog(eq(WORKSPACE_ID), captor.capture(), eq("aws"), eq("AWS"), eq(stack.getCluster().getBlueprint()), eq(false), eq(false), eq(user), any());
    assertThat(result.getUpgrade().getImageName()).isEqualTo("id-2");
    assertThat(result.getReason()).isEqualTo(null);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) UpgradeOptionV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response) ClusterViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Map(java.util.Map) HashMap(java.util.HashMap) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 9 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class UpgradeServiceTest method setupAttachedClusterMocks.

public void setupAttachedClusterMocks() {
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses();
    stackViewV4Responses.setResponses(List.of());
    when(distroXV1Endpoint.list(eq(null), anyString())).thenReturn(stackViewV4Responses);
}
Also used : StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)

Example 10 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class DatahubPollerServiceTest method testStopAttachedDatahubWhenNoAttachedDatahub.

@Test
void testStopAttachedDatahubWhenNoAttachedDatahub() {
    when(datahubService.list(ENV_CRN)).thenReturn(new StackViewV4Responses(Collections.emptySet()));
    underTest.stopAttachedDatahubClusters(ENV_ID, ENV_CRN);
    verify(datahubService, times(0)).putStopByCrns(eq(ENV_CRN), anyList());
}
Also used : StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Test(org.junit.jupiter.api.Test)

Aggregations

StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)33 Test (org.junit.jupiter.api.Test)19 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)18 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)14 Test (org.junit.Test)8 PollingConfig (com.sequenceiq.environment.util.PollingConfig)4 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)3 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)3 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)3 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 StackInstanceCount (com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 Environment (com.sequenceiq.environment.environment.domain.Environment)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)2 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)2