abh1sar commented on code in PR #12644:
URL: https://github.com/apache/cloudstack/pull/12644#discussion_r2811311026
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -186,7 +187,7 @@ public void testExecuteWithCifsMountType() throws Exception
{
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
- when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -461,7 +462,7 @@ public void testExecuteWithTempDirectoryCreationFailure()
throws Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
lenient().when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
-
lenient().when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -227,7 +228,7 @@ public void testExecuteWithMountFailure() throws Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
lenient().when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
-
lenient().when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java:
##########
Review Comment:
restoredVolume.setSize(backupVolumeInfo.getSize()); ->
restoredVolume.setSize(backedUpVolumeSize);
##########
plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java:
##########
@@ -366,7 +375,12 @@ public Pair<Boolean, String> restoreBackedUpVolume(Backup
backup, Backup.VolumeI
final StoragePoolVO pool =
primaryDataStoreDao.findByUuid(dataStoreUuid);
final HostVO hostVO = hostDao.findByIp(hostIp);
- LOG.debug("Restoring vm volume {} from backup {} on the NAS Backup
Provider", backupVolumeInfo, backup);
+ Backup.VolumeInfo matchingVolume =
getBackedUpVolumeInfo(backup.getBackedUpVolumes(), volume.getUuid());
+ if (matchingVolume == null) {
+ throw new CloudRuntimeException(String.format("Unable to find
volume %s in the list of backed up volumes for backup %s, cannot proceed with
restore", volume.getUuid(), backup));
+ }
+
Review Comment:
```suggestion
Long backedUpVolumeSize = matchingVolume.getSize();
```
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -309,7 +310,7 @@ public void testExecuteWithCorruptBackupFile() throws
Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
- when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
+
when(command.getBackupVolumesUUIDs()).thenReturn(Collections.singletonList("volume-123"));
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -357,7 +358,7 @@ public void testExecuteWithRsyncFailure() throws Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
- when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -263,7 +264,7 @@ public void testExecuteWithBackupFileNotFound() throws
Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
- when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
+
when(command.getBackupVolumesUUIDs()).thenReturn(Collections.singletonList("volume-123"));
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123",
"volume-456"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -407,7 +408,7 @@ public void testExecuteWithAttachVolumeFailure() throws
Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
- when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapperTest.java:
##########
@@ -69,7 +70,7 @@ public void testExecuteWithVmExistsNull() throws Exception {
PrimaryDataStoreTO primaryDataStore =
Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123"));
- when(command.getRestoreVolumeUUID()).thenReturn("volume-123");
Review Comment:
Add `when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123"));`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]