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:
Gaurav Aradhye 2014-12-05 14:15:24 +05:30 committed by SrikanteswaraRao Talluri
parent 18b230db74
commit ca52f15530
3 changed files with 1340 additions and 989 deletions

File diff suppressed because it is too large Load Diff

View File

@ -97,7 +97,8 @@ class TestPersistentNetworks(cloudstackTestCase):
cls.isolated_network_offering_netscaler = cls.createNetworkOffering( cls.isolated_network_offering_netscaler = cls.createNetworkOffering(
"nw_off_isolated_netscaler") "nw_off_isolated_netscaler")
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] = False cls.services["configurableData"]["netscaler"]["lbdevicededicated"] =\
False
# Configure Netscaler device # Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that # If configuration succeeds, set ns_configured to True so that
@ -172,9 +173,9 @@ class TestPersistentNetworks(cloudstackTestCase):
try: try:
sshClient = SshClient( sshClient = SshClient(
host=sourceip, host=sourceip,
port=22, port=self.services['configurableData']['host']["publicport"],
user='root', user=self.services['configurableData']['host']["username"],
passwd=self.services["host_password"]) passwd=self.services['configurableData']['host']["password"])
res = sshClient.execute("ping -c 1 %s" % ( res = sshClient.execute("ping -c 1 %s" % (
router.linklocalip router.linklocalip
)) ))
@ -1502,7 +1503,8 @@ class TestAssignVirtualMachine(cloudstackTestCase):
cls.persistent_network_offering_netscaler = cls.createNetworkOffering( cls.persistent_network_offering_netscaler = cls.createNetworkOffering(
"nw_off_isolated_persistent_netscaler") "nw_off_isolated_persistent_netscaler")
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] = False cls.services["configurableData"]["netscaler"]["lbdevicededicated"] =\
False
# Configure Netscaler device # Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that # If configuration succeeds, set ns_configured to True so that
@ -1968,7 +1970,8 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
cls.api_client, cls.api_client,
state="enabled") state="enabled")
cls.services["configurableData"]["netscaler"]["lbdevicededicated"] = False cls.services["configurableData"]["netscaler"]["lbdevicededicated"] =\
False
# Configure Netscaler device # Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that # If configuration succeeds, set ns_configured to True so that
@ -2039,9 +2042,9 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
try: try:
sshClient = SshClient( sshClient = SshClient(
host=sourceip, host=sourceip,
port=22, port=self.services['configurableData']['host']["publicport"],
user='root', user=self.services['configurableData']['host']["username"],
passwd=self.services["host_password"]) passwd=self.services['configurableData']['host']["password"])
res = sshClient.execute("ping -c 1 %s" % ( res = sshClient.execute("ping -c 1 %s" % (
router.linklocalip router.linklocalip
)) ))

View File

