use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class ClusterCommonServiceTest method testRotateAutoTlsCertificatesWithNodeFailure.
@Test
public void testRotateAutoTlsCertificatesWithNodeFailure() {
NameOrCrn cluster = NameOrCrn.ofName("cluster");
Stack stack = new Stack();
stack.setName("cluster");
stack.setStackStatus(new StackStatus(stack, NODE_FAILURE));
when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request));
assertEquals("Stack 'cluster' is currently in 'NODE_FAILURE' state. Certificates rotation can only be made when the underlying stack is 'AVAILABLE'.", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackOperationsTest method testChangeImageCatalogThrowsExceptionWhenFlowInProgress.
@Test
public void testChangeImageCatalogThrowsExceptionWhenFlowInProgress() {
NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
when(stackService.getByNameOrCrnInWorkspace(nameOrCrn, stack.getWorkspace().getId())).thenReturn(stack);
when(flowLogService.isOtherFlowRunning(stack.getId())).thenReturn(true);
assertThrows(CloudbreakServiceException.class, () -> underTest.changeImageCatalog(nameOrCrn, stack.getWorkspace().getId(), IMAGE_CATALOG));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackOperationsTest method testGenerateImageCatalog.
@Test
public void testGenerateImageCatalog() {
NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
CloudbreakImageCatalogV3 imageCatalog = mock(CloudbreakImageCatalogV3.class);
when(stackService.getByNameOrCrnInWorkspace(nameOrCrn, stack.getWorkspace().getId())).thenReturn(stack);
when(generateImageCatalogService.generateImageCatalogForStack(stack)).thenReturn(imageCatalog);
CloudbreakImageCatalogV3 actual = underTest.generateImageCatalog(nameOrCrn, stack.getWorkspace().getId());
assertEquals(imageCatalog, actual);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackOperationsTest method testGetWhenNameOrCrnCrnFilledThenProperGetCalled.
@Test
public void testGetWhenNameOrCrnCrnFilledThenProperGetCalled() {
StackV4Response expected = stackResponse();
NameOrCrn nameOrCrn = NameOrCrn.ofCrn(stack.getResourceCrn());
when(stackCommonService.findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE)).thenReturn(expected);
StackV4Response result = underTest.get(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
assertEquals(expected, result);
verify(stackCommonService, times(1)).findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class DistroXUpgradeV1Controller method upgradeCluster.
private DistroXUpgradeV1Response upgradeCluster(String clusterNameOrCrn, DistroXUpgradeV1Request distroxUpgradeRequest, NameOrCrn nameOrCrn, InternalUpgradeSettings internalUpgradeSettings) {
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
UpgradeV4Request request = upgradeConverter.convert(distroxUpgradeRequest, internalUpgradeSettings);
Long workspaceId = restRequestThreadLocalService.getRequestedWorkspaceId();
if (request.isDryRun() || request.isShowAvailableImagesSet()) {
LOGGER.info("Checking for upgrade for cluster [{}] with request: {}", clusterNameOrCrn, request);
UpgradeV4Response upgradeV4Response = upgradeAvailabilityService.checkForUpgrade(nameOrCrn, workspaceId, request, userCrn);
return upgradeConverter.convert(upgradeV4Response);
} else {
LOGGER.info("Triggering upgrade for cluster [{}] with request: {}", clusterNameOrCrn, request);
UpgradeV4Response upgradeV4Response = upgradeService.triggerUpgrade(nameOrCrn, workspaceId, userCrn, request);
return upgradeConverter.convert(upgradeV4Response);
}
}
Aggregations