@Test public void canAddVmWithVirtioScsiControllerNotSupportedOs() { VM vm = createVm(); AddVmFromTemplateCommand<AddVmParameters> cmd = createVmFromTemplateCommand(vm); cluster = createCluster(); vm.setClusterId(cluster.getId()); mockStorageDomainDaoGetForStoragePool(); mockVmTemplateDaoReturnVmTemplate(); mockVerifyAddVM(cmd); mockConfig(); mockMaxPciSlots(); mockStorageDomainDaoGetAllStoragesForPool(20); mockUninterestingMethods(cmd); mockDisplayTypes(vm.getOs()); mockGraphicsDevices(vm.getId()); doReturn(true).when(cmd).checkCpuSockets(); doReturn(cluster).when(cmd).getCluster(); doReturn(createStoragePool()).when(cmd).getStoragePool(); cmd.getParameters().setVirtioScsiEnabled(true); when(osRepository.isSoundDeviceEnabled(any(Integer.class), any(Version.class))) .thenReturn(true); when(osRepository.getArchitectureFromOS(any(Integer.class))) .thenReturn(ArchitectureType.x86_64); when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class))) .thenReturn(new ArrayList<>(Collections.singletonList("VirtIO"))); mockGetAllSnapshots(cmd); cmd.initEffectiveCompatibilityVersion(); ValidateTestUtils.runAndAssertValidateFailure( cmd, EngineMessage.ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_DOES_NOT_SUPPORT_VIRTIO_SCSI); }
protected void mockInterfaceList() { SimpleDependencyInjector.getInstance().bind(OsRepository.class, osRepository); ArrayList<String> diskInterfaces = new ArrayList<>(Arrays.asList(new String[] {"IDE", "VirtIO", "VirtIO_SCSI"})); when(osRepository.getDiskInterfaces(anyInt(), any(Version.class))).thenReturn(diskInterfaces); }
@Test public void isVirtioScsiEnabledDefaultedToTrue() { AddVmCommand<AddVmParameters> cmd = setupCanAddVmTests(0); Cluster cluster = createCluster(); doReturn(cluster).when(cmd).getCluster(); cmd.getParameters().getVm().setClusterId(cluster.getId()); cmd.initEffectiveCompatibilityVersion(); when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class))) .thenReturn(new ArrayList<>(Collections.singletonList("VirtIO_SCSI"))); assertTrue( "isVirtioScsiEnabled hasn't been defaulted to true on cluster >= 3.3.", cmd.isVirtioScsiEnabled()); }
@Test public void testLunDiskWithSgioCanBeAdded() { LunDisk disk = createISCSILunDisk(); disk.setDiskInterface(DiskInterface.VirtIO_SCSI); disk.setSgio(ScsiGenericIO.UNFILTERED); AddDiskParameters parameters = createParameters(); parameters.setDiskInfo(disk); initializeCommand(Guid.newGuid(), parameters); VM vm = mockVm(); vm.setVdsGroupCompatibilityVersion(Version.v3_3); mockMaxPciSlots(); when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class))) .thenReturn(new ArrayList<>(Arrays.asList("VirtIO_SCSI"))); DiskValidator diskValidator = spyDiskValidator(disk); doReturn(true).when(diskValidator).isVirtioScsiControllerAttached(any(Guid.class)); mockInterfaceList(); CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command); }
@Test public void testVirtIoScsiNotSupportedByOs() { DiskImage disk = createVirtIoScsiDiskImage(); AddDiskParameters parameters = createParameters(); parameters.setDiskInfo(disk); Guid storageId = Guid.newGuid(); initializeCommand(storageId, parameters); mockStorageDomain(storageId); mockStoragePoolIsoMap(); VM vm = mockVm(); vm.setVdsGroupCompatibilityVersion(Version.v3_3); mockMaxPciSlots(); when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class))) .thenReturn(new ArrayList<>(Arrays.asList("VirtIO"))); DiskValidator diskValidator = spyDiskValidator(disk); doReturn(true).when(diskValidator).isVirtioScsiControllerAttached(any(Guid.class)); CanDoActionTestUtils.runAndAssertCanDoActionFailure( command, EngineMessage.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED); }
protected void mockInterfaceList() { ArrayList<String> diskInterfaces = new ArrayList<>(Arrays.asList(new String[] {"IDE", "VirtIO", "VirtIO_SCSI"})); when(osRepository.getDiskInterfaces(anyInt(), any(Version.class))).thenReturn(diskInterfaces); }