You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2016/09/11 11:18:46 UTC

[2/3] git commit: updated refs/heads/master to 744cb2c

CLOUDSTACK-9428: Add marvin test


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

Branch: refs/heads/master
Commit: 2de5b0dc98148c8e447484b0190c9b5d27a66c35
Parents: 4297857
Author: nvazquez <ni...@gmail.com>
Authored: Wed Aug 31 18:26:43 2016 -0700
Committer: nvazquez <ni...@gmail.com>
Committed: Wed Aug 31 18:26:43 2016 -0700

----------------------------------------------------------------------
 .../smoke/test_deploy_vgpu_enabled_vm.py        | 180 +++++++++++++++----
 1 file changed, 144 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2de5b0dc/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
index c9eb767..d49ab08 100644
--- a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
+++ b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
@@ -24,21 +24,20 @@ from marvin.cloudstackTestCase import cloudstackTestCase
 
 # base - contains all resources as entities and defines create, delete,
 # list operations on them
-from marvin.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering, NetworkOffering, Network, Template
 
 # utils - utility classes for common cleanup, external library wrappers etc
-from marvin.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources, get_hypervisor_type, validateList
 
 # common - commonly used methods for all tests are listed here
 from marvin.lib.common import get_zone, get_domain, get_template, list_hosts
 
 from marvin.sshClient import SshClient
 
-from marvin.codes import FAILED
+from marvin.codes import FAILED, PASS
 
 from nose.plugins.attrib import attr
 
-
 class TestDeployvGPUenabledVM(cloudstackTestCase):
 
     """
@@ -100,48 +99,76 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
     def setUp(self):
         self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"]
         self.apiclient = self.testClient.getApiClient()
+	self.dbclient = self.testClient.getDbConnection()
         if self.noSuitableHost or self.unsupportedHypervisor:
-            self.skipTest("Skipping test because suitable hypervisor/host not\
-                    present")
+            self.hypervisor = get_hypervisor_type(self.apiclient)
+            if self.hypervisor.lower() not in ["vmware"]:
+	            self.skipTest("Skipping test because suitable hypervisor/host not\
+        	            present")
+            self.testdata = self.testClient.getParsedTestDataConfig()
 
         # Get Zone, Domain and Default Built-in template
         self.domain = get_domain(self.apiclient)
-        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
-        self.testdata["mode"] = self.zone.networktype
-        # Before running this test, register a windows template with ostype as
-        # 'Windows 7 (32-bit)'
+	self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
+
+        # Before running this test for Xen Server, register a windows template with ostype as
+	# 'Windows 7 (32-bit)'
         self.template = get_template(
-            self.apiclient,
-            self.zone.id,
-            self.testdata["ostype"])
+		self.apiclient,
+	        self.zone.id,
+        	self.testdata["ostype"])
 
-        if self.template == FAILED:
-            assert False, "get_template() failed to return template with description %s" % self.testdata[
-                "ostype"]
-        # create a user account
+	# create a user account
         self.account = Account.create(
-            self.apiclient,
-            self.testdata["account"],
-            domainid=self.domain.id
+	        self.apiclient,
+        	self.testdata["account"],
+		domainid=self.domain.id
         )
+	self.cleanup = []
 
-        self.testdata["small"]["zoneid"] = self.zone.id
-        self.testdata["small"]["template"] = self.template.id
+	if self.hypervisor.lower() in ["xenserver"]:
+	        self.testdata["mode"] = self.zone.networktype
 
-        self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [
-            {
-                'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, {
-                'vgpuType': 'GRID K120Q'}]
-        # create a service offering
-        self.service_offering = ServiceOffering.create(
-            self.apiclient,
-            self.testdata["service_offerings"]["vgpu260qwin"],
-        )
-        # build cleanup list
-        self.cleanup = [
-            self.service_offering,
-            self.account
-        ]
+	        if self.template == FAILED:
+        	    assert False, "get_template() failed to return template with description %s" % self.testdata[
+                	"ostype"]
+
+	        self.testdata["small"]["zoneid"] = self.zone.id
+        	self.testdata["small"]["template"] = self.template.id
+
+	        self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [
+        	    {
+                	'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, {
+	                'vgpuType': 'GRID K120Q'}]
+        	# create a service offering
+	        self.service_offering = ServiceOffering.create(
+        	    self.apiclient,
+	            self.testdata["service_offerings"]["vgpu260qwin"],
+        	)
+	        # build cleanup list
+        	self.cleanup = [
+	            self.service_offering,
+        	    self.account
+	        ]
+	elif self.hypervisor.lower() in ["vmware"]:
+		self.testdata["isolated_network"]["zoneid"] = self.zone.id
+		self.userapiclient = self.testClient.getUserApiClient(
+         		UserName=self.account.name,
+		        DomainName=self.account.domain
+	        )
+		self.service_offering = ServiceOffering.create(
+	            self.apiclient,
+        	    self.testdata["service_offering"])
+	        self.cleanup.append(self.service_offering)
+
+		# Create Shared Network Offering
+        	self.isolated_network_offering = NetworkOffering.create(
+	            self.apiclient,
+        	    self.testdata["isolated_network_offering"])
+	        self.cleanup.append(self.isolated_network_offering)
+        	# Enable Isolated Network offering
+	        self.isolated_network_offering.update(self.apiclient, state='Enabled')
+		
 
     @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
     def test_deploy_vgpu_enabled_vm(self):
@@ -152,6 +179,10 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
         # 2. Virtual Machine is vGPU enabled (via SSH)
         # 3. listVirtualMachines returns accurate information
         """
