use of com.sequenceiq.cloudbreak.auth.JsonCMLicense in project cloudbreak by hortonworks.
the class DistroXUpgradeService method verifyCMLicenseValidity.
private void verifyCMLicenseValidity(String userCrn) {
LOGGER.info("Verify if the CM license is valid to authenticate to {}", paywallUrl);
JsonCMLicense license = clouderaManagerLicenseProvider.getLicense(userCrn);
paywallAccessChecker.checkPaywallAccess(license, paywallUrl);
}
use of com.sequenceiq.cloudbreak.auth.JsonCMLicense in project cloudbreak by hortonworks.
the class SdxRuntimeUpgradeServiceTest method testTriggerUpgradeWithValidPaywallLicense.
@Test
public void testTriggerUpgradeWithValidPaywallLicense() {
when(sdxService.getByCrn(anyString(), anyString())).thenReturn(sdxCluster);
when(stackV4Endpoint.checkForClusterUpgradeByName(anyLong(), anyString(), any(), anyString())).thenReturn(response);
when(sdxUpgradeClusterConverter.upgradeResponseToSdxUpgradeResponse(any(UpgradeV4Response.class))).thenReturn(sdxUpgradeResponse);
when(entitlementService.runtimeUpgradeEnabled(any())).thenReturn(true);
when(entitlementService.isInternalRepositoryForUpgradeAllowed(any())).thenReturn(false);
when(clouderaManagerLicenseProvider.getLicense(any())).thenReturn(new JsonCMLicense());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(creatExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(creatExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
sdxUpgradeResponse.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
sdxUpgradeRequest.setLockComponents(false);
sdxUpgradeRequest.setImageId(null);
sdxUpgradeRequest.setReplaceVms(REPAIR_AFTER_UPGRADE);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerUpgradeByCrn(USER_CRN, STACK_CRN, sdxUpgradeRequest, ACCOUNT_ID));
verify(sdxReactorFlowManager, times(1)).triggerDatalakeRuntimeUpgradeFlow(sdxCluster, IMAGE_ID_LAST, REPAIR_AFTER_UPGRADE, SKIP_BACKUP);
verify(sdxReactorFlowManager, times(0)).triggerDatalakeRuntimeUpgradeFlow(sdxCluster, IMAGE_ID, REPAIR_AFTER_UPGRADE, SKIP_BACKUP);
}
use of com.sequenceiq.cloudbreak.auth.JsonCMLicense in project cloudbreak by hortonworks.
the class TelemetryConfigServiceTest method testCreateTelemetryConfigs.
@Test
public void testCreateTelemetryConfigs() throws Exception {
// GIVEN
UserManagementProto.Account account = UserManagementProto.Account.newBuilder().setClouderaManagerLicenseKey("myLicense").build();
JsonCMLicense license = new JsonCMLicense();
license.setName("myname");
license.setUuid("myuuid");
Stack stack = createStack();
given(stackService.getStackById(STACK_ID)).willReturn(stack);
given(entitlementService.useDataBusCNameEndpointEnabled(anyString())).willReturn(false);
given(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).willReturn("myendpoint");
given(vmLogsService.getVmLogs()).willReturn(List.of(new VmLog()));
given(telemetryCommonConfigService.createTelemetryCommonConfigs(any(), any(), any())).willReturn(new TelemetryCommonConfigView.Builder().build());
given(cmLicenseParser.parseLicense(anyString())).willReturn(Optional.of(license));
given(umsClient.getAccountDetails(anyString(), any(), any())).willReturn(account);
given(fluentConfigService.createFluentConfigs(any(), anyBoolean(), anyBoolean(), isNull(), any())).willReturn(new FluentConfigView.Builder().build());
given(nodeStatusConfigService.createNodeStatusConfig(isNull(), isNull(), anyBoolean())).willReturn(new NodeStatusConfigView.Builder().build());
given(monitoringConfigService.createMonitoringConfig(isNull(), any(), isNull(), isNull(), anyBoolean())).willReturn(new MonitoringConfigView.Builder().build());
// WHEN
Map<String, SaltPillarProperties> result = underTest.createTelemetryConfigs(STACK_ID, Set.of(TelemetryComponentType.CDP_TELEMETRY));
// THEN
verify(fluentConfigService, times(1)).createFluentConfigs(any(), anyBoolean(), anyBoolean(), isNull(), any());
assertNotNull(result.get("telemetry").getProperties().get("cloudera-manager"));
assertNotNull(result.get("telemetry").getProperties().get("telemetry"));
}
use of com.sequenceiq.cloudbreak.auth.JsonCMLicense in project cloudbreak by hortonworks.
the class DistroXUpgradeServiceTest method testTriggerFlowWithPaywallCheck.
@Test
public void testTriggerFlowWithPaywallCheck() {
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
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(LOCK_COMPONENTS);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW_CHAIN, "asdf");
when(reactorFlowManager.triggerDistroXUpgrade(eq(STACK_ID), eq(imageChangeDto), anyBoolean(), eq(LOCK_COMPONENTS), anyString())).thenReturn(flowIdentifier);
UpgradeV4Response result = underTest.triggerUpgrade(CLUSTER, WS_ID, USER_CRN, request);
verify(paywallAccessChecker).checkPaywallAccess(any(), any());
assertEquals(flowIdentifier, result.getFlowIdentifier());
assertTrue(result.getReason().contains(imageInfoV4Response.getImageId()));
StackImageChangeV4Request imageChangeV4Request = imageChangeRequestArgumentCaptor.getValue();
assertEquals(imageInfoV4Response.getImageId(), imageChangeV4Request.getImageId());
assertEquals(imageInfoV4Response.getImageCatalogName(), imageChangeV4Request.getImageCatalogName());
}
use of com.sequenceiq.cloudbreak.auth.JsonCMLicense in project cloudbreak by hortonworks.
the class DistroXUpgradeServiceTest method testTriggerFlowWhenReplaceVmsParamIsFalse.
@Test
public void testTriggerFlowWhenReplaceVmsParamIsFalse() {
// GIVEN
UpgradeV4Request request = new UpgradeV4Request();
UpgradeV4Response response = new UpgradeV4Response();
response.setReplaceVms(false);
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(LOCK_COMPONENTS);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW_CHAIN, "asdf");
when(reactorFlowManager.triggerDistroXUpgrade(eq(STACK_ID), eq(imageChangeDto), anyBoolean(), eq(LOCK_COMPONENTS), anyString())).thenReturn(flowIdentifier);
// WHEN
UpgradeV4Response result = underTest.triggerUpgrade(CLUSTER, WS_ID, USER_CRN, request);
// THEN
verify(reactorFlowManager).triggerDistroXUpgrade(STACK_ID, imageChangeDto, false, LOCK_COMPONENTS, "variant");
assertFalse(result.isReplaceVms());
}
Aggregations