use of com.sequenceiq.cloudbreak.auth.altus.EntitlementService in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnMultipleMaintenanceUpgradeCandidatesAreAvaiable.
@Test
@DisplayName("this test simulates that a Data Hub runtime upgrade entitlement is disabled" + " and there are 2 image candidates for maintenance upgrade and the latest should be returned with dry-run")
public void testCheckForUpgradeWhenDataHubUpgradeIsDisabledAnMultipleMaintenanceUpgradeCandidatesAreAvaiable() {
Cluster datalakeCluster = TestUtil.cluster();
datalakeCluster.setRangerRazEnabled(false);
UpgradeV4Request request = new UpgradeV4Request();
request.setDryRun(true);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response current = createImageResponse(1L, "7.1.0");
ImageInfoV4Response image1 = createImageResponse(2L, "7.1.0");
ImageInfoV4Response image2 = createImageResponse(3L, "7.1.0");
ImageInfoV4Response image3 = createImageResponse(6L, "7.3.0");
response.setUpgradeCandidates(List.of(image1, image2, image3));
response.setCurrent(current);
StackView stackView = new StackView();
ClusterView clusterView = new ClusterView();
clusterView.setId(1L);
ReflectionTestUtils.setField(stackView, "cluster", clusterView);
stack.setCluster(TestUtil.cluster());
when(runtimeVersionService.getRuntimeVersion(any())).thenReturn(Optional.of("C"));
when(clusterService.getCluster(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);
when(entitlementService.isDifferentDataHubAndDataLakeVersionAllowed(anyString())).thenReturn(false);
when(stackViewService.findDatalakeViewByEnvironmentCrn(stack.getEnvironmentCrn())).thenReturn(Optional.of(stackView));
when(runtimeVersionService.getRuntimeVersion(eq(clusterView.getId()))).thenReturn(Optional.of("7.1.0"));
UpgradeV4Response result = underTest.checkForUpgrade(CLUSTER, WORKSPACE_ID, request, USER_CRN);
assertEquals(1, result.getUpgradeCandidates().size());
verify(entitlementService, times(2)).datahubRuntimeUpgradeEnabled(ACCOUNT_ID);
assertTrue(result.getUpgradeCandidates().stream().anyMatch(img -> img.getCreated() == 3L && "7.1.0".equals(img.getComponentVersions().getCdp())));
}
use of com.sequenceiq.cloudbreak.auth.altus.EntitlementService in project cloudbreak by hortonworks.
the class DistroXUpgradeAvailabilityServiceTest method testCheckForUpgradeWhenDataHubUpgradeIsGaAndOneMaintenanceUpgradeCandidateIsAvaiable.
@Test
@DisplayName("this test simulates that a Data Hub blueprint is GA for upgrade " + " and there 3 image candidates for upgrade")
public void testCheckForUpgradeWhenDataHubUpgradeIsGaAndOneMaintenanceUpgradeCandidateIsAvaiable() {
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.1.0");
ImageInfoV4Response image2 = createImageResponse(8L, "7.2.0");
ImageInfoV4Response image3 = createImageResponse(6L, "7.3.0");
response.setUpgradeCandidates(List.of(image1, image2, image3));
response.setCurrent(current);
stack.getCluster().getBlueprint().setBlueprintUpgradeOption(BlueprintUpgradeOption.GA);
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);
verify(entitlementService, times(1)).datahubRuntimeUpgradeEnabled(ACCOUNT_ID);
assertEquals(3, result.getUpgradeCandidates().size());
assertTrue(result.getUpgradeCandidates().stream().anyMatch(img -> img.getCreated() == 2L && "7.1.0".equals(img.getComponentVersions().getCdp())));
}
Aggregations