cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raf...@apache.org
Subject [4/5] git commit: updated refs/heads/master to 4480d05
Date Tue, 23 Feb 2016 23:39:25 GMT
CLOUDSTACK-9211: Unit test for 3dgpu support


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b73c053a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b73c053a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b73c053a

Branch: refs/heads/master
Commit: b73c053abd59617b1faca18ad21ed26c5dc78e9f
Parents: 4fcebfc
Author: nvazquez <nicolas.m.vazquez@gmail.com>
Authored: Wed Jan 20 12:09:30 2016 -0800
Committer: nvazquez <nicolas.m.vazquez@gmail.com>
Committed: Wed Jan 20 12:09:30 2016 -0800

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         |  2 +-
 .../vmware/resource/VmwareResourceTest.java     | 29 +++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b73c053a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index bdaf8cf..d6322ab 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -1953,7 +1953,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
      * @param vmMo virtual machine mo
      * @param vmSpec virtual machine specs
      */
-    private void postVideoCardMemoryConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachineTO
vmSpec) {
+    protected void postVideoCardMemoryConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachineTO
vmSpec) {
         String paramVRamSize = "svga.vramSize";
         if (vmSpec.getDetails().containsKey(paramVRamSize)){
             String value = vmSpec.getDetails().get(paramVRamSize);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b73c053a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
index 2e3d41c..f554da9 100644
--- a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
+++ b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
@@ -19,6 +19,12 @@ package com.cloud.hypervisor.vmware.resource;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.any;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -26,8 +32,9 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.mockito.Spy;
 
+import com.vmware.vim25.VirtualDevice;
 import com.vmware.vim25.VirtualMachineConfigSpec;
-
+import com.vmware.vim25.VirtualMachineVideoCard;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.ScaleVmAnswer;
 import com.cloud.agent.api.ScaleVmCommand;
@@ -64,6 +71,10 @@ public class VmwareResourceTest {
     VirtualMachineMO vmMo;
     @Mock
     VirtualMachineConfigSpec vmConfigSpec;
+    @Mock
+    VirtualMachineMO vmMo3dgpu;
+    @Mock
+    VirtualMachineTO vmSpec3dgpu;
 
     @Before
     public void setup() {
@@ -90,4 +101,20 @@ public class VmwareResourceTest {
         verify(_resource).execute(cmd);
     }
 
+    @Test
+    public void testStartVm3dgpuEnabled() throws Exception{
+        Map<String, String> specDetails = new HashMap<String, String>();
+        specDetails.put("svga.vramSize", "131072");
+        when(vmSpec3dgpu.getDetails()).thenReturn(specDetails);
+
+        VirtualMachineVideoCard videoCard = mock(VirtualMachineVideoCard.class);
+        when(videoCard.getVideoRamSizeInKB()).thenReturn(65536l);
+        when(vmMo3dgpu.getAllDeviceList()).thenReturn(Arrays.asList((VirtualDevice) videoCard));
+
+        when(vmMo3dgpu.configureVm(any(VirtualMachineConfigSpec.class))).thenReturn(true);
+
+        _resource.postVideoCardMemoryConfigBeforeStart(vmMo3dgpu, vmSpec3dgpu);
+        verify(vmMo3dgpu).configureVm(any(VirtualMachineConfigSpec.class));
+    }
+
 }


Mime
View raw message