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