mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
test,refactor: fix test_project_resources cleanup (#8097)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
ba24a18f27
commit
065abe2a3b
@ -551,66 +551,59 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
||||||
if cls.hypervisor.lower() in ['lxc']:
|
if cls.hypervisor.lower() in ['lxc']:
|
||||||
raise unittest.SkipTest("create template from volume is not supported on %s" % cls.hypervisor.lower())
|
raise unittest.SkipTest("create template from volume is not supported on %s" % cls.hypervisor.lower())
|
||||||
|
cls._cleanup = []
|
||||||
|
|
||||||
cls.template = get_template(
|
cls.template = get_template(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.zone.id,
|
cls.zone.id,
|
||||||
cls.services["ostype"]
|
cls.services["ostype"]
|
||||||
)
|
)
|
||||||
cls.services["server"]["zoneid"] = cls.zone.id
|
cls.services["server"]["zoneid"] = cls.zone.id
|
||||||
|
|
||||||
# Create Domains, Account etc
|
# Create Domains, Account etc
|
||||||
cls.domain = Domain.create(
|
cls.domain = Domain.create(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.services["domain"]
|
cls.services["domain"]
|
||||||
)
|
)
|
||||||
|
cls._cleanup.append(cls.domain)
|
||||||
|
|
||||||
cls.account = Account.create(
|
cls.account = Account.create(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.services["account"],
|
cls.services["account"],
|
||||||
domainid=cls.domain.id
|
domainid=cls.domain.id
|
||||||
)
|
)
|
||||||
|
cls._cleanup.append(cls.account)
|
||||||
cls.user = Account.create(
|
cls.user = Account.create(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.services["account"],
|
cls.services["account"],
|
||||||
domainid=cls.domain.id
|
domainid=cls.domain.id
|
||||||
)
|
)
|
||||||
|
cls._cleanup.append(cls.user)
|
||||||
# Create project as a domain admin
|
# Create project as a domain admin
|
||||||
cls.project = Project.create(
|
cls.project = Project.create(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.services["project"],
|
cls.services["project"],
|
||||||
account=cls.account.name,
|
account=cls.account.name,
|
||||||
domainid=cls.account.domainid
|
domainid=cls.account.domainid
|
||||||
)
|
)
|
||||||
|
cls._cleanup.append(cls.project)
|
||||||
cls.services["account"] = cls.account.name
|
cls.services["account"] = cls.account.name
|
||||||
|
|
||||||
# Create Service offering and disk offerings etc
|
# Create Service offering and disk offerings etc
|
||||||
cls.service_offering = ServiceOffering.create(
|
cls.service_offering = ServiceOffering.create(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.services["service_offering"]
|
cls.services["service_offering"]
|
||||||
)
|
)
|
||||||
|
cls._cleanup.append(cls.service_offering)
|
||||||
cls.userapiclient = cls.testClient.getUserApiClient(
|
cls.userapiclient = cls.testClient.getUserApiClient(
|
||||||
UserName=cls.account.name,
|
UserName=cls.account.name,
|
||||||
DomainName=cls.domain.name
|
DomainName=cls.domain.name
|
||||||
)
|
)
|
||||||
|
|
||||||
cls._cleanup = [
|
|
||||||
cls.project,
|
|
||||||
cls.service_offering,
|
|
||||||
cls.account,
|
|
||||||
cls.user,
|
|
||||||
cls.domain
|
|
||||||
]
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
try:
|
super(TestTemplates, cls).tearDownClass()
|
||||||
#Cleanup resources used
|
|
||||||
cleanup_resources(cls.api_client, cls._cleanup)
|
|
||||||
except Exception as e:
|
|
||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
|
||||||
return
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.apiclient = self.testClient.getApiClient()
|
self.apiclient = self.testClient.getApiClient()
|
||||||
@ -619,12 +612,7 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
super(TestTemplates, self).tearDown()
|
||||||
#Clean up, terminate the created instance, volumes and snapshots
|
|
||||||
cleanup_resources(self.apiclient, self.cleanup)
|
|
||||||
except Exception as e:
|
|
||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
|
||||||
return
|
|
||||||
|
|
||||||
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns"], required_hardware="false")
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns"], required_hardware="false")
|
||||||
def test_04_public_private_template_use_in_project(self):
|
def test_04_public_private_template_use_in_project(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user