use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsRuntimeValid.
@Test
public void testFilterUpgradeOptionsRuntimeValid() {
UpgradeV4Request request = new UpgradeV4Request();
request.setRuntime(MATCHING_TARGET_RUNTIME);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
assertEquals(2, response.getUpgradeCandidates().size());
assertEquals(2, response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).collect(Collectors.toSet()).size());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class UpgradeConverterTest method testConvertResult.
@Test
public void testConvertResult() {
UpgradeV4Response source = new UpgradeV4Response();
source.setUpgradeCandidates(List.of());
source.setCurrent(new ImageInfoV4Response());
source.setFlowIdentifier(new FlowIdentifier(FlowType.FLOW, "asdg"));
source.setReason("fdas");
DistroXUpgradeV1Response result = underTest.convert(source);
assertEquals(source.getCurrent(), result.getCurrent());
assertEquals(source.getFlowIdentifier(), result.getFlowIdentifier());
assertEquals(source.getReason(), result.getReason());
assertEquals(source.getUpgradeCandidates(), result.getUpgradeCandidates());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnNoMaintenanceUpgradeCandidatesAreAvaiable.
@Test
@DisplayName("this test simulates that a Data Hub runtime upgrade entitlement is disabled" + " and all the image candidates are filtered for maintenance upgrade so empty response should be returned")
public void testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnNoMaintenanceUpgradeCandidatesAreAvaiable() {
Cluster datalakeCluster = TestUtil.cluster();
datalakeCluster.setRangerRazEnabled(false);
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response current = createImageResponse(1L, "7.1.0");
ImageInfoV4Response image1 = createImageResponse(2L, "7.2.0");
ImageInfoV4Response image2 = createImageResponse(8L, "7.3.0");
ImageInfoV4Response image3 = createImageResponse(6L, "7.4.0");
response.setUpgradeCandidates(List.of(image1, image2, image3));
response.setCurrent(current);
when(clusterService.getClusterByStackResourceCrn(any())).thenReturn(datalakeCluster);
when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
when(entitlementService.datahubRuntimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(false);
UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
String expectedMessage = "No image is available for maintenance upgrade, CDP version: 7.1.0";
assertEquals(0, result.getUpgradeCandidates().size());
assertEquals(expectedMessage, result.getReason());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testReturnLatestOnlyForDryRun.
@Test
public void testReturnLatestOnlyForDryRun() {
UpgradeV4Request request = new UpgradeV4Request();
request.setDryRun(Boolean.TRUE);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response image1 = new ImageInfoV4Response();
image1.setCreated(1L);
ImageInfoV4Response image2 = new ImageInfoV4Response();
image2.setCreated(8L);
ImageInfoV4Response image3 = new ImageInfoV4Response();
image3.setCreated(5L);
response.setUpgradeCandidates(List.of(image1, image2, image3));
when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
assertEquals(1, result.getUpgradeCandidates().size());
assertEquals(8L, result.getUpgradeCandidates().get(0).getCreated());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testReturnAllCandidates.
@Test
public void testReturnAllCandidates() {
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
response.setUpgradeCandidates(List.of(mock(ImageInfoV4Response.class), mock(ImageInfoV4Response.class)));
when(stackService.getByNameOrCrnInWorkspace(CLUSTER, WORKSPACE_ID)).thenReturn(stack);
when(stackUpgradeOperations.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request)).thenReturn(response);
UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
assertEquals(response.getUpgradeCandidates(), result.getUpgradeCandidates());
}
Aggregations