use of com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes in project cloudbreak by hortonworks.
the class ResourceUtilTest method getVolumeSetResource.
private Resource getVolumeSetResource(String instanceID, Long id) {
Resource resource = new Resource();
resource.setResourceType(ResourceType.AZURE_VOLUMESET);
resource.setInstanceId(instanceID);
resource.setId(id);
VolumeSetAttributes volumeSetAttributes = new VolumeSetAttributes.Builder().build();
resource.setAttributes(new Json(volumeSetAttributes));
return resource;
}
use of com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes in project cloudbreak by hortonworks.
the class AwsRepairTest method assertVolumeResource.
private void assertVolumeResource(List<CloudResource> updatedCloudResources, String instanceId, int sizeDisk, String fstab) {
updatedCloudResources.stream().filter(cloudResource -> instanceId.equals(cloudResource.getInstanceId())).findFirst().ifPresentOrElse(cloudResource -> {
VolumeSetAttributes volumeSetAttributes = cloudResource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class);
assertTrue(cloudResource.isPersistent());
assertEquals(instanceId, cloudResource.getInstanceId());
assertEquals(ResourceType.AWS_VOLUMESET, cloudResource.getType());
assertEquals(WORKER_GROUP, cloudResource.getGroup());
assertEquals(CommonStatus.CREATED, cloudResource.getStatus());
assertEquals(AVAILABILITY_ZONE, volumeSetAttributes.getAvailabilityZone());
assertEquals(Integer.valueOf(sizeDisk), volumeSetAttributes.getVolumes().get(0).getSize());
assertEquals("standard", volumeSetAttributes.getVolumes().get(0).getType());
assertEquals(fstab, volumeSetAttributes.getFstab());
}, () -> fail("Volume resource was not saved for " + instanceId));
}
use of com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes in project cloudbreak by hortonworks.
the class AzureVolumeResourceBuilderTest method deleteTestWhenDiskIsDeletedOnAzure.
@Test
public void deleteTestWhenDiskIsDeletedOnAzure() throws PreserveResourceException {
CloudResource mock = CloudResource.builder().type(ResourceType.AZURE_RESOURCE_GROUP).name("resource-group").build();
when(context.getNetworkResources()).thenReturn(List.of(mock));
ArrayList<VolumeSetAttributes.Volume> volumes = new ArrayList<>();
volumes.add(new VolumeSetAttributes.Volume(VOLUME_ID, DEVICE, VOLUME_SIZE, "ssd", CloudVolumeUsageType.GENERAL));
CloudResource volumeSetResource = CloudResource.builder().type(ResourceType.AZURE_VOLUMESET).status(CommonStatus.CREATED).params(Map.of(CloudResource.ATTRIBUTES, new VolumeSetAttributes(AVAILABILITY_ZONE, true, "", volumes, VOLUME_SIZE, "ssd"))).name(VOLUME_NAME).build();
PagedList<Disk> pagedList = mock(PagedList.class);
when(azureClient.listDisksByResourceGroup(eq("resource-group"))).thenReturn(pagedList);
underTest.delete(context, auth, volumeSetResource);
verify(azureUtils, times(0)).deleteManagedDisks(any(), any());
}
use of com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes in project cloudbreak by hortonworks.
the class AzureVolumeResourceBuilderTest method verifyVolumeSetResource.
private void verifyVolumeSetResource(CloudResource resultVolumeSetResource, String diskIdExpected, String deviceExpected) {
assertThat(resultVolumeSetResource.getType()).isEqualTo(ResourceType.AZURE_VOLUMESET);
assertThat(resultVolumeSetResource.getStatus()).isEqualTo(CommonStatus.CREATED);
assertThat(resultVolumeSetResource.getName()).isEqualTo(VOLUME_NAME);
VolumeSetAttributes resultVolumeSetAttributes = resultVolumeSetResource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class);
assertThat(resultVolumeSetAttributes).isNotNull();
assertThat(resultVolumeSetAttributes.getAvailabilityZone()).isEqualTo(AVAILABILITY_ZONE);
assertThat(resultVolumeSetAttributes.getDeleteOnTermination()).isEqualTo(true);
assertThat(resultVolumeSetAttributes.getFstab()).isEqualTo(FSTAB);
assertThat(resultVolumeSetAttributes.getVolumeSize()).isEqualTo(VOLUME_SIZE);
assertThat(resultVolumeSetAttributes.getVolumeType()).isEqualTo(VOLUME_TYPE);
List<VolumeSetAttributes.Volume> resultVolumes = resultVolumeSetAttributes.getVolumes();
assertThat(resultVolumes).isNotNull();
assertThat(resultVolumes).hasSize(1);
VolumeSetAttributes.Volume resultVolume = resultVolumes.get(0);
assertThat(resultVolume.getId()).isEqualTo(diskIdExpected);
assertThat(resultVolume.getDevice()).isEqualTo(deviceExpected);
assertThat(resultVolume.getSize()).isEqualTo(VOLUME_SIZE);
assertThat(resultVolume.getType()).isEqualTo(VOLUME_TYPE);
assertThat(resultVolume.getCloudVolumeUsageType()).isEqualTo(CloudVolumeUsageType.GENERAL);
}
use of com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes in project cloudbreak by hortonworks.
the class AzureVolumeResourceBuilderTest method buildTestWhenVolumeSetExistsAndRequestedAndExistingDisk.
@Test
void buildTestWhenVolumeSetExistsAndRequestedAndExistingDisk() throws Exception {
initAsyncTaskExecutor();
ArrayList<VolumeSetAttributes.Volume> volumes = new ArrayList<>();
volumes.add(new VolumeSetAttributes.Volume(VOLUME_ID, DEVICE, VOLUME_SIZE, VOLUME_TYPE, CloudVolumeUsageType.GENERAL));
CloudResource volumeSetResource = CloudResource.builder().type(ResourceType.AZURE_VOLUMESET).status(CommonStatus.REQUESTED).params(Map.of(CloudResource.ATTRIBUTES, new VolumeSetAttributes(AVAILABILITY_ZONE, true, FSTAB, volumes, VOLUME_SIZE, VOLUME_TYPE))).name(VOLUME_NAME).build();
when(azureClient.getDiskByName(RESOURCE_GROUP, VOLUME_ID)).thenReturn(disk);
List<CloudResource> result = underTest.build(context, cloudInstance, PRIVATE_ID, auth, group, List.of(volumeSetResource), cloudStack);
verify(azureClient, never()).createManagedDisk(anyString(), anyInt(), any(AzureDiskType.class), anyString(), anyString(), anyMap(), anyString());
assertThat(result).isNotNull();
assertThat(result).hasSize(1);
verifyVolumeSetResource(result.get(0), DISK_ID, DEVICE_DEV_SDC);
}
Aggregations