Search in sources :

Example 1 with BackupResponse

use of com.sequenceiq.common.api.backup.response.BackupResponse in project cloudbreak by hortonworks.

the class EnvironmentResponseConverterTest method testDtoToDetailedResponse.

@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE", "GCP" })
void testDtoToDetailedResponse(CloudPlatform cloudPlatform) {
    EnvironmentDto environment = createEnvironmentDto(cloudPlatform);
    CredentialResponse credentialResponse = mock(CredentialResponse.class);
    FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
    CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
    TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
    BackupResponse backupResponse = mock(BackupResponse.class);
    ProxyResponse proxyResponse = mock(ProxyResponse.class);
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    when(credentialConverter.convert(environment.getCredential())).thenReturn(credentialResponse);
    when(freeIpaConverter.convert(environment.getFreeIpaCreation())).thenReturn(freeIpaResponse);
    when(regionConverter.convertRegions(environment.getRegions())).thenReturn(compactRegionResponse);
    when(telemetryApiConverter.convert(environment.getTelemetry())).thenReturn(telemetryResponse);
    when(backupConverter.convert(environment.getBackup())).thenReturn(backupResponse);
    when(proxyConfigToProxyResponseConverter.convert((ProxyConfig) environment.getProxyConfig())).thenReturn(proxyResponse);
    when(networkDtoToResponseConverter.convert(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), true)).thenReturn(environmentNetworkResponse);
    DetailedEnvironmentResponse actual = underTest.dtoToDetailedResponse(environment);
    assertEquals(environment.getResourceCrn(), actual.getCrn());
    assertEquals(environment.getName(), actual.getName());
    assertEquals(environment.getOriginalName(), actual.getOriginalName());
    assertEquals(environment.getDescription(), actual.getDescription());
    assertEquals(environment.getCloudPlatform(), actual.getCloudPlatform());
    assertEquals(credentialResponse, actual.getCredential());
    assertEquals(environment.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
    assertLocation(environment.getLocation(), actual.getLocation());
    assertTrue(actual.getCreateFreeIpa());
    assertEquals(freeIpaResponse, actual.getFreeIpa());
    assertEquals(compactRegionResponse, actual.getRegions());
    assertEquals(environment.getCreator(), actual.getCreator());
    assertAuthentication(environment.getAuthentication(), actual.getAuthentication());
    assertEquals(environment.getStatusReason(), actual.getStatusReason());
    assertEquals(environment.getCreated(), actual.getCreated());
    assertEquals(environment.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
    assertEquals(environment.getTags().getDefaultTags(), actual.getTags().getDefaults());
    assertEquals(telemetryResponse, actual.getTelemetry());
    assertEquals(environment.getExperimentalFeatures().getTunnel(), actual.getTunnel());
    assertEquals(environment.getExperimentalFeatures().getIdBrokerMappingSource(), actual.getIdBrokerMappingSource());
    assertEquals(environment.getExperimentalFeatures().getCloudStorageValidation(), actual.getCloudStorageValidation());
    assertEquals(environment.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
    assertEquals(environment.getAdminGroupName(), actual.getAdminGroupName());
    assertParameters(environment, actual, cloudPlatform);
    assertEquals(environment.getParentEnvironmentCrn(), actual.getParentEnvironmentCrn());
    assertEquals(environment.getParentEnvironmentName(), actual.getParentEnvironmentName());
    assertEquals(environment.getParentEnvironmentCloudPlatform(), actual.getParentEnvironmentCloudPlatform());
    assertEquals(proxyResponse, actual.getProxyConfig());
    assertEquals(environmentNetworkResponse, actual.getNetwork());
    assertSecurityAccess(environment.getSecurityAccess(), actual.getSecurityAccess());
    verify(credentialConverter).convert(environment.getCredential());
    verify(freeIpaConverter).convert(environment.getFreeIpaCreation());
    verify(regionConverter).convertRegions(environment.getRegions());
    verify(telemetryApiConverter).convert(environment.getTelemetry());
    verify(proxyConfigToProxyResponseConverter).convert(environment.getProxyConfig());
    verify(networkDtoToResponseConverter).convert(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), true);
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with BackupResponse

use of com.sequenceiq.common.api.backup.response.BackupResponse in project cloudbreak by hortonworks.

the class BackupConverter method createBackupResponseFromSource.

private BackupResponse createBackupResponseFromSource(EnvironmentBackup backup) {
    BackupResponse backupResponse = null;
    if (backup != null) {
        backupResponse = new BackupResponse();
        backupResponse.setStorageLocation(backup.getStorageLocation());
        backupResponse.setS3(convertS3(backup.getS3()));
        backupResponse.setAdlsGen2(convertAdlsV2(backup.getAdlsGen2()));
        backupResponse.setGcs(convertGcs(backup.getGcs()));
        backupResponse.setCloudwatch(BackupCloudwatchParams.copy(backup.getCloudwatch()));
    }
    return backupResponse;
}
Also used : BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse)

Example 3 with BackupResponse

use of com.sequenceiq.common.api.backup.response.BackupResponse in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverterTest method testConvertWhenEnvironmentBackupLocationDefinedThenBaseFileSystemConfigurationsViewShouldAddIt.

@Test
public void testConvertWhenEnvironmentBackupLocationDefinedThenBaseFileSystemConfigurationsViewShouldAddIt() throws IOException {
    String backupLocation = "s3a://test";
    FileSystem sourceFileSystem = new FileSystem();
    FileSystem clusterServiceFileSystem = new FileSystem();
    ConfigQueryEntries configQueryEntries = new ConfigQueryEntries();
    BaseFileSystemConfigurationsView expected = mock(BaseFileSystemConfigurationsView.class);
    List<StorageLocationView> storageLocationViews = mock(List.class);
    BackupResponse backupResponse = new BackupResponse();
    backupResponse.setStorageLocation(backupLocation);
    DetailedEnvironmentResponse environmentResponse = DetailedEnvironmentResponse.builder().withIdBrokerMappingSource(IdBrokerMappingSource.MOCK).withCredential(new CredentialResponse()).withAdminGroupName(ADMIN_GROUP_NAME).withCrn(TestConstants.CRN).withBackup(backupResponse).build();
    StorageLocation storageLocation = new StorageLocation();
    storageLocation.setValue(backupLocation);
    storageLocation.setProperty(RangerCloudStorageServiceConfigProvider.DEFAULT_BACKUP_DIR);
    StorageLocationView backupLocationView = new StorageLocationView(storageLocation);
    when(sourceCluster.getFileSystem()).thenReturn(sourceFileSystem);
    when(cluster.getFileSystem()).thenReturn(clusterServiceFileSystem);
    when(fileSystemConfigurationProvider.fileSystemConfiguration(eq(clusterServiceFileSystem), eq(stackMock), any(), eq(new Json("")), eq(configQueryEntries))).thenReturn(expected);
    when(cmCloudStorageConfigProvider.getConfigQueryEntries()).thenReturn(configQueryEntries);
    when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
    when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
    when(expected.getLocations()).thenReturn(storageLocationViews);
    TemplatePreparationObject result = underTest.convert(stackMock);
    assertThat(result.getFileSystemConfigurationView().isPresent()).isTrue();
    assertThat(result.getFileSystemConfigurationView().get()).isEqualTo(expected);
    verify(fileSystemConfigurationProvider, times(1)).fileSystemConfiguration(eq(clusterServiceFileSystem), eq(stackMock), any(), eq(new Json("")), eq(configQueryEntries));
    verify(expected, times(1)).getLocations();
    verify(storageLocationViews, times(1)).add(eq(backupLocationView));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Json(com.sequenceiq.cloudbreak.common.json.Json) BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse) StorageLocation(com.sequenceiq.cloudbreak.domain.StorageLocation) ConfigQueryEntries(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntries) Test(org.junit.jupiter.api.Test)

Example 4 with BackupResponse

use of com.sequenceiq.common.api.backup.response.BackupResponse in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverter method updateFileSystemViewWithBackupLocation.

private void updateFileSystemViewWithBackupLocation(DetailedEnvironmentResponse detailedEnvironmentResponse, BaseFileSystemConfigurationsView fileSystemConfigurationView) {
    if (fileSystemConfigurationView != null) {
        BackupResponse backupResponse = detailedEnvironmentResponse.getBackup();
        TelemetryResponse telemetryResponse = detailedEnvironmentResponse.getTelemetry();
        Optional<String> backupLocation = Optional.empty();
        if (backupResponse != null && backupResponse.getStorageLocation() != null) {
            backupLocation = Optional.of(backupResponse.getStorageLocation());
        } else if (telemetryResponse != null && telemetryResponse.getLogging() != null) {
            backupLocation = Optional.of(telemetryResponse.getLogging().getStorageLocation());
        }
        if (backupLocation.isPresent()) {
            StorageLocation storageLocation = new StorageLocation();
            storageLocation.setValue(backupLocation.get());
            storageLocation.setProperty(RangerCloudStorageServiceConfigProvider.DEFAULT_BACKUP_DIR);
            StorageLocationView backupLocationView = new StorageLocationView(storageLocation);
            fileSystemConfigurationView.getLocations().add(backupLocationView);
        }
    }
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse) StorageLocation(com.sequenceiq.cloudbreak.domain.StorageLocation)

Example 5 with BackupResponse

use of com.sequenceiq.common.api.backup.response.BackupResponse in project cloudbreak by hortonworks.

the class EnvironmentClientServiceTest method testSdxBackupLocationOnUpgradeRequestEnabled.

@Test
public void testSdxBackupLocationOnUpgradeRequestEnabled() {
    BackupResponse backupResponse = new BackupResponse();
    backupResponse.setStorageLocation(BACKUP_LOCATION);
    LoggingResponse loggingResponse = new LoggingResponse();
    loggingResponse.setStorageLocation(LOG_LOCATION);
    TelemetryResponse telemetryResponse = new TelemetryResponse();
    telemetryResponse.setLogging(loggingResponse);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
    environmentResponse.setBackup(backupResponse);
    environmentResponse.setTelemetry(telemetryResponse);
    environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.MULTIPLE).build()).build());
    when(environmentEndpoint.getByCrn(anyString())).thenReturn(environmentResponse);
    Assert.assertEquals(BACKUP_LOCATION, underTest.getBackupLocation(ENV_CRN));
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse) Test(org.junit.Test)

Aggregations

BackupResponse (com.sequenceiq.common.api.backup.response.BackupResponse)6 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 StorageLocation (com.sequenceiq.cloudbreak.domain.StorageLocation)2 StorageLocationView (com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView)2 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)1 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)1 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)1 ConfigQueryEntries (com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntries)1 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)1 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)1 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1