Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test fixes
  • Loading branch information
sureshanaparti committed Sep 26, 2025
commit 9edae46fbabc65bde5974469f3c0cec960750b22
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.cloud.vm.VirtualMachine;
import org.apache.cloudstack.backup.BackupAnswer;
import org.apache.cloudstack.backup.RestoreBackupCommand;
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -65,6 +66,8 @@ public void testExecuteWithVmExistsNull() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(null);
when(command.getDiskType()).thenReturn("root");
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.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -105,6 +108,8 @@ public void testExecuteWithVmExistsTrue() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(true);
when(command.getDiskType()).thenReturn("root");
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.getBackupVolumesUUIDs()).thenReturn(Arrays.asList("volume-123"));
when(command.getMountTimeout()).thenReturn(30);
Expand Down Expand Up @@ -141,6 +146,8 @@ public void testExecuteWithVmExistsFalse() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(false);
when(command.getDiskType()).thenReturn("root");
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.getMountTimeout()).thenReturn(30);

Expand Down Expand Up @@ -176,6 +183,8 @@ public void testExecuteWithCifsMountType() throws Exception {
when(command.getMountOptions()).thenReturn("username=user,password=pass");
when(command.isVmExists()).thenReturn(null);
when(command.getDiskType()).thenReturn("root");
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.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -215,6 +224,8 @@ public void testExecuteWithMountFailure() throws Exception {
lenient().when(command.getMountOptions()).thenReturn("rw");
lenient().when(command.isVmExists()).thenReturn(null);
lenient().when(command.getDiskType()).thenReturn("root");
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");
lenient().when(command.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -249,6 +260,8 @@ public void testExecuteWithBackupFileNotFound() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(null);
when(command.getDiskType()).thenReturn("root");
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.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -293,6 +306,8 @@ public void testExecuteWithCorruptBackupFile() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(null);
when(command.getDiskType()).thenReturn("root");
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.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -339,6 +354,8 @@ public void testExecuteWithRsyncFailure() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(null);
when(command.getDiskType()).thenReturn("root");
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.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -387,6 +404,8 @@ public void testExecuteWithAttachVolumeFailure() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(null);
when(command.getDiskType()).thenReturn("root");
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.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -439,6 +458,8 @@ public void testExecuteWithTempDirectoryCreationFailure() throws Exception {
lenient().when(command.getMountOptions()).thenReturn("rw");
lenient().when(command.isVmExists()).thenReturn(null);
lenient().when(command.getDiskType()).thenReturn("root");
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");
lenient().when(command.getVmState()).thenReturn(VirtualMachine.State.Running);
Expand Down Expand Up @@ -467,6 +488,12 @@ public void testExecuteWithMultipleVolumes() throws Exception {
when(command.getMountOptions()).thenReturn("rw");
when(command.isVmExists()).thenReturn(true);
when(command.getDiskType()).thenReturn("root");
PrimaryDataStoreTO primaryDataStore1 = Mockito.mock(PrimaryDataStoreTO.class);
PrimaryDataStoreTO primaryDataStore2 = Mockito.mock(PrimaryDataStoreTO.class);
when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(
primaryDataStore1,
primaryDataStore2
));
when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList(
"/var/lib/libvirt/images/volume-123",
"/var/lib/libvirt/images/volume-456"
Expand Down
Loading