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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations