Search in sources :

Example 1 with SdxRepairRequest

use of com.sequenceiq.sdx.api.model.SdxRepairRequest in project cloudbreak by hortonworks.

the class SdxRepairSettingsTest method throwsExceptionWhenHostGroupAndNodeIdsAreSpecified.

@Test
void throwsExceptionWhenHostGroupAndNodeIdsAreSpecified() {
    SdxRepairRequest request = new SdxRepairRequest();
    request.setHostGroupName("hg1");
    request.setNodesIds(List.of("node1", "node2"));
    BadRequestException exception = assertThrows(BadRequestException.class, () -> SdxRepairSettings.from(request));
    assertEquals("Please select one host group ('hostGroupName'), multiple host groups ('hostGroupNames'), or nodes ('nodesIds').", exception.getMessage());
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) Test(org.junit.jupiter.api.Test)

Example 2 with SdxRepairRequest

use of com.sequenceiq.sdx.api.model.SdxRepairRequest in project cloudbreak by hortonworks.

the class SdxRepairSettingsTest method setsCorrectNodeIdsWhenNodeIdsAreSpecified.

@Test
void setsCorrectNodeIdsWhenNodeIdsAreSpecified() {
    SdxRepairRequest request = new SdxRepairRequest();
    request.setNodesIds(List.of("node1", "node2"));
    SdxRepairSettings settings = SdxRepairSettings.from(request);
    assertEquals(List.of("node1", "node2"), settings.getNodeIds());
    assertEquals(List.of(), settings.getHostGroupNames());
}
Also used : SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) Test(org.junit.jupiter.api.Test)

Example 3 with SdxRepairRequest

use of com.sequenceiq.sdx.api.model.SdxRepairRequest in project cloudbreak by hortonworks.

the class SdxRepairSettingsTest method setsCorrectHostGroupWhenHostGroupNameSpecified.

@Test
void setsCorrectHostGroupWhenHostGroupNameSpecified() {
    SdxRepairRequest request = new SdxRepairRequest();
    request.setHostGroupName("hostgroup1");
    SdxRepairSettings settings = SdxRepairSettings.from(request);
    assertEquals(List.of("hostgroup1"), settings.getHostGroupNames());
    assertEquals(List.of(), settings.getNodeIds());
}
Also used : SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) Test(org.junit.jupiter.api.Test)

Example 4 with SdxRepairRequest

use of com.sequenceiq.sdx.api.model.SdxRepairRequest in project cloudbreak by hortonworks.

the class SdxRepairServiceTest method triggerHostGroupBasedCloudbreakRepair.

@Test
public void triggerHostGroupBasedCloudbreakRepair() {
    SdxCluster cluster = new SdxCluster();
    cluster.setId(CLUSTER_ID.incrementAndGet());
    cluster.setInitiatorUserCrn(USER_CRN);
    cluster.setClusterName(CLUSTER_NAME);
    cluster.setAccountId("accountid");
    SdxRepairRequest sdxRepairRequest = new SdxRepairRequest();
    sdxRepairRequest.setHostGroupNames(List.of("master"));
    SdxRepairSettings sdxRepairSettings = SdxRepairSettings.from(sdxRepairRequest);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    doNothing().when(cloudbreakFlowService).saveLastCloudbreakFlowChainId(any(), any());
    underTest.startRepairInCb(cluster, sdxRepairSettings);
    verify(stackV4Endpoint).repairClusterInternal(eq(0L), eq(CLUSTER_NAME), captor.capture(), nullable(String.class));
    assertEquals(List.of("master"), captor.getValue().getHostGroups());
    assertNull(captor.getValue().getNodes());
    verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.REPAIR_IN_PROGRESS, "Datalake repair in progress", cluster);
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) SdxRepairSettings(com.sequenceiq.datalake.settings.SdxRepairSettings) Test(org.junit.jupiter.api.Test)

Example 5 with SdxRepairRequest

use of com.sequenceiq.sdx.api.model.SdxRepairRequest in project cloudbreak by hortonworks.

the class SdxRepairServiceTest method triggerNodeIdBasedCloudbreakRepair.

@Test
public void triggerNodeIdBasedCloudbreakRepair() {
    SdxCluster cluster = new SdxCluster();
    cluster.setId(CLUSTER_ID.incrementAndGet());
    cluster.setInitiatorUserCrn(USER_CRN);
    cluster.setClusterName(CLUSTER_NAME);
    cluster.setAccountId("accountid");
    SdxRepairRequest sdxRepairRequest = new SdxRepairRequest();
    sdxRepairRequest.setNodesIds(List.of("node1"));
    SdxRepairSettings sdxRepairSettings = SdxRepairSettings.from(sdxRepairRequest);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    doNothing().when(cloudbreakFlowService).saveLastCloudbreakFlowChainId(any(), any());
    underTest.startRepairInCb(cluster, sdxRepairSettings);
    verify(stackV4Endpoint).repairClusterInternal(eq(0L), eq(CLUSTER_NAME), captor.capture(), nullable(String.class));
    assertEquals(List.of("node1"), captor.getValue().getNodes().getIds());
    assertNull(captor.getValue().getHostGroups());
    verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.REPAIR_IN_PROGRESS, "Datalake repair in progress", cluster);
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) SdxRepairSettings(com.sequenceiq.datalake.settings.SdxRepairSettings) Test(org.junit.jupiter.api.Test)

Aggregations

SdxRepairRequest (com.sequenceiq.sdx.api.model.SdxRepairRequest)9 Test (org.junit.jupiter.api.Test)9 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)4 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 SdxRepairSettings (com.sequenceiq.datalake.settings.SdxRepairSettings)2