mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8021: Change test cases to use host information from configurableData section in test_data.py
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
parent
18b230db74
commit
ca52f15530
File diff suppressed because it is too large
Load Diff
@ -97,7 +97,8 @@ class TestPersistentNetworks(cloudstackTestCase):
|
||||
cls.isolated_network_offering_netscaler = cls.createNetworkOffering(
|
||||
"nw_off_isolated_netscaler")
|
||||
|
||||
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] = False
|
||||
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] =\
|
||||
False
|
||||
|
||||
# Configure Netscaler device
|
||||
# If configuration succeeds, set ns_configured to True so that
|
||||
@ -172,9 +173,9 @@ class TestPersistentNetworks(cloudstackTestCase):
|
||||
try:
|
||||
sshClient = SshClient(
|
||||
host=sourceip,
|
||||
port=22,
|
||||
user='root',
|
||||
passwd=self.services["host_password"])
|
||||
port=self.services['configurableData']['host']["publicport"],
|
||||
user=self.services['configurableData']['host']["username"],
|
||||
passwd=self.services['configurableData']['host']["password"])
|
||||
res = sshClient.execute("ping -c 1 %s" % (
|
||||
router.linklocalip
|
||||
))
|
||||
@ -1502,7 +1503,8 @@ class TestAssignVirtualMachine(cloudstackTestCase):
|
||||
cls.persistent_network_offering_netscaler = cls.createNetworkOffering(
|
||||
"nw_off_isolated_persistent_netscaler")
|
||||
|
||||
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] = False
|
||||
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] =\
|
||||
False
|
||||
|
||||
# Configure Netscaler device
|
||||
# If configuration succeeds, set ns_configured to True so that
|
||||
@ -1968,7 +1970,8 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
|
||||
cls.api_client,
|
||||
state="enabled")
|
||||
|
||||
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] = False
|
||||
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] =\
|
||||
False
|
||||
|
||||
# Configure Netscaler device
|
||||
# If configuration succeeds, set ns_configured to True so that
|
||||
@ -2039,9 +2042,9 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
|
||||
try:
|
||||
sshClient = SshClient(
|
||||
host=sourceip,
|
||||
port=22,
|
||||
user='root',
|
||||
passwd=self.services["host_password"])
|
||||
port=self.services['configurableData']['host']["publicport"],
|
||||
user=self.services['configurableData']['host']["username"],
|
||||
passwd=self.services['configurableData']['host']["password"])
|
||||
res = sshClient.execute("ping -c 1 %s" % (
|
||||
router.linklocalip
|
||||
))
|
||||
|
||||
@ -15,29 +15,32 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#Test from the Marvin - Testing in Python wiki
|
||||
# Test from the Marvin - Testing in Python wiki
|
||||
|
||||
#All tests inherit from cloudstackTestCase
|
||||
# All tests inherit from cloudstackTestCase
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
|
||||
|
||||
#Import Integration Libraries
|
||||
# Import Integration Libraries
|
||||
|
||||
#base - contains all resources as entities and defines create, delete, list operations on them
|
||||
# base - contains all resources as entities and defines create, delete,
|
||||
# list operations on them
|
||||
from marvin.lib.base import Account, VirtualMachine, ServiceOffering
|
||||
|
||||
#utils - utility classes for common cleanup, external library wrappers etc
|
||||
# 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
|
||||
# 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, XEN_SERVER
|
||||
from marvin.codes import FAILED
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
|
||||
class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
|
||||
"""
|
||||
Test deploy a vGPU enabled VM into a user account
|
||||
"""
|
||||
@ -46,41 +49,51 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient()
|
||||
self.apiclient = testClient.getApiClient()
|
||||
self.testdata = self.testClient.getParsedTestDataConfig()
|
||||
#Need to add check whether zone containing the xen hypervisor or not as well
|
||||
# Need to add check whether zone containing the xen hypervisor or not
|
||||
# as well
|
||||
hosts = list_hosts(
|
||||
self.apiclient,
|
||||
hypervisor="XenServer"
|
||||
)
|
||||
self.apiclient,
|
||||
hypervisor="XenServer"
|
||||
)
|
||||
if hosts is None:
|
||||
raise unittest.SkipTest("There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
|
||||
else:
|
||||
gpuhosts=0
|
||||
for ghost in hosts :
|
||||
if ghost.hypervisorversion >= "6.2.0":
|
||||
sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
|
||||
if ghost.hypervisorversion == "6.2.0":
|
||||
res = sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
|
||||
if len(res) == 0:
|
||||
continue
|
||||
res = sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\"")
|
||||
if len(res) != 0 :
|
||||
gpuhosts=gpuhosts+1
|
||||
else:
|
||||
continue
|
||||
raise unittest.SkipTest(
|
||||
"There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
|
||||
else:
|
||||
gpuhosts = 0
|
||||
for ghost in hosts:
|
||||
if ghost.hypervisorversion >= "6.2.0":
|
||||
sshClient = SshClient(
|
||||
host=ghost.ipaddress,
|
||||
port=self.testdata['configurableData']['host']["publicport"],
|
||||
user=self.testdata['configurableData']['host']["username"],
|
||||
passwd=self.testdata['configurableData']['host']["password"])
|
||||
if ghost.hypervisorversion == "6.2.0":
|
||||
res = sshClient.execute(
|
||||
"xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
|
||||
if len(res) == 0:
|
||||
continue
|
||||
res = sshClient.execute(
|
||||
"xe vgpu-type-list model-name=\"GRID K120Q\"")
|
||||
if len(res) != 0:
|
||||
gpuhosts = gpuhosts + 1
|
||||
else:
|
||||
continue
|
||||
if gpuhosts == 0:
|
||||
raise unittest.SkipTest("No XenServer available with GPU Drivers installed")
|
||||
raise unittest.SkipTest(
|
||||
"No XenServer available with GPU Drivers installed")
|
||||
|
||||
self.domain = get_domain(self.apiclient)
|
||||
self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
|
||||
#Creating Account
|
||||
# Creating Account
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.testdata["account"],
|
||||
domainid=self.domain.id
|
||||
)
|
||||
)
|
||||
self._cleanup = [
|
||||
self.account
|
||||
]
|
||||
self.account
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"]
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
@ -89,12 +102,17 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
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.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
|
||||
# Before running this test, register a windows template with ostype as
|
||||
# 'Windows 7 (32-bit)'
|
||||
self.template = get_template(
|
||||
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
|
||||
assert False, "get_template() failed to return template with description %s" % self.testdata[
|
||||
"ostype"]
|
||||
# create a user account
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.testdata["account"],
|
||||
@ -106,20 +124,22 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
|
||||
self.testdata["vgpu140q"]["zoneid"] = self.zone.id
|
||||
self.testdata["vgpu140q"]["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.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"],
|
||||
self.apiclient,
|
||||
self.testdata["service_offerings"]["vgpu260qwin"],
|
||||
)
|
||||
#build cleanup list
|
||||
# build cleanup list
|
||||
self.cleanup = [
|
||||
self.service_offering,
|
||||
self.account
|
||||
]
|
||||
|
||||
@attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
|
||||
@attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
|
||||
def test_deploy_vgpu_enabled_vm(self):
|
||||
"""Test Deploy Virtual Machine
|
||||
|
||||
@ -137,10 +157,12 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
mode=self.testdata['mode']
|
||||
)
|
||||
|
||||
list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)
|
||||
list_vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=self.virtual_machine.id)
|
||||
|
||||
self.debug(
|
||||
"Verify listVirtualMachines response for virtual machine: %s"\
|
||||
"Verify listVirtualMachines response for virtual machine: %s"
|
||||
% self.virtual_machine.id
|
||||
)
|
||||
|
||||
@ -172,26 +194,30 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
msg="VM is not in Running state"
|
||||
)
|
||||
hosts = list_hosts(
|
||||
self.apiclient,
|
||||
id=vm.hostid
|
||||
)
|
||||
self.apiclient,
|
||||
id=vm.hostid
|
||||
)
|
||||
hostip = hosts[0].ipaddress
|
||||
try:
|
||||
sshClient = SshClient(host=hostip, port=22, user='root',passwd=self.testdata["host_password"])
|
||||
res = sshClient.execute("xe vgpu-list vm-name-label=%s params=type-uuid %s" % (
|
||||
vm.instancename
|
||||
))
|
||||
sshClient = SshClient(
|
||||
host=hostip,
|
||||
port=self.testdata['configurableData']['host']["publicport"],
|
||||
user=self.testdata['configurableData']['host']["username"],
|
||||
passwd=self.testdata['configurableData']['host']["password"])
|
||||
res = sshClient.execute(
|
||||
"xe vgpu-list vm-name-label=%s params=type-uuid %s" %
|
||||
(vm.instancename))
|
||||
self.debug("SSH result: %s" % res)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
self.fail("SSH Access failed for %s: %s" %
|
||||
(hostip, e)
|
||||
)
|
||||
result = str(res)
|
||||
self.assertEqual(
|
||||
result.count("type-uuid"),
|
||||
1,
|
||||
"VM is vGPU enabled."
|
||||
)
|
||||
result.count("type-uuid"),
|
||||
1,
|
||||
"VM is vGPU enabled."
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user