vGPU add and list host test cases with review comments

This commit is contained in:
sailajamada 2014-09-01 22:03:35 +05:30
parent 6bd5041ff0
commit 50b1fd4c47
2 changed files with 517 additions and 140 deletions

View File

@ -19,17 +19,18 @@
#All tests inherit from cloudstackTestCase
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering,listConfigurations
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
from marvin.lib.base import Account, VirtualMachine, ServiceOffering , Template
from marvin.lib.base import Account, VirtualMachine, ServiceOffering , Template , Host
#utils - utility classes for common cleanup, external library wrappers etc
from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
from marvin.lib.common import get_zone, get_domain, get_template, list_hosts ,list_service_offering, get_windows_template
from marvin.lib.common import get_zone, get_domain, get_template, list_hosts ,list_service_offering, get_windows_template, get_pod, list_clusters, list_virtual_machines
from marvin.sshClient import SshClient
@ -49,6 +50,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
cls.testdata = cls.testClient.getParsedTestDataConfig()
cls.apiclient = cls.testClient.getApiClient()
cls._cleanup = []
cls.cleanup = []
hosts = list_hosts(
cls.apiclient,
hypervisor="XenServer"
@ -65,65 +67,68 @@ class TestvGPUWindowsVm(cloudstackTestCase):
cls.k200gpuhosts=0
cls.k1passthroughgpuhosts=0
cls.k2passthroughgpuhosts=0
cls.nongpuhosts=[]
k2hosts=0
k1hosts=0
cls.vm_k1_card=""
cls.vm_k2_card=""
for ghost in hosts :
if ghost.hypervisorversion >= "6.2.0":
sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd="host_password")
#sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd="freebsd")
sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd="freebsd")
if ghost.hypervisorversion == "6.2.0":
res = sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
if len(res) == 0:
res = len(sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503"))
if res == 0:
continue
k1card= sshClient.execute("lspci | grep \"GRID K1\"")
k2card= sshClient.execute("lspci | grep \"GRID K2\"")
if len(k2card) !=0:
k1card= len(sshClient.execute("lspci | grep \"GRID K1\""))
k2card= len(sshClient.execute("lspci | grep \"GRID K2\""))
cls.debug("k1 card and k2 card details are :%s %s "%(k1card,k2card))
if (k2card==0) and (k1card==0):
cls.nongpuhosts.append(ghost.ipaddress)
if k2card !=0:
k2hosts=k2hosts+1
k260q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K260Q\"")
k240q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K240Q\"")
k220q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K220Q\"")
k200 = sshClient.execute("xe vgpu-type-list model-name=\"GRID K200\"")
k2passthrough = sshClient.execute("xe vgpu-type-list model-name='passthrough'")
if (len(k260q) == 0) and len(k240q) == 0 and len(k220q) == 0 and len(k200) == 0 and len(k2passthrough) == 0:
k260q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K260Q\""))
k240q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K240Q\""))
k220q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K220Q\""))
k200 = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K200\""))
k2passthrough = len(sshClient.execute("xe vgpu-type-list model-name='passthrough'"))
if ((k260q==0) and (k240q==0) and (k220q==0) and (k200==0) and (k2passthrough== 0)):
continue
else:
if len(k260q) != 0 :
if k260q != 0 :
cls.k260qgpuhosts=cls.k260qgpuhosts+1
if len(k240q) != 0 :
if k240q != 0 :
cls.k240qgpuhosts=cls.k240qgpuhosts+1
if len(k220q) != 0 :
if k220q != 0 :
cls.k220qgpuhosts=cls.k220qgpuhosts+1
if len(k200) != 0 :
if k200 != 0 :
cls.k200gpuhosts=cls.k200gpuhosts+1
if len(k2passthrough) != 0:
if k2passthrough != 0:
cls.k2passthroughgpuhosts=cls.k2passthroughgpuhosts+1
if len(k1card) != 0:
if k1card != 0:
k1hosts=k1hosts+1
k100 = sshClient.execute("xe vgpu-type-list model-name=\"GRID K100\"")
k120q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\"")
k140q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K140Q\"")
k1passthrough = sshClient.execute("xe vgpu-type-list model-name='passthrough'")
if len(k100) == 0 and len(k120q) == 0 and len(k140q) == 0 and len(k1passthrough) == 0:
k100 = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K100\""))
k120q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\""))
k140q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K140Q\""))
k1passthrough = len(sshClient.execute("xe vgpu-type-list model-name='passthrough'"))
if ((k100 == 0) and (k120q == 0) and (k140q == 0) and (k1passthrough == 0)):
continue
else:
if len(k140q) != 0 :
if k140q != 0 :
cls.k140qgpuhosts=cls.k140qgpuhosts+1
if len(k120q) != 0 :
if k120q != 0 :
cls.k120qgpuhosts=cls.k120qgpuhosts+1
if len(k100) != 0 :
if k100 != 0 :
cls.k100gpuhosts=cls.k100gpuhosts+1
if len(k1passthrough) != 0 :
if k1passthrough != 0 :
cls.k1passthroughgpuhosts=cls.k1passthroughgpuhosts+1
if (k1hosts == 0) and (k2hosts == 0):
raise unittest.SkipTest("No XenServer available with GPU Drivers installed")
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient)
cls.pod = get_pod(cls.apiclient, cls.zone.id)
cls.account = Account.create(
cls.apiclient,
cls.testdata["account"],
@ -160,12 +165,13 @@ class TestvGPUWindowsVm(cloudstackTestCase):
template_response = list_template_response[0]
if template_response.isready == True:
break
if timeout == 0:
raise unittest.SkipTest("Failed to download template(ID: %s)" % template_response.id)
timeout = timeout - 1
"""
Create Service Offerings for Both K1 and K2 cards to be used for VM life cycle tests
"""
@ -180,15 +186,15 @@ class TestvGPUWindowsVm(cloudstackTestCase):
else:
gtype = "passthrough"
cls.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'},
cls.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice':'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'},
{'vgpuType':gtype}]
try:
cls.k100_vgpu_service_offering = ServiceOffering.create(
self.apiclient,
cls.apiclient,
cls.testdata["vgpu"]["service_offerings"][gtype]
)
except Exception as e:
self.fail("Failed to create the service offering, %s" % e)
cls.fail("Failed to create the service offering, %s" % e)
if(k2hosts != 0):
if(cls.k240qgpuhosts != 0):
@ -208,7 +214,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
cls.testdata["vgpu"]["service_offerings"][gtype]
)
except Exception as e:
self.fail("Failed to create the service offering, %s" % e)
cls.fail("Failed to create the service offering, %s" % e)
"""
Create Virtual Machines for Both K1 and K2 cards to be used for VM life cycle tests
@ -237,17 +243,61 @@ class TestvGPUWindowsVm(cloudstackTestCase):
cls._cleanup = [
cls.account
cls.account,
cls.k100_vgpu_service_offering,
cls.k200_vgpu_service_offering
]
@attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
def setUp(self):
self.testdata = self.testClient.getParsedTestDataConfig()
self.apiclient = self.testClient.getApiClient()
self.cleanup = []
return
def check_host_vgpu_capacity(self,gpucard,gtype):
gputhosts = list_hosts(
self.apiclient,
hypervisor="XenServer"
)
vgpucapacity=0
for ghost in gputhosts:
if ghost.gpugroup is not None:
for gp in ghost.gpugroup:
if gp.gpugroupname == gpucard:
for gptype in gp.vgpu:
if gptype.vgputype == gtype:
vgpucapacity=vgpucapacity+gptype.remainingcapacity
return(vgpucapacity)
@attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
def vgpu_serviceoffering_creation(self,gtype,nvidiamodel):
if gtype=="nonvgpuoffering" and nvidiamodel=="None":
self.service_offering = ServiceOffering.create(
self.apiclient,
self.testdata["vgpu"]["service_offerings"][gtype]
)
list_service_response = ServiceOffering.list(
self.apiclient,
id=self.service_offering.id
)
if list_service_response is None:
raise unittest.SkipTest("Check Service Offering list for %s service offering" %(gtype))
self.assertEqual(
list_service_response[0].displaytext,
self.testdata["vgpu"]["service_offerings"][gtype]["displaytext"],
"Check server displaytext in createServiceOfferings"
)
self.assertEqual(
list_service_response[0].name,
self.testdata["vgpu"]["service_offerings"][gtype]["name"],
"Check name in createServiceOffering"
)
else:
self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': nvidiamodel},
{'vgpuType':gtype}]
self.service_offering = ServiceOffering.create(
@ -277,7 +327,8 @@ class TestvGPUWindowsVm(cloudstackTestCase):
self.testdata["vgpu"]["service_offerings"][gtype]["name"],
"Check name in createServiceOffering"
)
return(self.service_offering)
return(self.service_offering)
@attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
def check_for_vGPU_resource(self,hostid,vminstancename,serviceofferingid,vgputype):
@ -290,7 +341,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
self.apiclient,
id=hostid
)
ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd="host_password")
ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd="freebsd")
"""
Get vGPU type model
"""
@ -325,7 +376,8 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def deploy_vGPU_windows_vm(self,vgpuofferingid):
def deploy_vGPU_windows_vm(self,vgpuofferingid,vgput):
"""
Validate vGPU K1 windows instances
"""
@ -338,14 +390,47 @@ class TestvGPUWindowsVm(cloudstackTestCase):
serviceofferingid=vgpuofferingid,
templateid=self.template.id
)
time.sleep(600)
self.virtual_machine.getState(
self.apiclient,
"Running")
"""
Check for vGPU resources in the VM
"""
self.check_for_vGPU_resource(self.virtual_machine.hostid,self.virtual_machine.instancename,self.virtual_machine.serviceofferingid,self.virtual_machine.vgpu)
time.sleep(self.testdata["vgpu"]["sleep"])
list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)
self.debug(
"Verify listVirtualMachines response for virtual machine: %s"\
% self.virtual_machine.id
)
self.assertEqual(
isinstance(list_vms, list),
True,
"List VM response was not a valid list"
)
self.assertNotEqual(
len(list_vms),
0,
"List VM response was empty"
)
vm = list_vms[0]
self.assertEqual(
vm.id,
self.virtual_machine.id,
"Virtual Machine ids do not match"
)
self.assertEqual(
vm.name,
self.virtual_machine.name,
"Virtual Machine names do not match"
)
self.assertEqual(
vm.state,
"Running",
msg="VM is not in Running state"
)
if vgput != "None":
self.assertEqual(
vm.vgpu,
vgput,
msg="Failed to deploy VM with vGPU card"
)
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@ -369,153 +454,423 @@ class TestvGPUWindowsVm(cloudstackTestCase):
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def destroy_vm(self):
"""Test destroy Virtual Machine
"""Destroy Virtual Machine
"""
self.virtual_machine.delete(self.apiclient)
self.virtual_machine.getState(
self.apiclient,
"Destroyed")
list_vm_response = VirtualMachine.list(
self.apiclient,
id=self.virtual_machine.id
)
self.assertEqual(
isinstance(list_vm_response, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
len(list_vm_response),
0,
"Check VM avaliable in List Virtual Machines"
)
self.assertEqual(
list_vm_response[0].state,
"Destroyed",
"Check virtual machine is in destroyed state"
)
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def stop_vm(self):
"""Stop Virtual Machine
"""
try:
self.virtual_machine.stop(self.apiclient)
except Exception as e:
self.fail("Failed to stop VM: %s" % e)
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def start_vm(self):
"""Start Virtual Machine
"""
self.debug("Starting VM - ID: %s" % self.virtual_machine.id)
self.virtual_machine.start(self.apiclient)
list_vm_response = VirtualMachine.list(
self.apiclient,
id=self.virtual_machine.id
)
self.assertEqual(
isinstance(list_vm_response, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
len(list_vm_response),
0,
"Check VM available in List Virtual Machines"
)
self.debug(
"Verify listVirtualMachines response for virtual machine: %s" \
% self.virtual_machine.id
)
self.assertEqual(
list_vm_response[0].state,
"Running",
"Check virtual machine is in running state"
)
return
def test_01_list_vgpu_host_details(self):
""" list vGPU host details """
hhosts = list_hosts(
self.apiclient,
hypervisor="XenServer",
)
self.assertEqual(
isinstance(hhosts, list),
True,
"Check list hosts response returns a valid list"
)
self.assertNotEqual(
len(hhosts),
0,
"Check Host details are available in List Hosts"
)
k260q=0
k240q=0
k220q=0
k200=0
k2pass=0
k140q=0
k120q=0
k100=0
k1pass=0
for ggroup in hhosts:
if ggroup.ipaddress not in self.nongpuhosts:
for gp in ggroup.gpugroup:
if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID K2] GPUs":
for gptype in gp.vgpu:
if gptype.vgputype == "GRID K260Q":
k260q=k260q+1
if gptype.vgputype == "GRID K220Q":
k220q=k220q+1
if gptype.vgputype == "GRID K240Q":
k240q=k240q+1
if gptype.vgputype == "GRID K200":
k200=k200+1
if gptype.vgputype != "passthrough":
k2pass=k2pass+1
if gp.gpugroupname == "Group of NVIDIA Corporation GK107GL [GRID K1] GPUs":
for gptype in gp.vgpu:
if gptype.vgputype == "GRID K140Q":
k140q=k140q+1
if gptype.vgputype == "GRID K120Q":
k120q=k120q+1
if gptype.vgputype == "GRID K100":
k100=k100+1
if gptype.vgputype == "passthrough":
k1pass=k1pass+1
else:
self.debug("This is nongpuhost:%s"%(ggroup.ipaddress))
if self.k260qgpuhosts>0:
if not k260q:
self.fail("list host details with K260Q vgpu are not correct")
if self.k240qgpuhosts>0:
if not k240q:
self.fail("list host details with K240Q vgpu are not correct")
if self.k220qgpuhosts>0:
if not k220q:
self.fail("list host details with K220Q vgpu are not correct")
if self.k200gpuhosts>0:
if not k200:
self.fail("list host details with K200 vgpu are not correct")
if self.k2passthroughgpuhosts>0:
if not k2pass:
self.fail("list host details with K2 passthrough vgpu are not correct")
if self.k140qgpuhosts>0:
if not k140q:
self.fail("list host details with K140Q vgpu are not correct")
if self.k120qgpuhosts>0:
if not k120q:
self.fail("list host details with K120Q vgpu are not correct")
if self.k100gpuhosts>0:
if not k100:
self.fail("list host details with K100 vgpu are not correct")
if self.k1passthroughgpuhosts>0:
if not k200:
self.fail("list host details with K1 Passthrough vgpu are not correct")
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_01_create_deploy_windows_vm_with_k100_vgpu_service_offering(self):
"""Test to create and deploy vm with K100 vGPU service offering"""
if (self.k100gpuhosts == 0):
k100capacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K100")
self.debug("k100capacity is:%s"%(k100capacity))
self.debug("k100gpuhosts is:%s"%(self.k100gpuhosts))
if (self.k100gpuhosts == 0) or (k100capacity == 0):
raise unittest.SkipTest("No XenServer available with K100 vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K100","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
self.deploy_vGPU_windows_vm(self.vgpuoffering[0].id)
self.delete_vgpu_service_offering(self.vgpuoffering)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K100","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K100")
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_02_create_deploy_windows_vm_with_k120q_vgpu_service_offering(self):
def test_03_create_deploy_windows_vm_with_k120q_vgpu_service_offering(self):
"""Test to create and deploy vm with K120Q vGPU service offering"""
if (self.k120qgpuhosts == 0):
k120qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K120Q")
if (self.k120qgpuhosts == 0) or (k120qcapacity==0):
raise unittest.SkipTest("No XenServer available with K120Q vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K120Q","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K120Q","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K120Q")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_03_create_deploy_windows_vm_with_k140q_vgpu_service_offering(self):
def test_04_create_deploy_windows_vm_with_k140q_vgpu_service_offering(self):
"""Test to create and deploy vm with K140Q vGPU service offering"""
if (self.k140qgpuhosts == 0):
k140qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K140Q")
if (self.k140qgpuhosts == 0) or (k140qcapacity ==0):
raise unittest.SkipTest("No XenServer available with K140Q vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K140Q","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K140Q","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K140Q")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_04_create_deploy_windows_vm_with_k1_passthrough_vgpu_service_offering(self):
def test_05_create_deploy_windows_vm_with_k1_passthrough_vgpu_service_offering(self):
"""Test to create and deploy vm with K1 passthrough vGPU service offering"""
if (self.k1passthroughgpuhosts == 0):
k1passcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","passthrough")
if (self.k1passthroughgpuhosts == 0) or (k1passcapacity==0):
raise unittest.SkipTest("No XenServer available with K1 passthrough installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("passthrough","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("passthrough","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"passthrough")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_05_create_deploy_windows_vm_with_k2_passthrough_vgpu_service_offering(self):
def test_06_create_deploy_windows_vm_with_k2_passthrough_vgpu_service_offering(self):
"""Test to create and deploy vm with K2 pasthrough vGPU service offering"""
if (self.k2passthroughgpuhosts == 0):
k2passcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","passthrough")
if (self.k2passthroughgpuhosts == 0) or (k2passcapacity==0):
raise unittest.SkipTest("No XenServer available with K2 passthrough installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("passthrough","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("passthrough","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"passthrough")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_06_create_deploy_windows_vm_with_k260q_vgpu_service_offering(self):
def test_07_create_deploy_windows_vm_with_k260q_vgpu_service_offering(self):
"""Test to create and deploy vm with K260Q vGPU service offering"""
if (self.k260qgpuhosts == 0):
k260qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K260Q")
if (self.k260qgpuhosts == 0) or (k260qcapacity == 0):
raise unittest.SkipTest("No XenServer available with K260Q vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K260Q","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K260Q","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K260Q")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_07_create_deploy_windows_vm_with_k240q_vgpu_service_offering(self):
def test_08_create_deploy_windows_vm_with_k240q_vgpu_service_offering(self):
""" Test to create and deploy vm with K240Q vGPU service offering """
if (self.k240qgpuhosts == 0):
k240qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K240Q")
if (self.k240qgpuhosts == 0) or (k240qcapacity==0):
raise unittest.SkipTest("No XenServer available with K240Q vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K240Q","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K240Q","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K240Q")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_08_create_deploy_windows_vm_with_k220q_vgpu_service_offering(self):
def test_09_create_deploy_windows_vm_with_k220q_vgpu_service_offering(self):
""" Test to create and deploy vm with K220Q vGPU service offering """
if (self.k220qgpuhosts == 0):
k220qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K220Q")
if (self.k220qgpuhosts == 0) or (k220qcapacity==0):
raise unittest.SkipTest("No XenServer available with K220Q vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K220Q","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
res=self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K220Q","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K220Q")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
if res is not None:
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_09_create_deploy_windows_vm_with_k200_vgpu_service_offering(self):
def test_10_create_deploy_windows_vm_with_k200_vgpu_service_offering(self):
""" Test to create and deploy vm with K200 vGPU service offering """
if (self.k200gpuhosts == 0):
k200capacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K200")
if (self.k200gpuhosts == 0) or (k200capacity==0):
raise unittest.SkipTest("No XenServer available with K200 vGPU Drivers installed")
else:
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K200","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
res=self.deploy_vGPU_windows_vm(self.vgpuoffering.id)
self.vgpuoffering=self.vgpu_serviceoffering_creation("GRID K200","Group of NVIDIA Corporation GK104GL [GRID K2] GPUs")
if self.vgpuoffering is not None:
self.deploy_vGPU_windows_vm(self.vgpuoffering.id,"GRID K200")
self.delete_vgpu_service_offering(self.vgpuoffering)
self.destroy_vm()
if res is not None:
self.delete_vgpu_service_offering(self.vgpuoffering)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_10_validate_deployed_vGPU_windows_vm(self):
def test_11_add_nonvgpu_host_to_vgpucluster(self):
""" Test to add non vGPU host to an existing cluster """
countx=0
#hostuuids=[]
huuids=[]
lhosts = list_hosts(
self.apiclient,
hypervisor="XenServer"
)
sshClient1 = SshClient(host=lhosts[0].ipaddress, port=22, user='root',passwd="freebsd")
totalxenhosts=len(sshClient1.execute("xe host-list | grep uuid"))
for hostlist in lhosts:
countx=countx+1
if totalxenhosts<=countx:
raise unittest.SkipTest("No additional Host is available in the XS pool to add host")
huuids.append(sshClient1.execute("xe host-list --minimal"))
self.debug("host uuids are:%s"%huuids)
hostuuids=huuids[0][0].split(',')
addhost="FAIL"
for hid in hostuuids:
self.debug("host id: %s"%(hid))
haddress=sshClient1.execute("xe host-param-get param-name=address --minimal uuid="+hid)
self.debug("host address is %s"%(haddress[0]))
if haddress[0]==self.testdata["vgpu"]["nongpu_host_ip"]:
addhost="PASS"
break
if addhost!="PASS":
raise unittest.SkipTest("XS Pool new host ip is not matching with test data host ip. Skipping the test.Please update test data file with hostip added to XS pool")
list_cluster_response = list_clusters(
self.apiclient,
hypervisor="XenServer",
allocationstate="Enabled"
)
self.assertEqual(
isinstance(list_cluster_response, list),
True,
"Check list clusters response returns a valid list"
)
self.assertNotEqual(
len(list_cluster_response),
0,
"Check list clusters response"
)
cluster_response = list_cluster_response[0]
self.assertEqual(
cluster_response.allocationstate,
'Enabled',
"Check whether allocation state of cluster is enabled"
)
self.debug("Cluster response is:%s"%(cluster_response))
self.assertEqual(
cluster_response.hypervisortype,
"XenServer",
"Check hypervisor type is XenServer or not"
)
nongpuhost = Host.create(
self.apiclient,
cluster_response,
self.testdata["vgpu"]["hosts"]["nonvgpuxenserver"],
zoneid=self.zone.id,
podid=self.pod.id,
hypervisor="XenServer"
)
if nongpuhost == FAILED:
self.fail("Host Creation Failed")
self.debug(
"Created host (ID: %s) in cluster ID %s" %(
nongpuhost.id,
cluster_response.id
))
listhosts = list_hosts(
self.apiclient,
hypervisor="XenServer",
id=nongpuhost.id
)
self.assertEqual(
isinstance(listhosts, list),
True,
"Check list hosts response returns a valid list"
)
self.assertNotEqual(
len(listhosts),
0,
"Check Host details are available in List Hosts"
)
for ggroup in listhosts:
if ggroup.gpugroup is not None:
self.fail("This is not a non vGPU host")
#Cleanup Host
self.cleanup.append(nongpuhost)
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_13_validate_deployed_vGPU_windows_vm(self):
""" Test deploy virtual machine
"""
self.debug("Check if deployed VMs are in running state?")
@ -535,7 +890,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_11_stop_vGPU_windows_vm(self):
def test_14_stop_vGPU_windows_vm(self):
""" Test stop virtual machine
"""
if(self.vm_k1_card):
@ -547,7 +902,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_12_start_vGPU_windows_vm(self):
def test_15_start_vGPU_windows_vm(self):
""" Test start virtual machine
"""
if(self.vm_k1_card):
@ -563,7 +918,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_13_restore_vGPU_windows_vm(self):
def test_16_restore_vGPU_windows_vm(self):
"""Test restore Virtual Machine
"""
if(self.vm_k1_card):
@ -587,7 +942,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_14_reboot_vGPU_windows_vm(self):
def test_17_reboot_vGPU_windows_vm(self):
""" Test reboot virtual machine
"""
if(self.vm_k1_card):
@ -611,7 +966,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_15_destroy_vGPU_windows_vm(self):
def test_18_destroy_vGPU_windows_vm(self):
"""Test destroy Virtual Machine
"""
if(self.vm_k1_card):
@ -629,7 +984,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
return
@attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
def test_16_recover_vGPU_windows_vm(self):
def test_19_recover_vGPU_windows_vm(self):
"""Test recover Virtual Machine
"""
if(self.vm_k1_card):

View File

@ -929,7 +929,7 @@ test_data = {
"name": "hostantiaffinity",
"type": "host anti-affinity",
},
"vgpu":{
"vgpu":{
"disk_offering":{
"displaytext": "Small",
"name": "Small",
@ -945,7 +945,20 @@ test_data = {
"ispublic": "true",
"hypervisor": "XenServer"
},
"clusters": {
"clustername": "Xen Cluster Vgpu",
"clustertype": "CloudManaged",
"hypervisor": "XenServer"
},
"hosts": {
"nonvgpuxenserver": {
"hypervisor": 'XenServer',
"clustertype": 'CloudManaged',
"url": 'http://10.102.192.57',
"username": "root",
"password": "freebsd",
},
},
"account": {
"email": "test@test.com",
"firstname": "Test",
@ -955,8 +968,8 @@ test_data = {
# ensure unique username generated each time
"password": "password",
},
"vgpu260q":
{
"vgpu260q": # Create a virtual machine instance with vgpu type as 260q
{
"displayname": "testserver",
"username": "root", # VM creds for SSH
"password": "password",
@ -966,7 +979,7 @@ test_data = {
"publicport": 22,
"protocol": 'TCP',
},
"vgpu140q":
"vgpu140q": # Create a virtual machine instance with vgpu type as 140q
{
"displayname": "testserver",
"username": "root",
@ -981,40 +994,40 @@ test_data = {
{
"GRID K260Q":
{
"name": "Windows Instance with vGPU260Q",
"displaytext": "Windows Instance with vGPU260Q",
"name": "vGPU260Q",
"displaytext": "vGPU260Q",
"cpunumber": 2,
"cpuspeed": 1600, # in MHz
"memory": 3072, # In MBs
},
"GRID K240Q":
{
"name": "Windows Instance with vGPU240Q",
"displaytext": "Windows Instance with vGPU240Q",
"name": "vGPU240Q",
"displaytext": "vGPU240Q",
"cpunumber": 2,
"cpuspeed": 1600, # in MHz
"memory": 3072, # In MBs
},
"GRID K220Q":
{
"name": "Windows Instance with vGPU220Q",
"displaytext": "Windows Instance with vGPU220Q",
"name": "vGPU220Q",
"displaytext": "vGPU220Q",
"cpunumber": 2,
"cpuspeed": 1600, # in MHz
"memory": 3072, # In MBs
},
"GRID K200":
{
"name": "Windows Instance with vGPU200",
"displaytext": "Windows Instance with vGPU200",
"name": "vGPU200",
"displaytext": "vGPU200",
"cpunumber": 2,
"cpuspeed": 1600, # in MHz
"memory": 3072, # In MBs
},
"passthrough":
{
"name": "Windows Instance with vGPU passthrough",
"displaytext": "Windows Instance with vGPU passthrough",
"name": "vGPU passthrough",
"displaytext": "vGPU passthrough",
"cpunumber": 2,
"cpuspeed": 1600, # in MHz
"memory": 3072, # In MBs
@ -1023,36 +1036,45 @@ test_data = {
{
# Small service offering ID to for change VM
# service offering from medium to small
"name": "Windows Instance with vGPU140Q",
"displaytext": "Windows Instance with vGPU140Q",
"name": "vGPU140Q",
"displaytext": "vGPU140Q",
"cpunumber": 2,
"cpuspeed": 1600,
"memory": 3072,
},
"GRID K120Q":
{
"name": "Windows Instance with vGPU120Q",
"displaytext": "Windows Instance with vGPU120Q",
"name": "vGPU120Q",
"displaytext": "vGPU120Q",
"cpunumber": 2,
"cpuspeed": 1600,
"memory": 3072,
},
"GRID K100":
{
"name": "Windows Instance with vGPU100",
"displaytext": "Windows Instance with vGPU100",
"name": "vGPU100",
"displaytext": "vGPU100",
"cpunumber": 2,
"cpuspeed": 1600,
"memory": 3072,
},
"nonvgpuoffering":
{
"name": "nonvgpuoffering",
"displaytext": "nonvgpuoffering",
"cpunumber": 2,
"cpuspeed": 1600,
"memory": 3072,
}
},
"diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc', '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1' ],
# Disk device where ISO is attached to instance
"mount_dir": "/mnt/tmp",
"sleep": 90,
"sleep": 180,
"timeout": 60,
"ostype": 'Windows 8 (64-bit)',
"nongpu_host_ip":"10.102.192.57"
},
"acl":{
#data for domains and accounts