@ -15,29 +15,32 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # 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 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 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 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.lib.common import get_zone, get_domain, get_template, list_hosts
from marvin.sshClient import SshClient from marvin.sshClient import SshClient
from marvin.codes import FAILED, XEN_SERVER from marvin.codes import FAILED
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
class TestDeployvGPUenabledVM(cloudstackTestCase): class TestDeployvGPUenabledVM(cloudstackTestCase):
""" """
Test deploy a vGPU enabled VM into a user account Test deploy a vGPU enabled VM into a user account
""" """
@ -46,33 +49,42 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient() testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient()
self.apiclient = testClient.getApiClient() self.apiclient = testClient.getApiClient()
self.testdata = self.testClient.getParsedTestDataConfig() 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( hosts = list_hosts(
self.apiclient, self.apiclient,
hypervisor="XenServer" hypervisor="XenServer"
) )
if hosts is None: if hosts is None:
raise unittest.SkipTest("There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response") raise unittest.SkipTest(
"There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
else: else:
gpuhosts=0 gpuhosts = 0
for ghost in hosts : for ghost in hosts:
if ghost.hypervisorversion >= "6.2.0": if ghost.hypervisorversion >= "6.2.0":
sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd=self.testdata["host_password"]) 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": if ghost.hypervisorversion == "6.2.0":
res = sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503") res = sshClient.execute(
"xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
if len(res) == 0: if len(res) == 0:
continue continue
res = sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\"") res = sshClient.execute(
if len(res) != 0 : "xe vgpu-type-list model-name=\"GRID K120Q\"")
gpuhosts=gpuhosts+1 if len(res) != 0:
gpuhosts = gpuhosts + 1
else: else:
continue continue
if gpuhosts == 0: 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.domain = get_domain(self.apiclient)
self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
#Creating Account # Creating Account
self.account = Account.create( self.account = Account.create(
self.apiclient, self.apiclient,
self.testdata["account"], self.testdata["account"],
@ -81,6 +93,7 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
self._cleanup = [ self._cleanup = [
self.account self.account
] ]
def setUp(self): def setUp(self):
self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"] self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"]
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -89,12 +102,17 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
self.domain = get_domain(self.apiclient) self.domain = get_domain(self.apiclient)
self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.testdata["mode"] = self.zone.networktype self.testdata["mode"] = self.zone.networktype
# Before running this test, register a windows template with ostype as 'Windows 7 (32-bit)' # Before running this test, register a windows template with ostype as
self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) # 'Windows 7 (32-bit)'
self.template = get_template(
self.apiclient,
self.zone.id,
self.testdata["ostype"])
if self.template == FAILED: if self.template == FAILED:
assert False, "get_template() failed to return template with description %s" % self.testdata["ostype"] assert False, "get_template() failed to return template with description %s" % self.testdata[
#create a user account "ostype"]
# create a user account
self.account = Account.create( self.account = Account.create(
self.apiclient, self.apiclient,
self.testdata["account"], self.testdata["account"],
@ -106,20 +124,22 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
self.testdata["vgpu140q"]["zoneid"] = self.zone.id self.testdata["vgpu140q"]["zoneid"] = self.zone.id
self.testdata["vgpu140q"]["template"] = self.template.id self.testdata["vgpu140q"]["template"] = self.template.id
self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [{'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, self.testdata["service_offerings"]["vgpu260qwin"]["serviceofferingdetails"] = [
{'vgpuType':'GRID K120Q'}] {
#create a service offering 'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, {
'vgpuType': 'GRID K120Q'}]
# create a service offering
self.service_offering = ServiceOffering.create( self.service_offering = ServiceOffering.create(
self.apiclient, self.apiclient,
self.testdata["service_offerings"]["vgpu260qwin"], self.testdata["service_offerings"]["vgpu260qwin"],
) )
#build cleanup list # build cleanup list
self.cleanup = [ self.cleanup = [
self.service_offering, self.service_offering,
self.account 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): def test_deploy_vgpu_enabled_vm(self):
"""Test Deploy Virtual Machine """Test Deploy Virtual Machine
@ -137,10 +157,12 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
mode=self.testdata['mode'] 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( self.debug(
"Verify listVirtualMachines response for virtual machine: %s"\ "Verify listVirtualMachines response for virtual machine: %s"
% self.virtual_machine.id % self.virtual_machine.id
) )
@ -177,13 +199,17 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
) )
hostip = hosts[0].ipaddress hostip = hosts[0].ipaddress
try: try:
sshClient = SshClient(host=hostip, port=22, user='root',passwd=self.testdata["host_password"]) sshClient = SshClient(
res = sshClient.execute("xe vgpu-list vm-name-label=%s params=type-uuid %s" % ( host=hostip,
vm.instancename 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) self.debug("SSH result: %s" % res)
except Exception as e: except Exception as e:
self.fail("SSH Access failed for %s: %s" % \ self.fail("SSH Access failed for %s: %s" %
(hostip, e) (hostip, e)
) )
result = str(res) result = str(res)