Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions test/integration/smoke/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def test_01_create_account(self):
account=account.name,
domainid=account.domainid
)
self.cleanup.append(user)
self.debug("Created user: %s" % user.id)
list_users_response = list_users(
self.apiclient,
Expand Down Expand Up @@ -324,20 +325,20 @@ def setUpClass(cls):
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls._cleanup = []

cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
)
cls._cleanup.append(cls.service_offering)
# Create an account
cls.account = Account.create(
cls.api_client,
cls.services["account"]
)
cls._cleanup.append(cls.account)

cls._cleanup = [cls.account,
cls.service_offering,
]
return

@classmethod
Expand Down Expand Up @@ -380,6 +381,7 @@ def test_01_user_remove_VM_running(self):
domainid=self.account.domainid
)
self.debug("Created user: %s" % user_1.id)
self.cleanup.append(user_1)

user_2 = User.create(
self.apiclient,
Expand Down Expand Up @@ -419,6 +421,7 @@ def test_01_user_remove_VM_running(self):
# Remove one of the user
self.debug("Deleting user: %s" % user_1.id)
user_1.delete(self.apiclient)
self.cleanup.remove(user_1)

# Account should exist after deleting user
accounts_response = list_accounts(
Expand Down Expand Up @@ -991,6 +994,7 @@ def setUpClass(cls):
domainid=cls.account_1.domainid,
serviceofferingid=cls.service_offering.id
)
cls._cleanup.append(cls.vm_1)

cls.vm_2 = VirtualMachine.create(
cls.api_client,
Expand All @@ -1000,6 +1004,7 @@ def setUpClass(cls):
domainid=cls.account_2.domainid,
serviceofferingid=cls.service_offering.id
)
cls._cleanup.append(cls.vm_2)
return

@classmethod
Expand Down Expand Up @@ -1812,6 +1817,7 @@ def test_forceDeleteDomain(self):
self.services["domain"],
parentdomainid=self.domain.id
)
self.cleanup.append(domain)
self.debug("Domain is created succesfully.")
self.debug(
"Checking if the created domain is listed in list domains API")
Expand All @@ -1828,20 +1834,25 @@ def test_forceDeleteDomain(self):
self.services["account"],
domainid=domain.id
)
self.cleanup.append(self.account_1)

self.account_2 = Account.create(
self.apiclient,
self.services["account"],
domainid=domain.id
)
self.cleanup.append(self.account_2)

vm_1 = None
vm_2 = None
try:
self.debug("Creating a tiny service offering for VM deployment")
self.service_offering = ServiceOffering.create(
self.apiclient,
self.services["service_offering"],
domainid=self.domain.id
)
self.cleanup.append(self.service_offering)

self.debug("Deploying virtual machine in account 1: %s" %
self.account_1.name)
Expand All @@ -1853,17 +1864,19 @@ def test_forceDeleteDomain(self):
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(vm_1)