+
+	if self.hypervisor.lower() not in ["xenserver"]:
+            self.skipTest("This test case is written specifically\
+                    for XenServer hypervisor")
         self.virtual_machine = VirtualMachine.create(
             self.apiclient,
             self.testdata["small"],
@@ -228,3 +259,80 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
             self.debug("Warning! Exception in tearDown: %s" % e)
+
+    @attr(tags=["advanced"])
+    def test_3d_gpu_support(self):
+        """
+
+        # 1. Register a template for VMware with nicAdapter vmxnet3 and 3D GPU details
+        # 2. Deploy a VM using this template
+        # 3. Create an isolated network
+        # 4. Add network to VM
+        # 5. Verify vm details for 3D GPU details
+        """
+
+        if self.hypervisor.lower() not in ["vmware"]:
+            self.skipTest("This test case is written specifically\
+                    for Vmware hypervisor")
+
+        # Register a private template in the account with nic adapter vmxnet3
+        # Also add required 3D GPU details for enabling it
+        template = Template.register(
+            self.userapiclient,
+            self.testdata["configurableData"]["vmxnet3template"],
+            zoneid=self.zone.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            details=[{"mks.enable3d" : "true", "mks.use3dRenderer" : "automatic",
+                     "svga.autodetect" : "false", "svga.vramSize" : "131072"}]
+        )
+        self.cleanup.append(template)
+        template.download(self.apiclient)
+
+        templates = Template.list(
+            self.userapiclient,
+            listall=True,
+            id=template.id,
+            templatefilter="self"
+        )
+
+        self.assertEqual(
+            validateList(templates)[0],
+            PASS,
+            "Templates list validation failed"
+        )
+
+        self.testdata["virtual_machine"]["zoneid"] = self.zone.id
+        self.testdata["virtual_machine"]["template"] = template.id
+
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.testdata["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            templateid=template.id,
+            serviceofferingid=self.service_offering.id)
+
+        isolated_network = Network.create(
+            self.apiclient,
+            self.testdata["isolated_network"],
+            self.account.name,
+            self.account.domainid,
+            networkofferingid=self.isolated_network_offering.id)
+
+        virtual_machine.add_nic(self.apiclient, isolated_network.id)
+
+        qresultset = self.dbclient.execute("select id from vm_instance where uuid = '%s';"      % virtual_machine.id)
+        vm_id = qresultset[0]
+        qresultset = self.dbclient.execute("select name, value from user_vm_details where vm_id = '%d';"        % vm_id)
+        detailKeys = [x[0] for x in qresultset]
+
+        self.assertTrue('mks.enable3d' in detailKeys and 'mks.use3dRenderer' in detailKeys and 'svga.autodetect' in detailKeys and 'svga.vramSize' in detailKeys, "VM details do not contain 3D GPU details")
+
+        self.assertEquals('true', qresultset[detailKeys.index('mks.enable3d')][1], "Expected detail 'mks.enable3d'='true'")
+
+        self.assertEquals('automatic', qresultset[detailKeys.index('mks.use3dRenderer')][1], "Expected detail 'mks.use3dRenderer'='automatic'")
+
+        self.assertEquals('false', qresultset[detailKeys.index('svga.autodetect')][1], "Expected detail 'svga.autodetect'='false'")
+
+        self.assertEquals('131072', qresultset[detailKeys.index('svga.vramSize')][1], "Expected detail 'svga.vramSize'='131072'")