@SuppressWarnings("unchecked") @Test public void checkStorageProcessorAndHandlerNfsVersionAttributeVersionSet() { _resource.storageNfsVersion = NFS_VERSION; _resource.checkStorageProcessorAndHandlerNfsVersionAttribute(storageCmd); verify(_resource, never()) .examineStorageSubSystemCommandNfsVersion(Matchers.eq(storageCmd), any(EnumMap.class)); }
@Test public void testSetNewVRamSizeVmVideoCardPresent() throws Exception { when(vmMo3dgpu.getAllDeviceList()).thenReturn(Arrays.asList(videoCard, virtualDevice)); _resource.setNewVRamSizeVmVideoCard(vmMo3dgpu, VRAM_MEMORY_SIZE, vmConfigSpec); verify(_resource) .modifyVmVideoCardVRamSize(videoCard, vmMo3dgpu, VRAM_MEMORY_SIZE, vmConfigSpec); }
// Test successful scaling up the vm @Test public void testScaleVMF1() throws Exception { when(_resource.getHyperHost(context, null)).thenReturn(hyperHost); doReturn("i-2-3-VM").when(cmd).getVmName(); when(hyperHost.findVmOnHyperHost("i-2-3-VM")).thenReturn(vmMo); doReturn(536870912L).when(vmSpec).getMinRam(); doReturn(1).when(vmSpec).getCpus(); doReturn(1000).when(vmSpec).getMinSpeed(); doReturn(1000).when(vmSpec).getMaxSpeed(); doReturn(536870912L).when(vmSpec).getMaxRam(); doReturn(false).when(vmSpec).getLimitCpuUse(); when(vmMo.configureVm(vmConfigSpec)).thenReturn(true); _resource.execute(cmd); verify(_resource).execute(cmd); }
@Test public void testExamineStorageSubSystemCommandFullCloneFlagForVmwareNull() { when(destDataStoreTO.isFullCloneFlag()).thenReturn(null); _resource.examineStorageSubSystemCommandFullCloneFlagForVmware(storageCmd, params); verify(destDataTO).getDataStore(); verify(destDataStoreTO).isFullCloneFlag(); assertTrue(params.isEmpty()); }
@Test public void testFindVmOnDatacenter() throws Exception { when(hyperHost.getHyperHostDatacenter()).thenReturn(mor); when(datacenter.getMor()).thenReturn(mor); when(datacenter.findVm(VOLUME_PATH)).thenReturn(vmMo); whenNew(DatacenterMO.class).withArguments(context, mor).thenReturn(datacenter); VirtualMachineMO result = _resource.findVmOnDatacenter(context, hyperHost, volume); assertEquals(vmMo, result); }
@Test public void testConfigureVideoCardSvgaVramProvided() throws Exception { Map<String, String> specDetails = new HashMap<String, String>(); specDetails.put("svga.vramSize", String.valueOf(VRAM_MEMORY_SIZE)); when(vmSpec3dgpu.getDetails()).thenReturn(specDetails); _resource.configureVideoCard(vmMo3dgpu, vmSpec3dgpu, vmConfigSpec); verify(_resource).setNewVRamSizeVmVideoCard(vmMo3dgpu, VRAM_MEMORY_SIZE, vmConfigSpec); }
@Test public void testExamineStorageSubSystemCommandFullCloneFlagForVmware() { EnumMap<VmwareStorageProcessorConfigurableFields, Object> params2 = _resource.examineStorageSubSystemCommandFullCloneFlagForVmware(storageCmd, params); verify(destDataTO).getDataStore(); verify(destDataStoreTO, times(2)).isFullCloneFlag(); assertEquals(1, params2.size()); assertEquals( FULL_CLONE_FLAG, params2.get(VmwareStorageProcessorConfigurableFields.FULL_CLONE_FLAG)); }
@Test public void testConfigureSpecVideoCardNewVRamSize() { when(vmConfigSpec.getDeviceChange()).thenReturn(new ArrayList<VirtualDeviceConfigSpec>()); _resource.configureSpecVideoCardNewVRamSize(videoCard, VRAM_MEMORY_SIZE, vmConfigSpec); InOrder inOrder = Mockito.inOrder(videoCard, vmConfigSpec); inOrder.verify(videoCard).setVideoRamSizeInKB(VRAM_MEMORY_SIZE); inOrder.verify(videoCard).setUseAutoDetect(false); inOrder.verify(vmConfigSpec).getDeviceChange(); }
@Test public void testSetNewVRamSizeVmVideoCardNotPresent() throws Exception { when(vmMo3dgpu.getAllDeviceList()).thenReturn(Arrays.asList(virtualDevice)); _resource.setNewVRamSizeVmVideoCard(vmMo3dgpu, VRAM_MEMORY_SIZE, vmConfigSpec); verify(_resource, never()) .modifyVmVideoCardVRamSize( any(VirtualMachineVideoCard.class), eq(vmMo3dgpu), eq(VRAM_MEMORY_SIZE), eq(vmConfigSpec)); }
@SuppressWarnings("unchecked") @Test public void checkStorageProcessorAndHandlerNfsVersionAttributeVersionNotSet() { _resource.checkStorageProcessorAndHandlerNfsVersionAttribute(storageCmd); verify(_resource) .examineStorageSubSystemCommandNfsVersion(Matchers.eq(storageCmd), any(EnumMap.class)); verify(_resource) .examineStorageSubSystemCommandFullCloneFlagForVmware( Matchers.eq(storageCmd), any(EnumMap.class)); verify(_resource).reconfigureProcessorByHandler(any(EnumMap.class)); assertEquals(NFS_VERSION, _resource.storageNfsVersion); }
@Test public void testConfigNestedHVSupportFlagTrue() throws Exception { specsArray.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, "true"); _resource.configNestedHVSupport(vmMo, vmSpec, vmConfigSpec); verify(vmMo).getRunningHost(); verify(host).getMor(); verify(context, times(2)).getVimClient(); verify(client).getMoRefProp(hostRef, "parent"); verify(client).getMoRefProp(computeRef, "environmentBrowser"); verify(context).getService(); verify(vimService).queryTargetCapabilities(envRef, hostRef); verify(hostCapability).isNestedHVSupported(); verify(vmConfigSpec).setNestedHVEnabled(true); }
@Test public void testgetNfsVersionFromNfsTONfsVersion() { assertTrue(_resource.getStorageNfsVersionFromNfsTO(srcDataNfsTO)); }
@Test(expected = CloudRuntimeException.class) public void testFindVmOnDatacenterNullHyperHostReference() throws Exception { when(hyperHost.getMor()).thenReturn(null); _resource.findVmOnDatacenter(context, hyperHost, volume); }
@Test public void testConfigureVideoCardNotSvgaVramProvided() throws Exception { _resource.configureVideoCard(vmMo3dgpu, vmSpec3dgpu, vmConfigSpec); verify(_resource, never()).setNewVRamSizeVmVideoCard(vmMo3dgpu, VRAM_MEMORY_SIZE, vmConfigSpec); }
@Test public void testModifyVmVideoCardVRamSizeDifferentVramSizes() { _resource.modifyVmVideoCardVRamSize(videoCard, vmMo3dgpu, VRAM_MEMORY_SIZE, vmConfigSpec); verify(_resource).configureSpecVideoCardNewVRamSize(videoCard, VRAM_MEMORY_SIZE, vmConfigSpec); }
@Test public void testExamineStorageSubSystemCommandFullCloneFlagForHypervisorNotVmware() { when(destDataTO.getHypervisorType()).thenReturn(HypervisorType.XenServer); _resource.examineStorageSubSystemCommandFullCloneFlagForVmware(storageCmd, params); verify(destDataTO, never()).getDataStore(); }
@Test public void testExamineStorageSubSystemCommandNfsVersion() { _resource.examineStorageSubSystemCommandNfsVersion(storageCmd, params); assertEquals(1, params.size()); assertEquals(NFS_VERSION, params.get(VmwareStorageProcessorConfigurableFields.NFS_VERSION)); }
@Test public void testExamineStorageSubSystemCommandNfsVersionNotPresent() { when(srcDataNfsTO.getNfsVersion()).thenReturn(NFS_VERSION_NOT_PRESENT); _resource.examineStorageSubSystemCommandNfsVersion(storageCmd, params); assertTrue(params.isEmpty()); }
@Test public void testgetNfsVersionFromNfsTONfsVersionNull() { when(srcDataNfsTO.getNfsVersion()).thenReturn(NFS_VERSION_NOT_PRESENT); assertFalse(_resource.getStorageNfsVersionFromNfsTO(srcDataNfsTO)); }
@Test public void testgetNfsVersionFromNfsTONull() { assertFalse(_resource.getStorageNfsVersionFromNfsTO(null)); }
@Test public void testModifyVmVideoCardVRamSizeEqualSizes() { _resource.modifyVmVideoCardVRamSize(videoCard, vmMo3dgpu, VIDEO_CARD_MEMORY_SIZE, vmConfigSpec); verify(_resource, never()) .configureSpecVideoCardNewVRamSize(videoCard, VIDEO_CARD_MEMORY_SIZE, vmConfigSpec); }
@Test public void testConfigNestedHVSupportFlagFalse() throws Exception { specsArray.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, "false"); _resource.configNestedHVSupport(vmMo, vmSpec, vmConfigSpec); verify(vmMo, never()).getRunningHost(); }
@Test public void testSetCurrentNfsVersionInProcessorAndHandler() { params.put(VmwareStorageProcessorConfigurableFields.NFS_VERSION, NFS_VERSION); _resource.reconfigureProcessorByHandler(params); verify(storageHandler).reconfigureStorageProcessor(params); }