self.debug("Deploying virtual machine in account 2: %s" %
self.account_2.name)
VirtualMachine.create(
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(vm_2)

networks = Network.list(
self.apiclient,
Expand Down Expand Up @@ -1927,15 +1940,16 @@ def test_forceDeleteDomain(self):
"Length of response from listLbRules should not be 0"
)
except Exception as e:
self.cleanup.append(self.domain)
self.cleanup.append(self.account_1)
self.cleanup.append(self.account_2)
self.cleanup.append(self.service_offering)
self.fail(e)

self.debug("Deleting domain with force option")
try:
domain.delete(self.apiclient, cleanup=True)
self.cleanup.remove(domain)
if vm_1 != None:
self.cleanup.remove(vm_1)
if vm_2 != None:
self.cleanup.remove(vm_2)
except Exception as e:
self.debug("Waiting for account.cleanup.interval" +
" to cleanup any remaining resouces")
Expand Down Expand Up @@ -2033,17 +2047,19 @@ def test_DeleteDomain(self):
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(vm_1)

self.debug("Deploying virtual machine in account 2: %s" %
self.account_2.name)
VirtualMachine.create(
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(vm_2)

networks = Network.list(
self.apiclient,
Expand Down Expand Up @@ -2110,6 +2126,7 @@ def test_DeleteDomain(self):
self.debug("Deleting domain without force option")
with self.assertRaises(Exception):
domain.delete(self.apiclient, cleanup=False)
# TODO should domain be removed from self.cleanup or can it remain in the list?
return

class TestMoveUser(cloudstackTestCase):
Expand Down
29 changes: 18 additions & 11 deletions test/integration/smoke/test_affinity_groups_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ def setUpClass(cls):
cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id

cls._cleanup = []

cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)

projectData = {
"name": "Project",
Expand All @@ -73,6 +76,7 @@ def setUpClass(cls):
account=cls.account.name,
domainid=cls.account.domainid
)
cls._cleanup.append(cls.project)

# Add user to the project
cls.project.addAccount(
Expand All @@ -84,17 +88,22 @@ def setUpClass(cls):
cls.apiclient,
cls.services["service_offerings"]["tiny"]
)
cls._cleanup.append(cls.service_offering)

cls.ag = AffinityGroup.create(cls.apiclient, cls.services["virtual_machine"]["affinity"],projectid=cls.project.id)
cls._cleanup.append(cls.ag)

return

cls._cleanup = [
cls.service_offering,
cls.ag,
cls.project,
cls.account,
]
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return

def tearDown(self):
super(TestDeployVmWithAffinityGroup,self).tearDown()

@attr(tags=["basic", "advanced", "multihost"], required_hardware="false")
def test_DeployVmAntiAffinityGroup_in_project(self):
"""
Expand All @@ -112,6 +121,7 @@ def test_DeployVmAntiAffinityGroup_in_project(self):
serviceofferingid=self.service_offering.id,
affinitygroupnames=[self.ag.name]
)
self.cleanup.append(vm1)

list_vm1 = list_virtual_machines(
self.apiclient,
Expand Down Expand Up @@ -149,6 +159,7 @@ def test_DeployVmAntiAffinityGroup_in_project(self):
serviceofferingid=self.service_offering.id,
affinitygroupnames=[self.ag.name]
)
self.cleanup.append(vm2)
list_vm2 = list_virtual_machines(
self.apiclient,
id=vm2.id
Expand Down Expand Up @@ -182,8 +193,4 @@ def test_DeployVmAntiAffinityGroup_in_project(self):

@classmethod
def tearDownClass(cls):
try:
#Clean up, terminate the created templates
cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
super(TestDeployVmWithAffinityGroup,cls).tearDownClass()
22 changes: 7 additions & 15 deletions test/integration/smoke/test_async_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,24 @@ def setUpClass(cls):
cls.hypervisor
)

cls._cleanup = []

# Create service, disk offerings etc
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.testdata["service_offering"]
)
cls._cleanup.append(cls.service_offering)

cls.disk_offering = DiskOffering.create(
cls.api_client,
cls.testdata["disk_offering"]
)

cls._cleanup = [
cls.service_offering,
cls.disk_offering
]
cls._cleanup.append(cls.disk_offering)

@classmethod
def tearDownClass(cls):
try:
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as exception:
raise Exception("Warning: Exception during cleanup : %s" % exception)
super(TestAsyncJob,cls).tearDownClass()

def setUp(self):
self.apiclient = self.testClient.getApiClient()
Expand All @@ -83,12 +79,7 @@ def setUp(self):
self.cleanup = [self.account]

def tearDown(self):
try:
self.debug("Cleaning up the resources")
cleanup_resources(self.apiclient, self.cleanup)
self.debug("Cleanup complete!")
except Exception as exception:
self.debug("Warning! Exception in tearDown: %s" % exception)
super(TestAsyncJob,self).tearDown()

@attr(tags=["advanced", "eip", "advancedns", "basic", "sg"], required_hardware="false")
def test_query_async_job_result(self):
Expand All @@ -106,6 +97,7 @@ def test_query_async_job_result(self):
diskofferingid=self.disk_offering.id,
hypervisor=self.hypervisor
)
self.cleanup.append(virtual_machine)

response = virtual_machine.getState(
self.apiclient,
Expand Down
4 changes: 2 additions & 2 deletions test/integration/smoke/test_hostha_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def tearDown(self):
self.dbclient.execute("delete from data_center_details where name='resourceHAEnabled'")
self.dbclient.execute("delete from ha_config where resource_type='Host'")
self.dbclient.execute("update host set resource_state='Enabled' where type='Routing' and resource_state='Maintenance'")
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
raise Exception("Warning: Exception during db cleanup : %s" % e)
super(TestHostHA,self).tearDown()


def getFakeMsId(self):
Expand Down