|
18 | 18 |
|
19 | 19 | import com.cloud.agent.api.Answer; |
20 | 20 | import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; |
| 21 | +import com.cloud.storage.Storage; |
21 | 22 | import com.cloud.utils.script.Script; |
22 | 23 | import com.cloud.vm.VirtualMachine; |
23 | 24 | import org.apache.cloudstack.backup.BackupAnswer; |
@@ -66,7 +67,10 @@ public void testExecuteWithVmExistsNull() throws Exception { |
66 | 67 | when(command.getMountOptions()).thenReturn("rw"); |
67 | 68 | when(command.isVmExists()).thenReturn(null); |
68 | 69 | when(command.getDiskType()).thenReturn("root"); |
| 70 | + when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 71 | + when(command.getWait()).thenReturn(60); |
69 | 72 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 73 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
70 | 74 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
71 | 75 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
72 | 76 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -109,6 +113,7 @@ public void testExecuteWithVmExistsTrue() throws Exception { |
109 | 113 | when(command.isVmExists()).thenReturn(true); |
110 | 114 | when(command.getDiskType()).thenReturn("root"); |
111 | 115 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 116 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
112 | 117 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
113 | 118 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
114 | 119 | when(command.getBackupVolumesUUIDs()).thenReturn(Arrays.asList("volume-123")); |
@@ -148,6 +153,7 @@ public void testExecuteWithVmExistsFalse() throws Exception { |
148 | 153 | when(command.isVmExists()).thenReturn(false); |
149 | 154 | when(command.getDiskType()).thenReturn("root"); |
150 | 155 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 156 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
151 | 157 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
152 | 158 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
153 | 159 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -185,7 +191,10 @@ public void testExecuteWithCifsMountType() throws Exception { |
185 | 191 | when(command.getMountOptions()).thenReturn("username=user,password=pass"); |
186 | 192 | when(command.isVmExists()).thenReturn(null); |
187 | 193 | when(command.getDiskType()).thenReturn("root"); |
| 194 | + when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 195 | + when(command.getWait()).thenReturn(60); |
188 | 196 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 197 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
189 | 198 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
190 | 199 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
191 | 200 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -226,7 +235,10 @@ public void testExecuteWithMountFailure() throws Exception { |
226 | 235 | lenient().when(command.getMountOptions()).thenReturn("rw"); |
227 | 236 | lenient().when(command.isVmExists()).thenReturn(null); |
228 | 237 | lenient().when(command.getDiskType()).thenReturn("root"); |
| 238 | + lenient().when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 239 | + lenient().when(command.getWait()).thenReturn(60); |
229 | 240 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 241 | + lenient().when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
230 | 242 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
231 | 243 | lenient().when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
232 | 244 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -262,7 +274,10 @@ public void testExecuteWithBackupFileNotFound() throws Exception { |
262 | 274 | when(command.getMountOptions()).thenReturn("rw"); |
263 | 275 | when(command.isVmExists()).thenReturn(null); |
264 | 276 | when(command.getDiskType()).thenReturn("root"); |
| 277 | + when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 278 | + when(command.getWait()).thenReturn(60); |
265 | 279 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 280 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
266 | 281 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
267 | 282 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
268 | 283 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -308,7 +323,10 @@ public void testExecuteWithCorruptBackupFile() throws Exception { |
308 | 323 | when(command.getMountOptions()).thenReturn("rw"); |
309 | 324 | when(command.isVmExists()).thenReturn(null); |
310 | 325 | when(command.getDiskType()).thenReturn("root"); |
| 326 | + when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 327 | + when(command.getWait()).thenReturn(60); |
311 | 328 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 329 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
312 | 330 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
313 | 331 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
314 | 332 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -356,7 +374,10 @@ public void testExecuteWithRsyncFailure() throws Exception { |
356 | 374 | when(command.getMountOptions()).thenReturn("rw"); |
357 | 375 | when(command.isVmExists()).thenReturn(null); |
358 | 376 | when(command.getDiskType()).thenReturn("root"); |
| 377 | + when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 378 | + when(command.getWait()).thenReturn(60); |
359 | 379 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 380 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
360 | 381 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
361 | 382 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
362 | 383 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -406,7 +427,10 @@ public void testExecuteWithAttachVolumeFailure() throws Exception { |
406 | 427 | when(command.getMountOptions()).thenReturn("rw"); |
407 | 428 | when(command.isVmExists()).thenReturn(null); |
408 | 429 | when(command.getDiskType()).thenReturn("root"); |
| 430 | + when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 431 | + when(command.getWait()).thenReturn(60); |
409 | 432 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 433 | + when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
410 | 434 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
411 | 435 | when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
412 | 436 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -460,7 +484,10 @@ public void testExecuteWithTempDirectoryCreationFailure() throws Exception { |
460 | 484 | lenient().when(command.getMountOptions()).thenReturn("rw"); |
461 | 485 | lenient().when(command.isVmExists()).thenReturn(null); |
462 | 486 | lenient().when(command.getDiskType()).thenReturn("root"); |
| 487 | + lenient().when(command.getRestoreVolumeSizes()).thenReturn(Arrays.asList(1024L)); |
| 488 | + lenient().when(command.getWait()).thenReturn(60); |
463 | 489 | PrimaryDataStoreTO primaryDataStore = Mockito.mock(PrimaryDataStoreTO.class); |
| 490 | + lenient().when(primaryDataStore.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
464 | 491 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList(primaryDataStore)); |
465 | 492 | lenient().when(command.getRestoreVolumePaths()).thenReturn(Arrays.asList("/var/lib/libvirt/images/volume-123")); |
466 | 493 | when(command.getBackupFiles()).thenReturn(Arrays.asList("volume-123")); |
@@ -492,6 +519,8 @@ public void testExecuteWithMultipleVolumes() throws Exception { |
492 | 519 | when(command.getDiskType()).thenReturn("root"); |
493 | 520 | PrimaryDataStoreTO primaryDataStore1 = Mockito.mock(PrimaryDataStoreTO.class); |
494 | 521 | PrimaryDataStoreTO primaryDataStore2 = Mockito.mock(PrimaryDataStoreTO.class); |
| 522 | + when(primaryDataStore1.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
| 523 | + when(primaryDataStore2.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); |
495 | 524 | when(command.getRestoreVolumePools()).thenReturn(Arrays.asList( |
496 | 525 | primaryDataStore1, |
497 | 526 | primaryDataStore2 |
|
0 commit comments