Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
Don't allow assign VM to backup offering for VM with encrypted volumes#13229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:4.22
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1217,6 +1217,14 @@ public void testAssignVMToBackupOffering() { | ||
| when(vm.getDataCenterId()).thenReturn(1L); | ||
| when(vm.getBackupOfferingId()).thenReturn(null); | ||
| when(offering.getProvider()).thenReturn("testbackupprovider"); | ||
| VolumeVO volume = mock(VolumeVO.class); | ||
| when(volumeDao.findByInstance(vmId)).thenReturn(List.of(volume)); | ||
| when(volume.getPassphraseId()).thenReturn(null); | ||
| Long diskOfferingId = 5L; | ||
| when(volume.getDiskOfferingId()).thenReturn(diskOfferingId); | ||
| DiskOfferingVO diskOffering = Mockito.mock(DiskOfferingVO.class); | ||
| Mockito.when(diskOffering.getUuid()).thenReturn("disk-offering-uuid"); | ||
| Mockito.when(diskOfferingDao.findById(diskOfferingId)).thenReturn(diskOffering); | ||
| when(backupProvider.assignVMToBackupOffering(vm, offering)).thenReturn(true); | ||
| when(vmInstanceDao.update(1L, vm)).thenReturn(true); | ||
| @@ -1225,11 +1233,32 @@ public void testAssignVMToBackupOffering() { | ||
| assertTrue(result); | ||
| verify(vmInstanceDao, times(1)).findById(vmId); | ||
| verify(volumeDao, times(2)).findByInstance(vmId); | ||
| verify(backupOfferingDao, times(1)).findById(offeringId); | ||
| verify(backupManager, times(1)).getBackupProvider("testbackupprovider"); | ||
| } | ||
| } | ||
| @Test (expected = CloudRuntimeException.class) | ||
| public void testAssignVMToBackupOfferingForVMWithEncryptedVolumes() { | ||
| Long vmId = 1L; | ||
| Long offeringId = 2L; | ||
| VMInstanceVO vm = mock(VMInstanceVO.class); | ||
| overrideBackupFrameworkConfigValue(); | ||
| when(vmInstanceDao.findById(vmId)).thenReturn(vm); | ||
| when(vm.getState()).thenReturn(VirtualMachine.State.Running); | ||
| VolumeVO volume = mock(VolumeVO.class); | ||
| when(volumeDao.findByInstance(vmId)).thenReturn(List.of(volume)); | ||
| when(volume.getPassphraseId()).thenReturn(42L); | ||
| try (MockedStatic<UsageEventUtils> ignored2 = Mockito.mockStatic(UsageEventUtils.class)) { | ||
| backupManager.assignVMToBackupOffering(vmId, offeringId); | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: | ||
| verify(vmInstanceDao, times(1)).findById(vmId); | ||
| } | ||
| } | ||
| @Test | ||
| public void testRemoveVMFromBackupOffering() { | ||
| Long vmId = 1L; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to NasBackupProvider.java in backupProvider.assignVMToBackupOffering.
We want to disable backup for encrypted volume for just nas backup provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti ^