use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeImageSelectorTest method testSelectedImageByIdFound.
@Test
public void testSelectedImageByIdFound() {
List<ImageInfoV4Response> candidates = List.of(createImageResponse("A", 1L, "5"), createImageResponse("B", 6L, "3"), createImageResponse("C", 3L, "1"));
UpgradeV4Request request = new UpgradeV4Request();
request.setImageId("C");
ImageInfoV4Response result = underTest.determineImageId(request, candidates);
assertEquals("C", result.getImageId());
assertEquals("1", result.getComponentVersions().getCdp());
assertEquals(3L, result.getCreated());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeImageSelectorTest method testSelectedImageByRuntimeFound.
@Test
public void testSelectedImageByRuntimeFound() {
List<ImageInfoV4Response> candidates = List.of(createImageResponse("A", 1L, "5"), createImageResponse("B", 6L, "3"), createImageResponse("C", 3L, "1"), createImageResponse("D", 8L, "3"));
UpgradeV4Request request = new UpgradeV4Request();
request.setRuntime("3");
ImageInfoV4Response result = underTest.determineImageId(request, candidates);
assertEquals("D", result.getImageId());
assertEquals("3", result.getComponentVersions().getCdp());
assertEquals(8L, result.getCreated());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeServiceTest method testUpgradeResponseHasReason.
@Test
public void testUpgradeResponseHasReason() {
UpgradeV4Request request = new UpgradeV4Request();
when(upgradeAvailabilityService.checkForUpgrade(CLUSTER, WS_ID, request, USER_CRN)).thenReturn(new UpgradeV4Response("reason", null));
Assertions.assertThrows(BadRequestException.class, () -> underTest.triggerUpgrade(CLUSTER, WS_ID, USER_CRN, request));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeServiceTest method testUpgradeResponseHasNoCandidates.
@Test
public void testUpgradeResponseHasNoCandidates() {
UpgradeV4Request request = new UpgradeV4Request();
when(upgradeAvailabilityService.checkForUpgrade(CLUSTER, WS_ID, request, USER_CRN)).thenReturn(new UpgradeV4Response());
Assertions.assertThrows(BadRequestException.class, () -> underTest.triggerUpgrade(CLUSTER, WS_ID, USER_CRN, request));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeServiceTest method testTriggerFlowWithoutTurnOffReplaceVmsParam.
@Test
public void testTriggerFlowWithoutTurnOffReplaceVmsParam() {
// GIVEN
UpgradeV4Request request = createRequest(true);
UpgradeV4Response response = new UpgradeV4Response();
response.setReplaceVms(true);
response.setUpgradeCandidates(List.of(mock(ImageInfoV4Response.class)));
when(upgradeAvailabilityService.checkForUpgrade(CLUSTER, WS_ID, request, USER_CRN)).thenReturn(response);
when(entitlementService.isInternalRepositoryForUpgradeAllowed(ACCOUNT_ID)).thenReturn(Boolean.FALSE);
when(clouderaManagerLicenseProvider.getLicense(any())).thenReturn(new JsonCMLicense());
ImageInfoV4Response imageInfoV4Response = new ImageInfoV4Response();
imageInfoV4Response.setImageId("imgId");
imageInfoV4Response.setImageCatalogName("catalogName");
when(imageSelector.determineImageId(request, response.getUpgradeCandidates())).thenReturn(imageInfoV4Response);
ArgumentCaptor<StackImageChangeV4Request> imageChangeRequestArgumentCaptor = ArgumentCaptor.forClass(StackImageChangeV4Request.class);
ImageChangeDto imageChangeDto = new ImageChangeDto(STACK_ID, imageInfoV4Response.getImageId());
when(stackCommonService.createImageChangeDto(eq(CLUSTER), eq(WS_ID), imageChangeRequestArgumentCaptor.capture())).thenReturn(imageChangeDto);
when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WS_ID)).thenReturn(stack);
when(lockedComponentService.isComponentsLocked(stack, imageInfoV4Response.getImageId())).thenReturn(true);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW_CHAIN, "asdf");
when(reactorFlowManager.triggerDistroXUpgrade(eq(STACK_ID), eq(imageChangeDto), anyBoolean(), anyBoolean(), anyString())).thenReturn(flowIdentifier);
// WHEN
UpgradeV4Response result = underTest.triggerUpgrade(CLUSTER, WS_ID, USER_CRN, request);
// THEN
verify(reactorFlowManager).triggerDistroXUpgrade(STACK_ID, imageChangeDto, true, true, "variant");
assertTrue(result.isReplaceVms());
}
Aggregations