CLOUDSTACK-7818: Fixing test_escalations_instances.py, Removing dependency of test cases on each other

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Gaurav Aradhye 2014-10-30 18:05:41 +05:30 committed by SrikanteswaraRao Talluri
parent d4d8326a31
commit 46802557e8

View File

@ -16,17 +16,28 @@
# under the License.
# Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackException import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
from marvin.lib.utils import *
from marvin.lib.base import *
from marvin.lib.common import *
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.lib.utils import cleanup_resources, validateList
from marvin.lib.base import (Account,
ServiceOffering,
NetworkOffering,
Network,
VirtualMachine,
SecurityGroup,
DiskOffering,
Resources,
Iso,
Configurations,
SSHKeyPair,
Volume,
VmSnapshot,
Zone)
from marvin.lib.common import (get_zone,
get_template,
get_domain)
from marvin.codes import PASS
from nose.plugins.attrib import attr
from time import sleep
# from ctypes.wintypes import BOOLEAN
class TestListInstances(cloudstackTestCase):
@ -40,7 +51,9 @@ class TestListInstances(cloudstackTestCase):
cls.hypervisor = cls.testClient.getHypervisorInfo()
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.zone = get_zone(
cls.api_client,
cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@ -48,11 +61,13 @@ class TestListInstances(cloudstackTestCase):
)
if cls.zone.localstorageenabled:
cls.storagetype = 'local'
cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
cls.services["service_offerings"][
"tiny"]["storagetype"] = 'local'
cls.services["disk_offering"]["storagetype"] = 'local'
else:
cls.storagetype = 'shared'
cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
cls.services["service_offerings"][
"tiny"]["storagetype"] = 'shared'
cls.services["disk_offering"]["storagetype"] = 'shared'
cls.services['mode'] = cls.zone.networktype
@ -69,25 +84,6 @@ class TestListInstances(cloudstackTestCase):
cls.api_client,
cls.services["service_offerings"]["tiny"]
)
cls.account = Account.create(
cls.api_client,
cls.services["account"],
domainid=cls.domain.id
)
# Getting authentication for user in newly created Account
cls.user = cls.account.user[0]
cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
# Updating resource Limits
for i in range(0, 12):
Resources.updateLimit(
cls.api_client,
account=cls.account.name,
domainid=cls.domain.id,
max=-1,
resourcetype=i
)
cls._cleanup.append(cls.account)
cls._cleanup.append(cls.service_offering)
cls._cleanup.append(cls.disk_offering)
except Exception as e:
@ -98,7 +94,27 @@ class TestListInstances(cloudstackTestCase):
def setUp(self):
self.apiClient = self.testClient.getApiClient()
self.cleanup = []
self.account = Account.create(
self.apiClient,
self.services["account"],
domainid=self.domain.id
)
# Getting authentication for user in newly created Account
self.user = self.account.user[0]
self.userapiclient = self.testClient.getUserApiClient(
self.user.username,
self.domain.name)
# Updating resource Limits
for i in range(0, 12):
Resources.updateLimit(
self.api_client,
account=self.account.name,
domainid=self.domain.id,
max=-1,
resourcetype=i
)
self.cleanup = [self.account, ]
def tearDown(self):
# Clean up, terminate the created resources
@ -119,10 +135,11 @@ class TestListInstances(cloudstackTestCase):
@Desc: Function to verify expected and actual values
@Steps:
Step1: Initializing return flag to True
Step1: Verifying length of expected and actual dictionaries is matching.
Step1: Verifying length of expected and actual dictionaries is matching
If not matching returning false
Step2: Listing all the keys from expected dictionary
Step3: Looping through each key from step2 and verifying expected and actual dictionaries have same value
Step3: Looping through each key from step2 and verifying expected and
actual dictionaries have same value
If not making return flag to False
Step4: returning the return flag after all the values are verified
"""
@ -139,10 +156,10 @@ class TestListInstances(cloudstackTestCase):
return_flag = return_flag and True
else:
return_flag = return_flag and False
self.debug("expected Value: %s, is not matching with actual value: %s" % (
exp_val,
act_val
))
self.debug(
"expected Value: %s, is not matching with\
actual value: %s" %
(exp_val, act_val))
return return_flag
@attr(tags=["advanced", "basic"], required_hardware="false")
@ -152,11 +169,13 @@ class TestListInstances(cloudstackTestCase):
@Steps:
Step1: Listing all the Instances for a user
Step2: Verifying listed Instances for account created at class level
Step3: If number of volumes is less than (page size + 1), then creating them
Step3: If number of volumes is less than
(page size + 1), then creating them
Step4: Listing all the volumes again after creation of volumes
Step5: Verifying the length of the volumes is (page size + 1)
Step6: Listing all the volumes in page1
Step7: Verifying that the length of the volumes in page 1 is (page size)
Step7: Verifying that the length of the volumes in page 1 is
(page size)
Step8: Listing all the volumes in page2
Step9: Verifying that the length of the volumes in page 2 is 1
Step10: Deleting the volume present in page 2
@ -164,14 +183,17 @@ class TestListInstances(cloudstackTestCase):
Step12: Verifying that there are no volumes present in page 2
"""
# Listing all the instances for a user
list_instances_before = VirtualMachine.list(self.userapiclient, listall=self.services["listall"])
list_instances_before = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"])
# Verifying listed instances for account created at class level
self.assertIsNone(
list_instances_before,
"Virtual Machine already exists for newly created user"
)
# If number of instances are less than (pagesize + 1), then creating them
# If number of instances are less than (pagesize + 1), then creating
# them
for i in range(0, (self.services["pagesize"] + 1)):
vm_created = VirtualMachine.create(
self.userapiclient,
@ -184,17 +206,17 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
if(i < (self.services["pagesize"])):
self.cleanup.append(vm_created)
self.assertEqual(
self.services["virtual_machine"]["displayname"],
vm_created.displayname,
"Newly created VM name and the test data VM name are not matching"
)
"Newly created VM name and the test data VM name\
are not matching")
# Listing all the instances again after creating VM's
list_instances_after = VirtualMachine.list(self.userapiclient, listall=self.services["listall"])
list_instances_after = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"])
status = validateList(list_instances_after)
self.assertEquals(
PASS,
@ -226,8 +248,8 @@ class TestListInstances(cloudstackTestCase):
self.assertEqual(
self.services["pagesize"],
len(list_instances_page1),
"List VM response is not matching with the page size length for page 1"
)
"List VM response is not matching with the page size\
length for page 1")
# Listing all the VM's in page2
list_instances_page2 = VirtualMachine.list(
@ -247,7 +269,8 @@ class TestListInstances(cloudstackTestCase):
self.assertEqual(
1,
len(list_instances_page2),
"List VM response is not matching with the page size length for page 2"
"List VM response is not matching with the\
page size length for page 2"
)
instance_page2 = list_instances_page2[0]
@ -261,7 +284,7 @@ class TestListInstances(cloudstackTestCase):
)
# Deleting a single VM
VirtualMachine.delete(vm_created, self.userapiclient, expunge=True)
VirtualMachine.delete(vm_created, self.apiClient, expunge=True)
# Listing the VM's in page 2
list_instance_response = VirtualMachine.list(
@ -289,7 +312,8 @@ class TestListInstances(cloudstackTestCase):
Step3: Deploying a VM
Step4: Listing all the Running VMs for a user again
Step5: Verifying that the size of the list is increased by 1
Step6: Verifying that the details of the Running VM listed are same as the VM deployed in Step3
Step6: Verifying that the details of the Running VM listed are
same as the VM deployed in Step3
"""
# Listing all the Running VM's for a User
list_running_vms_before = VirtualMachine.list(
@ -316,7 +340,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the Running VM's for a User
list_running_vms_after = VirtualMachine.list(
self.userapiclient,
@ -381,7 +404,8 @@ class TestListInstances(cloudstackTestCase):
Step4: Stopping the VM deployed in step3
Step5: Listing all the Stopped VMs for a user again
Step6: Verifying that the size of the list is increased by 1
Step7: Verifying that the details of the Stopped VM listed are same as the VM stopped in Step4
Step7: Verifying that the details of the Stopped VM listed are
same as the VM stopped in Step4
"""
# Listing all the Stopped VM's for a User
list_stopped_vms_before = VirtualMachine.list(
@ -408,7 +432,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Stopping the VM
VirtualMachine.stop(vm_created, self.userapiclient)
# Listing all the Stopped VM's for a User
@ -476,7 +499,8 @@ class TestListInstances(cloudstackTestCase):
Step6: Verifying that destroyed VM is not listed for User
Step7: Listing all the destroyed VMs as admin
Step8: Verifying that the size of the list is 1
Step9: Verifying that the details of the Destroyed VM listed are same as the VM destroyed in Step4
Step9: Verifying that the details of the Destroyed VM listed
are same as the VM destroyed in Step4
"""
# Listing all the Destroyed VM's for a User
list_destroyed_vms_before = VirtualMachine.list(
@ -489,8 +513,8 @@ class TestListInstances(cloudstackTestCase):
)
self.assertIsNone(
list_destroyed_vms_before,
"Virtual Machine in Destroyed state already exists for newly created user"
)
"Virtual Machine in Destroyed state already exists\
for newly created user")
# Deploying a VM
vm_created = VirtualMachine.create(
self.userapiclient,
@ -582,7 +606,8 @@ class TestListInstances(cloudstackTestCase):
Step4: Listing all the VMs for a user again
Step5: Verifying that the size of the list is increased by 1
Step6: List a VM by specifying the Id if the VM deployed in Step3
Step7: Verifying that the details of the Listed VM are same as the VM deployed in Step3
Step7: Verifying that the details of the Listed VM are same as
the VM deployed in Step3
"""
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
@ -609,7 +634,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VM's for a User
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -683,9 +707,11 @@ class TestListInstances(cloudstackTestCase):
Step3: Deploying a 2 VM's
Step4: Listing all the VMs for a user again
Step5: Verifying that list size is increased by 2
Step6: Listing the VM by specifying complete name of VM-1 created in step3
Step6: Listing the VM by specifying complete name of
VM-1 created in step3
Step7: Verifying that the size of the list is 1
Step8: Verifying that the details of the listed VM are same as the VM-1 created in step3
Step8: Verifying that the details of the listed VM are same as the
VM-1 created in step3
Step9: Listing the VM by specifying the partial name of VM
Step10: Verifying that the size of the list is 2
"""
@ -715,7 +741,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
vms.update({i: vm_created})
# Listing all the VM's for a User
@ -758,7 +783,8 @@ class TestListInstances(cloudstackTestCase):
len(list_vm_byfullname),
"VM list by full name count is not matching"
)
# Verifying that the details of the listed VM are same as the VM created above
# Verifying that the details of the listed VM are same
# as the VM created above
# Creating expected and actual values dictionaries
expected_dict = {
"id": vms[0].id,
@ -818,12 +844,16 @@ class TestListInstances(cloudstackTestCase):
Step3: Deploying a VM
Step4: Listing all the VMs for a user again
Step5: Verifying that list size is increased by 1
Step6: Listing the VM by specifying name of VM created in step3 and state as Running (matching name and state)
Step6: Listing the VM by specifying name of VM created in step3 and
state as Running (matching name and state)
Step7: Verifying that the size of the list is 1
Step8: Verifying that the details of the listed VM are same as the VM created in step3
Step9: Listing the VM by specifying name of VM created in step3 and state as Stopped (non matching state)
Step8: Verifying that the details of the listed VM are same as
the VM created in step3
Step9: Listing the VM by specifying name of VM created in step3
and state as Stopped (non matching state)
Step10: Verifying that the size of the list is 0
Step11: Listing the VM by specifying non matching name and state as Running (non matching name)
Step11: Listing the VM by specifying non matching name and
state as Running (non matching name)
Step12: Verifying that the size of the list is 0
"""
# Listing all the VM's for a User
@ -850,7 +880,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VM's for a User
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -892,7 +921,8 @@ class TestListInstances(cloudstackTestCase):
len(list_running_vm),
"Count of VM list by name and state is not matching"
)
# Verifying that the details of the listed VM are same as the VM created above
# Verifying that the details of the listed VM are same
# as the VM created above
# Creating expected and actual values dictionaries
expected_dict = {
"id": vm_created.id,
@ -966,7 +996,8 @@ class TestListInstances(cloudstackTestCase):
Step6: Deploying a VM
Step7: Listing all the VMs for a user again for matching zone
Step8: Verifying that the size of the list is 1
Step9: Verifying that the details of the Listed VM are same as the VM deployed in Step6
Step9: Verifying that the details of the Listed VM are same
as the VM deployed in Step6
Step10: Listing all the VMs for a user again for non-matching zone
Step11: Verifying that the size of the list is 0
"""
@ -1021,7 +1052,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VMs for a user again for matching zone
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -1044,7 +1074,8 @@ class TestListInstances(cloudstackTestCase):
"VM list count is not matching"
)
listed_vm = list_vms_after[0]
# Verifying that the details of the Listed VM are same as the VM deployed above
# Verifying that the details of the Listed VM are
# same as the VM deployed above
# Creating expected and actual values dictionaries
expected_dict = {
"id": vm_created.id,
@ -1105,12 +1136,16 @@ class TestListInstances(cloudstackTestCase):
Step6: Deploying a VM
Step7: Listing all the VMs for a user again
Step8: Verifying that list size is increased by 1
Step9: Listing the VM by specifying name of VM created in step6 and matching zone (matching name and zone)
Step9: Listing the VM by specifying name of VM created in step6
and matching zone (matching name and zone)
Step10: Verifying that the size of the list is 1
Step11: Verifying that the details of the listed VM are same as the VM created in step3
Step12: Listing the VM by specifying name of VM created in step6 and non matching zone (non matching zone)
Step11: Verifying that the details of the listed VM are same
as the VM created in step3
Step12: Listing the VM by specifying name of VM created in step6
and non matching zone (non matching zone)
Step13: Verifying that the size of the list is 0
Step14: Listing the VM by specifying non matching name and matching zone (non matching name)
Step14: Listing the VM by specifying non matching name and
matching zone (non matching name)
Step15: Verifying that the size of the list is 0
"""
# Listing all the zones available
@ -1165,7 +1200,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VMs for a user again for matching zone
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -1188,7 +1222,8 @@ class TestListInstances(cloudstackTestCase):
len(list_vms_after),
"VM list count is not matching"
)
# Listing the VM by specifying name of VM created in above and matching zone
# Listing the VM by specifying name of VM created in above and
# matching zone
list_vms = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"],
@ -1211,7 +1246,8 @@ class TestListInstances(cloudstackTestCase):
"Count of listed VM's by name and zone is not as expected"
)
listed_vm = list_vms[0]
# Verifying that the details of the Listed VM are same as the VM deployed above
# Verifying that the details of the Listed VM are same
# as the VM deployed above
# Creating expected and actual values dictionaries
expected_dict = {
"id": vm_created.id,
@ -1240,7 +1276,8 @@ class TestListInstances(cloudstackTestCase):
list_vm_status,
"Listed VM by Id details are not as expected"
)
# Listing the VM by specifying name of VM created in step3 and non matching zone
# Listing the VM by specifying name of VM created in step3 and non
# matching zone
list_vms = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"],
@ -1254,7 +1291,8 @@ class TestListInstances(cloudstackTestCase):
list_vms,
"VM's listed for non matching zone"
)
# Listing the VM by specifying non matching name of VM and matching zone
# Listing the VM by specifying non matching name of VM and matching
# zone
list_vms = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"],
@ -1282,14 +1320,18 @@ class TestListInstances(cloudstackTestCase):
Step3: Deploying a VM
Step4: Listing all the VMs for a user again
Step5: Verifying that list size is increased by 1
Step6: Listing the VM by specifying name of VM created in step3 and matching zone and state as Running
Step6: Listing the VM by specifying name of VM created in step3
and matching zone and state as Running
Step7: Verifying that the size of the list is 1
Step8: Verifying that the details of the listed VM are same as the VM created in step3
Step9: Listing the VM by specifying name of VM created in step3 and matching zone and state as Stopped
Step8: Verifying that the details of the listed VM are same
as the VM created in step3
Step9: Listing the VM by specifying name of VM created in step3 and
matching zone and state as Stopped
Step10: Verifying that the size of the list is 0
Step11: Listing the VM by name, Zone and account
Step12: Verifying that the size of the list is 1
Step13: Verifying that the details of the listed VM are same as the VM created in step3
Step13: Verifying that the details of the listed VM are same
as the VM created in step3
"""
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
@ -1317,7 +1359,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VMs for a user again for matching zone
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -1340,7 +1381,8 @@ class TestListInstances(cloudstackTestCase):
len(list_vms_after),
"VM list count is not matching"
)
# Listing the VM by specifying name of VM created in step3 and matching zone and state as Running
# Listing the VM by specifying name of VM created in step3 and matching
# zone and state as Running
list_vms = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"],
@ -1364,7 +1406,8 @@ class TestListInstances(cloudstackTestCase):
"Count of listed VM's by name, zone and state is not as expected"
)
listed_vm = list_vms[0]
# Verifying that the details of the Listed VM are same as the VM deployed above
# Verifying that the details of the Listed VM are same
# as the VM deployed above
# Creating expected and actual values dictionaries
expected_dict = {
"id": vm_created.id,
@ -1393,7 +1436,8 @@ class TestListInstances(cloudstackTestCase):
list_vm_status,
"Listed VM by Id details are not as expected"
)
# Listing the VM by specifying name of VM created in step3, zone and State as Stopped
# Listing the VM by specifying name of VM created in step3, zone and
# State as Stopped
list_vms = VirtualMachine.list(
self.userapiclient,
listall=self.services["listall"],
@ -1432,7 +1476,8 @@ class TestListInstances(cloudstackTestCase):
"Count of listed VM's by name, zone and account is not as expected"
)
listed_vm = list_vms[0]
# Verifying that the details of the Listed VM are same as the VM deployed above
# Verifying that the details of the Listed VM are same
# as the VM deployed above
# Creating expected and actual values dictionaries
expected_dict = {
"id": vm_created.id,
@ -1498,7 +1543,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VMs for a user again
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -1596,8 +1640,10 @@ class TestListInstances(cloudstackTestCase):
@Steps:
Step1: Deploying a VM
Step2: Listing all the existing service offerings
Step3: If there is a matching Service Offering for change service of stopped VM
use that service offering. If not create one service offering for change service.
Step3: If there is a matching Service Offering for
change service of stopped VM
use that service offering. If not create
one service offering for change service.
Step4: Perform change service for the Running VM
Step5: Verifying that change service is not possible for Running VM
"""
@ -1622,7 +1668,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing details of current Service Offering
vm_so_list = ServiceOffering.list(
self.userapiclient,
@ -1661,14 +1706,17 @@ class TestListInstances(cloudstackTestCase):
so_exists = False
if service_offerings_list is not None:
for i in range(0, len(service_offerings_list)):
if ((current_so.id != service_offerings_list[i].id) and\
(current_so.storagetype == service_offerings_list[i].storagetype)):
if ((current_so.id != service_offerings_list[i].id) and (
current_so.storagetype ==
service_offerings_list[i].storagetype)):
so_exists = True
new_so = service_offerings_list[i]
break
# If service offering does not exists, then creating one service offering for scale up
# If service offering does not exists, then creating one service
# offering for scale up
if not so_exists:
self.services["service_offerings"]["small"]["storagetype"] = current_so.storagetype
self.services["service_offerings"]["small"][
"storagetype"] = current_so.storagetype
new_so = ServiceOffering.create(
self.apiClient,
self.services["service_offerings"]["small"]
@ -1720,15 +1768,19 @@ class TestListInstances(cloudstackTestCase):
Step8: Adding the networks created in step4 to VM deployed in step1
Step9: Verifying that VM deployed in step1 has 2 nics
Step10: Verifying that isdefault is set to true for only 1 nic
Step11: Verifying that isdefault is set to true for the Network created when deployed a VM
Step11: Verifying that isdefault is set to true for the Network
created when deployed a VM
Step12: Making the nic created in step4 as default nic
Step13: Verifying that isdefault is set to true for only 1 nic
Step14: Verifying that the isdefault is set to true for the nic created in step4
Step14: Verifying that the isdefault is set to true for the
nic created in step4
Step15: Removing the non-default nic from VM
Step16: Verifying that VM deployed in step1 has only 1 nic
"""
if self.hypervisor.lower() in ['hyperv']:
raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
raise unittest.SkipTest(
"This feature is not supported on existing hypervisor.\
Hence, skipping the test")
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
self.userapiclient,
@ -1750,7 +1802,6 @@ class TestListInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
self.cleanup.append(vm_created)
# Listing all the VMs for a user again
list_vms_after = VirtualMachine.list(
self.userapiclient,
@ -1895,7 +1946,8 @@ class TestListInstances(cloudstackTestCase):
default_count,
"Default NIC count is not matching"
)
# Verifying that default NIC is same the network created when VM is deployed
# Verifying that default NIC is same the network created when VM is
# deployed
self.assertEquals(
network1.id,
default_nic.networkid,
@ -1943,7 +1995,8 @@ class TestListInstances(cloudstackTestCase):
default_count,
"Default NIC count is not matching"
)
# Verifying that default NIC is same the newly updated network (network 2)
# Verifying that default NIC is same the newly updated network (network
# 2)
self.assertEquals(
network2.id,
default_nic.networkid,
@ -1985,6 +2038,7 @@ class TestListInstances(cloudstackTestCase):
)
return
class TestInstances(cloudstackTestCase):
@classmethod
@ -1997,7 +2051,9 @@ class TestInstances(cloudstackTestCase):
cls.hypervisor = cls.testClient.getHypervisorInfo()
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.zone = get_zone(
cls.api_client,
cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@ -2005,11 +2061,13 @@ class TestInstances(cloudstackTestCase):
)
if cls.zone.localstorageenabled:
cls.storagetype = 'local'
cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
cls.services["service_offerings"][
"tiny"]["storagetype"] = 'local'
cls.services["disk_offering"]["storagetype"] = 'local'
else:
cls.storagetype = 'shared'
cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
cls.services["service_offerings"][
"tiny"]["storagetype"] = 'shared'
cls.services["disk_offering"]["storagetype"] = 'shared'
cls.services['mode'] = cls.zone.networktype
@ -2034,7 +2092,9 @@ class TestInstances(cloudstackTestCase):
)
# Getting authentication for user in newly created Account
cls.user = cls.account.user[0]
cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
cls.userapiclient = cls.testClient.getUserApiClient(
cls.user.username,
cls.domain.name)
# Updating resource Limits
for i in range(0, 8):
Resources.updateLimit(
@ -2079,10 +2139,12 @@ class TestInstances(cloudstackTestCase):
@Desc: Function to verify expected and actual values
@Steps:
Step1: Initializing return flag to True
Step1: Verifying length of expected and actual dictionaries is matching.
Step1: Verifying length of expected and actual
dictionaries is matching.
If not matching returning false
Step2: Listing all the keys from expected dictionary
Step3: Looping through each key from step2 and verifying expected and actual dictionaries have same value
Step3: Looping through each key from step2 and verifying expected
and actual dictionaries have same value
If not making return flag to False
Step4: returning the return flag after all the values are verified
"""
@ -2099,10 +2161,10 @@ class TestInstances(cloudstackTestCase):
return_flag = return_flag and True
else:
return_flag = return_flag and False
self.debug("expected Value: %s, is not matching with actual value: %s" % (
exp_val,
act_val
))
self.debug(
"expected Value: %s, is not matching\
with actual value: %s" %
(exp_val, act_val))
return return_flag
@attr(tags=["advanced", "basic"], required_hardware="true")
@ -2123,7 +2185,9 @@ class TestInstances(cloudstackTestCase):
Step11: Verifying that detached ISO details are not associated with VM
"""
if self.hypervisor.lower() in ['kvm', 'hyperv']:
raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
raise unittest.SkipTest(
"This feature is not supported on existing hypervisor. Hence,\
skipping the test")
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
self.userapiclient,
@ -2231,7 +2295,8 @@ class TestInstances(cloudstackTestCase):
"ISO not detached from VM"
)
else:
self.fail("Executable ISO in Ready is not found in the given setup")
self.fail(
"Executable ISO in Ready is not found in the given setup")
return
@ -2255,7 +2320,9 @@ class TestInstances(cloudstackTestCase):
Step13: Verifying that size of the list is 0
"""
if self.hypervisor.lower() in ['kvm', 'hyperv']:
raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
raise unittest.SkipTest(
"This feature is not supported on existing hypervisor. Hence,\
skipping the test")
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
self.userapiclient,
@ -2406,13 +2473,19 @@ class TestInstances(cloudstackTestCase):
Step5: Listing all the Snapshots of the VM deployed in Step 1
Step6: Verifying that the list size is 2
Step7: Verifying that only 1 snapshot is have current flag set to True
Step8: Verifying that the VM snapshot with current flag set as true is the latest snapshot created
Step9: Reverting VM to snapshot having current flag as false (non current snapshot)
Step10: Verifying that only 1 VM snapshot is having current flag set as true.
Step11: Verifying that the VM Snapshot with current flag set to true is the reverted snapshot in Step 8
Step8: Verifying that the VM snapshot with current flag set as true is
the latest snapshot created
Step9: Reverting VM to snapshot having current flag as false
(non current snapshot)
Step10: Verifying that only 1 VM snapshot is having current
flag set as true.
Step11: Verifying that the VM Snapshot with current flag set to true
is the reverted snapshot in Step 8
"""
if self.hypervisor.lower() in ['kvm', 'hyperv']:
raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
raise unittest.SkipTest(
"This feature is not supported on existing hypervisor.\
Hence, skipping the test")
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
self.userapiclient,
@ -2565,7 +2638,8 @@ class TestInstances(cloudstackTestCase):
Step2: Listing all the Volumes of the VM deployed in Step 1
Step3: Verifying that the list size is 1
Step4: Creating page size number of volumes
Step5: Attaching all the volumes created in step4 to VM deployed in Step1
Step5: Attaching all the volumes created in step4 to
VM deployed in Step1
Step6: Listing all the Volumes for the VM in step1
Step7: Verifying that the list size is equal to page size + 1
Step8: Listing all the volumes of VM in page 1
@ -2766,18 +2840,24 @@ class TestInstances(cloudstackTestCase):
"""
@Desc: Test to verify change service for Running VM
@Steps:
Step1: Checking if dynamic scaling of virtual machines is enabled in zone and template.
Step1: Checking if dynamic scaling of virtual machines is
enabled in zone and template.
If yes then continuing.
If not then printing message that scale up is not possible for Running VM
If not then printing message that scale up is
not possible for Running VM
Step2: Deploying a VM
Step3: Listing all the existing service offerings
Step4: If there is a matching Service Offering for scale-up of running VM
use that service offering. If not create one service offering for scale up.
Step5: Perform change service (scale up) the Running VM deployed in step1
Step4: If there is a matching Service Offering for scale-up of
running VM
use that service offering. If not create one
service offering for scale up.
Step5: Perform change service (scale up) the Running VM
deployed in step1
Step6: Verifying that VM's service offerings is changed
"""
if self.hypervisor.lower() == 'kvm':
raise unittest.SkipTest("ScaleVM is not supported on KVM. Hence, skipping the test")
raise unittest.SkipTest(
"ScaleVM is not supported on KVM. Hence, skipping the test")
# Checking if Dynamic scaling of VM is supported or not
list_config = Configurations.list(
self.apiClient,
@ -2791,8 +2871,12 @@ class TestInstances(cloudstackTestCase):
"Listing of configuration failed"
)
# Checking if dynamic scaling is allowed in Zone and Template
if not ((list_config[0].value is True) and (self.template.isdynamicallyscalable)):
self.debug("Scale up of Running VM is not possible as Zone/Template does not support")
if not (
(list_config[0].value is True) and (
self.template.isdynamicallyscalable)):
self.debug(
"Scale up of Running VM is not possible as Zone/Template\
does not support")
else:
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
@ -2854,19 +2938,28 @@ class TestInstances(cloudstackTestCase):
so_exists = False
if service_offerings_list is not None:
for i in range(0, len(service_offerings_list)):
if not ((current_so.cpunumber > service_offerings_list[i].cpunumber or\
current_so.cpuspeed > service_offerings_list[i].cpuspeed or\
current_so.memory > service_offerings_list[i].memory) or\
(current_so.cpunumber == service_offerings_list[i].cpunumber and\
current_so.cpuspeed == service_offerings_list[i].cpuspeed and\
current_so.memory == service_offerings_list[i].memory)):
if(current_so.storagetype == service_offerings_list[i].storagetype):
if not ((current_so.cpunumber >
service_offerings_list[i].cpunumber or
current_so.cpuspeed >
service_offerings_list[i].cpuspeed or
current_so.memory >
service_offerings_list[i].memory) or
(current_so.cpunumber ==
service_offerings_list[i].cpunumber and
current_so.cpuspeed ==
service_offerings_list[i].cpuspeed and
current_so.memory ==
service_offerings_list[i].memory)):
if(current_so.storagetype ==
service_offerings_list[i].storagetype):
so_exists = True
new_so = service_offerings_list[i]
break
# If service offering does not exists, then creating one service offering for scale up
# If service offering does not exists, then creating one service
# offering for scale up
if not so_exists:
self.services["service_offerings"]["small"]["storagetype"] = current_so.storagetype
self.services["service_offerings"]["small"][
"storagetype"] = current_so.storagetype
new_so = ServiceOffering.create(
self.apiClient,
self.services["service_offerings"]["small"]
@ -2909,8 +3002,10 @@ class TestInstances(cloudstackTestCase):
Step1: Deploying a VM
Step2: Stopping the VM deployed in step1
Step3: Listing all the existing service offerings
Step4: If there is a matching Service Offering for change service of stopped VM
use that service offering. If not create one service offering for change service.
Step4: If there is a matching Service Offering for change service
of stopped VM
use that service offering. If not create one service
offering for change service.
Step5: Perform change service for the Stopped VM
Step6: Verifying that VM's service offerings is changed
"""
@ -2979,14 +3074,17 @@ class TestInstances(cloudstackTestCase):
so_exists = False
if service_offerings_list is not None:
for i in range(0, len(service_offerings_list)):
if ((current_so.id != service_offerings_list[i].id) and\
(current_so.storagetype == service_offerings_list[i].storagetype)):
if ((current_so.id != service_offerings_list[i].id) and (
current_so.storagetype ==
service_offerings_list[i].storagetype)):
so_exists = True
new_so = service_offerings_list[i]
break
# If service offering does not exists, then creating one service offering for scale up
# If service offering does not exists, then creating one service
# offering for scale up
if not so_exists:
self.services["service_offerings"]["small"]["storagetype"] = current_so.storagetype
self.services["service_offerings"]["small"][
"storagetype"] = current_so.storagetype
new_so = ServiceOffering.create(
self.apiClient,
self.services["service_offerings"]["small"]
@ -3259,7 +3357,8 @@ class TestInstances(cloudstackTestCase):
Step3: Listing all the VM's again for the user
Step4: Verifying that list size is increased by 1
Step5: Restoring the VM deployed in step2
Step6: Verifying that restored VM details are same as the VM deployed in step2
Step6: Verifying that restored VM details are same as
the VM deployed in step2
"""
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
@ -3342,7 +3441,8 @@ class TestInstances(cloudstackTestCase):
@Desc: Test to verify deploy VM with multiple networks
@Steps:
Step1: List all the networks for user
Step2: If size of list networks is greater than 2 then get all the networks id's
Step2: If size of list networks is greater than 2 then
get all the networks id's
Else create 2 networks and get network id's
Step3: List all the VM's for a user
Step4: Deploy a VM with multiple network id's
@ -3405,7 +3505,8 @@ class TestInstances(cloudstackTestCase):
"Listing networks failed"
)
# populating network id's
networkids = networks_list_after[0].id + "," + networks_list_after[1].id
networkids = networks_list_after[
0].id + "," + networks_list_after[1].id
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
self.userapiclient,
@ -3476,7 +3577,8 @@ class TestInstances(cloudstackTestCase):
@Desc: Test to verify deploy VM with multiple Security Groups
@Steps:
Step1: List all the security groups for user
Step2: If size of list security groups is greater than 2 then get all the security groups id's
Step2: If size of list security groups is greater than 2 then get
all the security groups id's
Else creating 2 security groups and get security groups id's
Step3: List all the VM's for a user
Step4: Deploy a VM with multiple security groups id's
@ -3522,7 +3624,9 @@ class TestInstances(cloudstackTestCase):
"Listing Security Groups failed"
)
# populating Security Groups id's
securitygroupids = {security_groups_list[0].id , security_groups_list[1].id}
securitygroupids = {
security_groups_list[0].id,
security_groups_list[1].id}
# Listing all the VM's for a User
list_vms_before = VirtualMachine.list(
self.userapiclient,
@ -3563,7 +3667,8 @@ class TestInstances(cloudstackTestCase):
len(list_vms_after),
"VM list count is not matching"
)
# Verifying that the Security Groups's in VM created are same as provided
# Verifying that the Security Groups's in VM created are same as
# provided
vm_securitygroups = vm_created.securitygroup
# Verifying that the size of security groups is 2
self.assertEquals(
@ -3574,7 +3679,7 @@ class TestInstances(cloudstackTestCase):
# Verifying that Security Group network ID's are as expected
vm_securitygroups_flag = True
for i in range(0, len(vm_securitygroups)):
if ((vm_securitygroups[i].id != security_groups_list[0].id) and\
if ((vm_securitygroups[i].id != security_groups_list[0].id) and
(vm_securitygroups[i].id != security_groups_list[1].id)):
vm_securitygroups_flag = False
break
@ -3698,13 +3803,17 @@ class TestInstances(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="false")
def test_25_ip_reallocation_ES1377(self):
"""
@Desc: Test to verify dnsmasq dhcp conflict issue due to /ect/hosts not getting udpated
@Desc: Test to verify dnsmasq dhcp conflict issue due to
/ect/hosts not getting udpated
@Steps:
Step1: Create a network for the user
Step2: List the network and check that it is created for the user
Step3: Deploy vm1 with hostname hostA and ip address IP A in the above network
Step4: List the vm and verify the ip address in the response and verify ssh access to vm
Step5: Deploy vm2 with hostname hostB and ip address IP B in the same network
Step3: Deploy vm1 with hostname hostA and ip address IP A in the
above network
Step4: List the vm and verify the ip address in the response and
verify ssh access to vm
Step5: Deploy vm2 with hostname hostB and ip address IP B in the
same network
Step6: Repeat step4
Step7: Destroy vm1 and vm2
Step8: Deploy vm3 with hostname hostA and ip address IP B
@ -3765,9 +3874,8 @@ class TestInstances(cloudstackTestCase):
mode="advanced",
)
self.assertIsNotNone(
vm1,
"VM1 creation failed with ip address %s and host name %s" % (vm_ip1, name1)
)
vm1, "VM1 creation failed with ip address %s and host name %s" %
(vm_ip1, name1))
# self.cleanup.append(vm_created)
self.cleanup.append(network)
# Listing all the VMs for a user again
@ -3827,9 +3935,10 @@ class TestInstances(cloudstackTestCase):
except Exception as e:
raise Exception("Warning: Exception in expunging vms : %s" % e)
"""
Deploy vm3 with ip address of vm1 and host name of vm2 so both the vm1 and vm2 entries
would be deleted from dhcphosts file on VR becase dhcprelease matches entries with
host name and ip address so it matches both the entries.
Deploy vm3 with ip address of vm1 and host name of vm2 so both the vm1
and vm2 entries would be deleted from dhcphosts file on VR becase
dhcprelease matches entries with host name and ip address so it
matches both the entries.
"""
# Deploying a VM
self.services["virtual_machine"]["name"] = name2
@ -3865,8 +3974,9 @@ class TestInstances(cloudstackTestCase):
)
# Deploying a VM
"""
Deploy vm4 with ip address of vm2. dnsmasq and dhcprelase should be in sync.
We should not see dhcp lease block due to IP reallocation.
Deploy vm4 with ip address of vm2. dnsmasq and dhcprelase
should be in sync. We should not see dhcp lease block due to IP
reallocation.
"""
name3 = "hostC"
self.services["virtual_machine"]["name"] = name3
@ -3904,5 +4014,7 @@ class TestInstances(cloudstackTestCase):
vm3.delete(self.apiClient, expunge=True)
vm4.delete(self.apiClient, expunge=True)
except Exception as e:
raise Exception("Warning: Exception in expunging vms vm3 and vm4 : %s" % e)
raise Exception(
"Warning: Exception in expunging vms vm3 and vm4 : %s" %
e)
return